mseitzer / pytorch-fid

Compute FID scores with PyTorch.
Apache License 2.0
3.22k stars 497 forks source link

batch_size error #94

Closed chokevin8 closed 1 year ago

chokevin8 commented 1 year ago

This is the code that I ran, and the error that I got:

(wsi_analysis1) C:\Users\Kevin\PycharmProjects\wsi_analysis>python -m pytorch_fid \shelter\Kyu\unstain2stain\tiles\registrated_tiles\HE\OTS_14832_3_he\72806_50278xy5509.png C:\Users\Kevin\PycharmProjects\pix2pix\ pytorch-CycleGAN-and-pix2pix\results\unstain2stain_pix2pix\test_pix2pix_latest\images\114818_62287xy5509_fake_B.png
Warning: batch size is bigger than the data size. Setting batch size to data size Traceback (most recent call last): File "C:\Users\Kevin.conda\envs\wsi_analysis1\lib\runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Users\Kevin.conda\envs\wsi_analysis1\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "C:\Users\Kevin.conda\envs\wsi_analysis1\lib\site-packages\pytorch_fid__main__.py", line 3, in pytorch_fid.fid_score.main() File "C:\Users\Kevin.conda\envs\wsi_analysis1\lib\site-packages\pytorch_fid\fid_score.py", line 313, in main fid_value = calculate_fid_given_paths(args.path, File "C:\Users\Kevin.conda\envs\wsi_analysis1\lib\site-packages\pytorch_fid\fid_score.py", line 259, in calculate_fid_given_paths m1, s1 = compute_statistics_of_path(paths[0], model, batch_size, File "C:\Users\Kevin.conda\envs\wsi_analysis1\lib\site-packages\pytorch_fid\fid_score.py", line 243, in compute_statistics_of_path m, s = calculate_activation_statistics(files, model, batch_size, File "C:\Users\Kevin.conda\envs\wsi_analysis1\lib\site-packages\pytorch_fid\fid_score.py", line 228, in calculate_activation_statistics act = get_activations(files, model, batch_size, dims, device, num_workers) File "C:\Users\Kevin.conda\envs\wsi_analysis1\lib\site-packages\pytorch_fid\fid_score.py", line 122, in get_activations dataloader = torch.utils.data.DataLoader(dataset, File "C:\Users\Kevin.conda\envs\wsi_analysis1\lib\site-packages\torch\utils\data\dataloader.py", line 350, in init batch_sampler = BatchSampler(sampler, batch_size, drop_last) File "C:\Users\Kevin.conda\envs\wsi_analysis1\lib\site-packages\torch\utils\data\sampler.py", line 232, in init raise ValueError("batch_size should be a positive integer value, " ValueError: batch_size should be a positive integer value, but got batch_size=0

I checked that both paths are valid paths to an image, and they're both .png images of the same size (1024 x 1024). Why am I keep getting this error? Help would be appreciated. Thanks!

peterwisu commented 1 year ago

same problem here

chokevin8 commented 1 year ago

@peterwisu I fixed this error a while back, forgot to close the issue. You get this error if you input a path for a .png, you instead want to input the file directory path that contains the images.

Royalbx commented 7 months ago

I set the path as directory,but still have same error.

dzy-cxy commented 7 months ago

I still have this problem, how to solve it

xiaoxiaodadada commented 7 months ago

how to solve it,please

dzy-cxy commented 7 months ago

how to solve it,please I solved it by puting all of the pictures into one folder, without any subfolders.

xiaoxiaodadada commented 7 months ago

thank you!