This commit is contained in:
chun 2023-12-22 00:22:44 +08:00
parent 9744980ede
commit b62dc1b83f
3 changed files with 19 additions and 0 deletions

BIN
demo/kodim08.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 770 KiB

6
requirements.txt Normal file
View File

@ -0,0 +1,6 @@
torch
torchvison
matplotlib
tqdm
numpy
fraction

13
scripts.py Normal file
View File

@ -0,0 +1,13 @@
import torch
import torch.nn as nn
def image_normalization(norm_type):
def _inner(tensor: torch.Tensor):
if norm_type == 'nomalization':
return tensor / 255.0
elif norm_type == 'denormalization':
return (tensor * 255.0).type(torch.FloatTensor)
else:
raise Exception('Unknown type of normalization')
return _inner