-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Re-upload weights for old model with new serialization #2068
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
For ref, the following classifications model urls raise an
|
same issue for me |
@BIGBALLON the issues should have been fixed in the latest release already. |
Hi, @NicolasHug, thanks for your reply. 🐛 BugTo ReproduceSteps to reproduce the behavior: 1 download the official resnet18 mode( import io
import torch
with open('resnet18-5c106cde.pth', 'rb') as f:
buffer = io.BytesIO(f.read())
torch.load(buffer) 3 got the following error: Traceback (most recent call last):
File "test.py", line 5, in <module>
torch.load(buffer)
File "/mnt/test/miniconda/envs/open-mmlab/lib/python3.7/site-packages/torch/serialization.py", line 595, in load
return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
File "/mnt/test/miniconda/envs/open-mmlab/lib/python3.7/site-packages/torch/serialization.py", line 764, in _legacy_load
magic_number = pickle_module.load(f, **pickle_load_args)
_pickle.UnpicklingError: unpickling stack underflow
Expected behaviorEnvironment
Additional context
|
OK, that's because you're still using the "old" weights. The issue won't and cannot be fixed for the old weights. The new weights are at https://download.pytorch.org/models/resnet18-f37072fd.pth Just delete the old ones and re-download the new ones (you can just call |
Thanks, @NicolasHug, the new weight can be loaded! |
Hi, I also encountered this issue when using torch.load() for vgg19-dcbb9e9d.pth, with torch==1.13.0, torchvision=0.14.0. @NicolasHug |
Some of the oldest models we have (including resnets) have been serialized with a legacy format which, while is mostly compatible with the current code, has some corner cases that do not work as expected anymore, see pytorch/pytorch#31615 (basically, if the data is in a
BytesIO
object it doesn't work).Here is a snippet to reproduce the problem:
This fails. We should re-save those weights and re-upload them (while keeping the old files around for BC) and update the paths in the model files to use the new files. This code re-downloads the old files and re-serializes it with the new format
One thing to keep in mind is if changing the default weights files (while being equivalent to the old models) won't bring unexpected changes / issues to some users, as it will trigger a re-download of the file, which might fail because of many reasons (the server doesn't have access to internet, files have been manually downloaded, etc).
The text was updated successfully, but these errors were encountered: