David310/Detect_AI-generated_Image
4
1import os2import torch3 4 5def mkdirs(paths):6 if isinstance(paths, list) and not isinstance(paths, str):7 for path in paths:8 mkdir(path)9 else:10 mkdir(paths)11 12 13def mkdir(path):14 if not os.path.exists(path):15 os.makedirs(path)16 17 18def unnormalize(tens, mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]):19 # assume tensor of shape NxCxHxW20 return tens * torch.Tensor(std)[None, :, None, None] + torch.Tensor(21 mean)[None, :, None, None]