Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:: replace scipy.misc with imageio and skimage #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions is_fid_pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__))

Expand Down Expand Up @@ -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)
Expand Down