-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil.py
executable file
·29 lines (21 loc) · 955 Bytes
/
util.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import os
import torch
# list of possible model architectures
models_names = ["efficient_b0", "efficient_b4", "vgg16", "res50", "resnext", "coatnet", "swin_large", "swin_base", "swin_tiny", "vit_base", "vit_large", "deit_base", "deit_small", "bit", "blip2", "beit", "convnext", "regnet"]
# list of possible datasets for testing
list_data = ["FFpp1", "FFpp2", "FFpp3", "FFpp4", "StyleGAN", "VQGAN", "PNDM", "DDPM", "LDM", "DDIM", "ProGAN"]
def mkdirs(paths):
if isinstance(paths, list) and not isinstance(paths, str):
for path in paths:
mkdir(path)
else:
mkdir(paths)
def mkdir(path):
if not os.path.exists(path):
os.makedirs(path)
def unnormalize(tens, mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]):
# assume tensor of shape NxCxHxW
return tens * torch.Tensor(std)[None, :, None, None] + torch.Tensor(
mean)[None, :, None, None]
results_dir = './results/'
mkdir(results_dir)