GaParmar / clean-fid

PyTorch - FID calculation with proper image resizing and quantization steps [CVPR 2022]
https://www.cs.cmu.edu/~clean-fid/
MIT License
944 stars 72 forks source link

PytorchStreamReader failed reading zip archive: failed finding central directory #9

Closed zhyyfaan closed 3 years ago

zhyyfaan commented 3 years ago

image I have this problem, and I guess it may relate to the version of pytorch or other environments, I don't know how to deal with.

BrandoZhang commented 3 years ago

image I have this problem, and I guess it may relate to the version of pytorch or other environments, I don't know how to deal with.

Hi @zhyyfaan , I got the same issue. Would you like to share how did you solve this problem?

zhyyfaan commented 3 years ago

I forgot to download the inception model , you can check if you hava the same problem.

------------------ 原始邮件 ------------------ 发件人: "Brando @.>; 发送时间: 2021年9月14日(星期二) 晚上6:15 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [GaParmar/clean-fid] PytorchStreamReader failed reading zip archive: failed finding central directory (#9)

I have this problem, and I guess it may relate to the version of pytorch or other environments, I don't know how to deal with.

Hi @zhyyfaan , I got the same issue. Would you like to share how did you solve this problem?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

GaParmar commented 3 years ago

This is great that you were able to resolve this issue. Feel free to reopen this issue and let me know if the problem persists.

zhyyfaan commented 3 years ago

OK!

------------------ 原始邮件 ------------------ 发件人: "Gaurav @.>; 发送时间: 2021年9月14日(星期二) 晚上7:01 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [GaParmar/clean-fid] PytorchStreamReader failed reading zip archive: failed finding central directory (#9)

This is great that you were able to resolve this issue. Feel free to reopen this issue and let me know if the problem persists.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

BrandoZhang commented 3 years ago

@zhyyfaan Which PyTorch version did you use?

From code below, the Inception model will be downloaded automatically.

https://github.com/GaParmar/clean-fid/blob/8f06f1b2fc4908184fbc0d10714d7b93ea4d18fd/cleanfid/features.py#L20

BrandoZhang commented 3 years ago

Some of my environment:

torch==1.7.0
clean-fid==0.1.13
requests==2.25.1
Pillow==8.3.2
tqdm==4.51.0
torchvision==0.8.1
scipy==1.7.1
GaParmar commented 3 years ago

Can you try manually deleting the inception weights currently downloaded in the "/tmp" directory and running the script again?

BrandoZhang commented 3 years ago

Can you try manually deleting the inception weights currently downloaded in the "/tmp" directory and running the script again?

Awesome, it works!

BTW, when I make_custom_stats, I got the following error:

saving custom stats to /home/brando/.local/lib/python3.7/site-packages/cleanfid/stats/sunglasses_clean_custom_na.npz
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/brando/.local/lib/python3.7/site-packages/cleanfid/fid.py", line 303, in make_custom_stats
    np.savez_compressed(outf, mu=mu, sigma=sigma)
  File "<__array_function__ internals>", line 6, in savez_compressed
  File "/usr/local/lib/python3.7/dist-packages/numpy/lib/npyio.py", line 686, in savez_compressed
    _savez(file, args, kwds, True)
  File "/usr/local/lib/python3.7/dist-packages/numpy/lib/npyio.py", line 712, in _savez
    zipf = zipfile_factory(file, mode="w", compression=compression)
  File "/usr/local/lib/python3.7/dist-packages/numpy/lib/npyio.py", line 112, in zipfile_factory
    return zipfile.ZipFile(file, *args, **kwargs)
  File "/usr/lib/python3.7/zipfile.py", line 1204, in __init__
    self.fp = io.open(file, filemode)
FileNotFoundError: [Errno 2] No such file or directory: '/home/brando/.local/lib/python3.7/site-packages/cleanfid/stats/sunglasses_clean_custom_na.npz'

It was resolved when I manually created directory stats in /home/brando/.local/lib/python3.7/site-packages/cleanfid/.

Maybe you could os.makedirs(xxx, exist_ok=True) after https://github.com/GaParmar/clean-fid/blob/8f06f1b2fc4908184fbc0d10714d7b93ea4d18fd/cleanfid/fid.py#L284 .

BrandoZhang commented 3 years ago

Hi @GaParmar, one more issue, can I create custom dataset statistics to compute KID?

In my trial, after make_custom_stats, the invoking of compute_fid works fine but compute_kid tries to download the statistics:

>>> fid.compute_kid('sunglasses/0', dataset_name='sunglasses', mode='clean', dataset_res=256, dataset_split='custom')
compute KID of a folder with sunglasses statistics
downloading statistics to /home/brando/.local/lib/python3.7/site-packages/cleanfid/stats/sunglasses_clean_custom_na_kid.npz
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/brando/.local/lib/python3.7/site-packages/cleanfid/fid.py", line 335, in compute_kid
    mode=mode, seed=0, split=dataset_split, metric="KID")
  File "/home/brando/.local/lib/python3.7/site-packages/cleanfid/features.py", line 95, in get_reference_statistics
    fpath = check_download_url(local_folder=stats_folder, url=url)
  File "/home/brando/.local/lib/python3.7/site-packages/cleanfid/downloads_helper.py", line 27, in check_download_url
    with urllib.request.urlopen(url) as response, open(local_path, 'wb') as f:
  File "/usr/lib/python3.7/urllib/request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.7/urllib/request.py", line 531, in open
    response = meth(req, response)
  File "/usr/lib/python3.7/urllib/request.py", line 641, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python3.7/urllib/request.py", line 569, in error
    return self._call_chain(*args)
  File "/usr/lib/python3.7/urllib/request.py", line 503, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.7/urllib/request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: Not Found
GaParmar commented 3 years ago

Thanks for pointing this out! Yeah I will add this in the next release. (meanwhile, a temporary fix can be to manually place the custom stats in the folder) Could you make a new open github issue for these?

BrandoZhang commented 3 years ago

Thanks for pointing this out! Yeah I will add this in the next release. (meanwhile, a temporary fix can be to manually place the custom stats in the folder) Could you make a new open github issue for these?

Sure, thanks for your patience!

loverabiola1 commented 2 years ago

OK! ------------------ 原始邮件 ------------------ 发件人: "Gaurav @.>; 发送时间: 2021年9月14日(星期二) 晚上7:01 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [GaParmar/clean-fid] PytorchStreamReader failed reading zip archive: failed finding central directory (#9) This is great that you were able to resolve this issue. Feel free to reopen this issue and let me know if the problem persists. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

l have the same issue what will i do please

loverabiola1 commented 2 years ago

WhatsApp Image 2022-10-06 at 12 40 25 AM

loverabiola1 commented 2 years ago

i keep on bring this up and it wont pop the camera