diff --git a/is_fid_pytorch.py b/is_fid_pytorch.py index a6bfdff..5bbf4c8 100644 --- a/is_fid_pytorch.py +++ b/is_fid_pytorch.py @@ -83,24 +83,28 @@ * https://paperswithcode.com/sota/image-generation-generative-models-of-ci * https://paperswithcode.com/task/conditional-image-generation """ +import os +import sys +import random +import pathlib +import numpy as np import torch import torch.nn as nn +import torch.utils.data + from torch.autograd import Variable from torch.nn import functional as F -import torch.utils.data from torchvision.models.inception import inception_v3 +from PIL import Image +from skimage.transform import resize from scipy.stats import entropy -import scipy.misc from scipy import linalg -import numpy as np + from tqdm import tqdm from glob import glob -import pathlib -import os -import sys -import random + CUR_DIRNAME = os.path.dirname(os.path.abspath(__file__)) @@ -376,8 +380,8 @@ def read_folder(foldername): img_list = [] print('Reading Images from %s ...' % foldername) for file in tqdm(files): - img = scipy.misc.imread(file, mode='RGB') - img = scipy.misc.imresize(img, (299, 299), interp='bilinear') + img = Image.open(file) + img = np.array(img.resize((299, 299), resample=Image.BILINEAR)) img = np.cast[np.float32]((-128 + img) / 128.) # 0~255 -> -1~1 img = np.expand_dims(img, axis=0).transpose(0, 3, 1, 2) # NHWC -> NCHW img_list.append(img)