Skip to content

Instantly share code, notes, and snippets.

View MercuriXito's full-sized avatar
🎯
Focusing

Shihui MercuriXito

🎯
Focusing
  • Beijing
View GitHub Profile
@MercuriXito
MercuriXito / ImageViewer.py
Last active May 6, 2022 12:53
A Tkinter based GUI demo which is able to show images and support dragging, scaling.
""" ImageViewer which supports dragging and scaling and
fits altered size of windows.
"""
import os
import cv2
import numpy as np
from PIL import ImageTk
import PIL.Image as Image
from copy import deepcopy
@MercuriXito
MercuriXito / GanTrainer.md
Last active April 28, 2020 01:37
GAN Training FrameWork

Train Frame

GAN 训练框架版本v2。

Modified

对简单的 Conditional GAN 和 Unconditional GAN 可以直接简单套用。 自定义的训练方式通过继承TrainerFrame类,并重写某些函数的形式,如例子的DCGANTrainer

Problems Remained

@MercuriXito
MercuriXito / BibtexParser.py
Last active March 21, 2020 14:04
LaTeX2Markdown (Adapted from https://github.com/ajtulloch/LaTeX2Markdown): Add features: (1) Conver Cross-Ref. (2) Conver verbatim to codes.
import os, sys, json
import re
class BibtexParser:
""" Simple Parser of bibtex
"""
def __init__(self, path, encoding = "utf-8"):
# self.path = os.path.abspath(path)
self.path = path
self.encoding = encoding
@MercuriXito
MercuriXito / ImageEval.py
Last active March 20, 2020 07:52
Pytorch based implemented Evaluation Methods of Image Quality: MSE, PSNR, SSIM
import torch
import torch.nn.functional as F
from torch.nn.functional import conv2d
import numpy as np
mse = lambda x,y: np.mean((x-y).flatten() ** 2)
def psnr(image1, image2, L = 255, eps = 1e-6):
m = mse(image1, image2)
return np.log10(L**2 / (m + eps)) * 10
@MercuriXito
MercuriXito / ResNetBlock.py
Last active February 29, 2020 13:22
Self-Implemented ResNet Structure with pytorch. ( Structure configuration adaptable )
import torch
import torch.nn as nn
import torch.nn.functional as F
# apply 函数针对net.children(), apply的参数为一个函数,该函数的输入是 Module
def weights_init(m):
class_name = m.__class__.__name__
if class_name.find("conv") != -1:
m.weight.data.normal_(0,0.02)
elif class_name.find("norm") != -1:
@MercuriXito
MercuriXito / spectral-norm.ipynb
Created February 12, 2020 08:11
Spectral Norm.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.