Skip to content

Commit 3b03f2f

Browse files
authored
fix:: replace scipy.misc with imageio and skimage
As state by @ML-Chen, `scipy.misc.imread` and `scipy.misc.imresize` has been deprecated and is no longer available with recent versions of scipy. Instead, we can replace it with `from imageio import imread` and `from skimage.transform import resize`. This should close lzhbrian#2.
1 parent 7f2f99c commit 3b03f2f

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

is_fid_pytorch.py

+13-9
Original file line numberDiff line numberDiff line change
@@ -83,24 +83,28 @@
8383
* https://paperswithcode.com/sota/image-generation-generative-models-of-ci
8484
* https://paperswithcode.com/task/conditional-image-generation
8585
"""
86+
import os
87+
import sys
88+
import random
89+
import pathlib
90+
import numpy as np
8691

8792
import torch
8893
import torch.nn as nn
94+
import torch.utils.data
95+
8996
from torch.autograd import Variable
9097
from torch.nn import functional as F
91-
import torch.utils.data
9298
from torchvision.models.inception import inception_v3
9399

100+
from imageio import imread
101+
from skimage.transform import resize
94102
from scipy.stats import entropy
95-
import scipy.misc
96103
from scipy import linalg
97-
import numpy as np
104+
98105
from tqdm import tqdm
99106
from glob import glob
100-
import pathlib
101-
import os
102-
import sys
103-
import random
107+
104108

105109
CUR_DIRNAME = os.path.dirname(os.path.abspath(__file__))
106110

@@ -376,8 +380,8 @@ def read_folder(foldername):
376380
img_list = []
377381
print('Reading Images from %s ...' % foldername)
378382
for file in tqdm(files):
379-
img = scipy.misc.imread(file, mode='RGB')
380-
img = scipy.misc.imresize(img, (299, 299), interp='bilinear')
383+
img = imread(file, pilmode='RGB')
384+
img = resize(img, (299, 299), mode='symmetric', preserve_range=True)
381385
img = np.cast[np.float32]((-128 + img) / 128.) # 0~255 -> -1~1
382386
img = np.expand_dims(img, axis=0).transpose(0, 3, 1, 2) # NHWC -> NCHW
383387
img_list.append(img)

0 commit comments

Comments
 (0)