deepinv
deepinv copied to clipboard
`download_archive` error message
When using download_archive but the URL doesn't exist (for example, when using get_image_url but the image name doesn't exist in the DeepInverse HuggingFace repo), a tiny file will still be downloaded silently. When trying to load it with torch, you get a very cryptic error.
Location:
https://github.com/deepinv/deepinv/blob/f796e3fbba7bc15a0d61e99c6f31ad0422ed89de/deepinv/datasets/utils.py#L67
Solution:
If the URL returns 404 throw an error. And, if get_image_url is used but the image isn't in the HuggingFace, then throw an error.
Minimal reproducible:
import deepinv as dinv
import torch
import os
random_name = "blah.blah"
dinv.datasets.utils.download_archive(dinv.utils.demo.get_image_url(random_name), f"{os.getcwd()}/{random_name}")
torch.load(random_name, weights_only=True)
Traceback:
---------------------------------------------------------------------------
UnpicklingError Traceback (most recent call last)
Cell In[2], line 6
4 random_name = "blah.blah"
5 dinv.datasets.utils.download_archive(dinv.utils.demo.get_image_url(random_name), f"{os.getcwd()}/{random_name}")
----> 6 torch.load("blah.blah", weights_only=True)
File lib\site-packages\torch\serialization.py:1383, in load(f, map_location, pickle_module, weights_only, mmap, **pickle_load_args)
1376 return _legacy_load(
1377 opened_file,
1378 map_location,
1379 _weights_only_unpickler,
1380 **pickle_load_args,
1381 )
1382 except pickle.UnpicklingError as e:
-> 1383 raise pickle.UnpicklingError(_get_wo_message(str(e))) from None
1384 return _legacy_load(
1385 opened_file, map_location, pickle_module, **pickle_load_args
1386 )
UnpicklingError: Weights only load failed. Re-running `torch.load` with `weights_only` set to `False` will likely succeed, but it can result in arbitrary code execution. Do it only if you got the file from a trusted source.
Please file an issue with the following so that we can make `weights_only=True` compatible with your use case: WeightsUnpickler error: Unsupported operand 69
Check the documentation of torch.load to learn more about types accepted by default with weights_only https://pytorch.org/docs/stable/generated/torch.load.html.
Hello! I'm interested in working on this good first issue. Could you please assign it to me?