Questions about batch size
udemegane opened this issue · comments
I get the following error:
~/w/sg2 ❯❯❯ python -m pytorch_fid --batch-size 1 ~/Documents/dataset/r-sample ~/Documents/dataset/g-sample/6/088000
100%|█████████████████████████████████████████████████████████████████| 2702/2702 [02:58<00:00, 15.17it/s]
Warning: batch size is bigger than the data size. Setting batch size to data size
Traceback (most recent call last):
File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/udemegane/workspace/sg2/venv38sg2/lib/python3.8/site-packages/pytorch_fid/__main__.py", line 4, in <module>
pytorch_fid.fid_score.main()
File "/home/udemegane/workspace/sg2/venv38sg2/lib/python3.8/site-packages/pytorch_fid/fid_score.py", line 249, in main
fid_value = calculate_fid_given_paths(args.path,
File "/home/udemegane/workspace/sg2/venv38sg2/lib/python3.8/site-packages/pytorch_fid/fid_score.py", line 238, in calculate_fid_given_paths
m2, s2 = _compute_statistics_of_path(paths[1], model, batch_size,
File "/home/udemegane/workspace/sg2/venv38sg2/lib/python3.8/site-packages/pytorch_fid/fid_score.py", line 218, in _compute_statistics_of_path
m, s = calculate_activation_statistics(files, model, batch_size,
File "/home/udemegane/workspace/sg2/venv38sg2/lib/python3.8/site-packages/pytorch_fid/fid_score.py", line 204, in calculate_activation_statistics
act = get_activations(files, model, batch_size, dims, cuda)
File "/home/udemegane/workspace/sg2/venv38sg2/lib/python3.8/site-packages/pytorch_fid/fid_score.py", line 102, in get_activations
for i in tqdm(range(0, len(files), batch_size)):
ValueError: range() arg 3 must not be zero
This error occurs despite a batch size that is clearly smaller than the dataset (eg 1).
I don't know the cause.
Thank you.
I suspect that no image files were found, hence the batch size was set to zero. Currently, only image files with the extensions .png and .jpg are recognized by default.
Oh, I found out why. It was quite simple. I had mistakenly thought that the contents of the directory would be loaded recursively.
Surely that doesn't recognize any images, lol.
Thanks!