33
33
"""
34
34
import os
35
35
import pathlib
36
- from argparse import ArgumentDefaultsHelpFormatter , ArgumentParser
36
+ from argparse import Namespace
37
37
38
38
import numpy as np
39
39
import torch
@@ -51,24 +51,6 @@ def tqdm(x):
51
51
52
52
from pytorch_fid .inception import InceptionV3
53
53
54
- parser = ArgumentParser (formatter_class = ArgumentDefaultsHelpFormatter )
55
- parser .add_argument ('--batch-size' , type = int , default = 50 ,
56
- help = 'Batch size to use' )
57
- parser .add_argument ('--num-workers' , type = int ,
58
- help = ('Number of processes to use for data loading. '
59
- 'Defaults to `min(8, num_cpus)`' ))
60
- parser .add_argument ('--device' , type = str , default = None ,
61
- help = 'Device to use. Like cuda, cuda:0 or cpu' )
62
- parser .add_argument ('--dims' , type = int , default = 2048 ,
63
- choices = list (InceptionV3 .BLOCK_INDEX_BY_DIM ),
64
- help = ('Dimensionality of Inception features to use. '
65
- 'By default, uses pool3 features' ))
66
- parser .add_argument ('--save-stats' , action = 'store_true' ,
67
- help = ('Generate an npz archive from a directory of samples. '
68
- 'The first path is used as input and the second as output.' ))
69
- parser .add_argument ('--path' , type = str , nargs = 2 , default = [r"C:\Users\PC\Desktop\output" , "pytorch_fid/imagenet.npz" ],
70
- help = ('Paths to the generated images or '
71
- 'to .npz statistic files' ))
72
54
73
55
IMAGE_EXTENSIONS = {'bmp' , 'jpg' , 'jpeg' , 'pgm' , 'png' , 'ppm' ,
74
56
'tif' , 'tiff' , 'webp' }
@@ -286,7 +268,14 @@ def save_fid_stats(paths, batch_size, device, dims, num_workers=1):
286
268
287
269
288
270
def main (path = None , dataset_name = "imagenet_compatible" ):
289
- args = parser .parse_args ()
271
+ args = Namespace (
272
+ batch_size = 50 ,
273
+ num_workers = None , # You can manually set this value if needed
274
+ device = None ,
275
+ dims = 2048 ,
276
+ save_stats = False ,
277
+ path = [r"C:\Users\PC\Desktop\output" , "pytorch_fid/imagenet.npz" ]
278
+ )
290
279
291
280
if path is not None :
292
281
args .path [0 ] = path
0 commit comments