Skip to content
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

Issues in loading Pre-trained model #73

Open
Subhan-Zaheer opened this issue Mar 22, 2024 · 5 comments
Open

Issues in loading Pre-trained model #73

Subhan-Zaheer opened this issue Mar 22, 2024 · 5 comments

Comments

@Subhan-Zaheer
Copy link

Whenever I try to load pre-trained models, I get the following error:

`---------------------------------------------------------------------------
UnpicklingError Traceback (most recent call last)
in <cell line: 7>()
5
6 vtoonify = VToonify(backbone = 'dualstylegan')
----> 7 vtoonify.load_state_dict(torch.load(os.path.join(MODEL_DIR, style_type+'_generator.pt'), map_location=lambda storage, loc: storage)['g_ema'])
8 vtoonify.to(device)
9

1 frames
/usr/local/lib/python3.10/dist-packages/torch/serialization.py in load(f, map_location, pickle_module, weights_only, mmap, **pickle_load_args)
1038 except RuntimeError as e:
1039 raise pickle.UnpicklingError(UNSAFE_MESSAGE + str(e)) from None
-> 1040 return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
1041
1042

/usr/local/lib/python3.10/dist-packages/torch/serialization.py in _legacy_load(f, map_location, pickle_module, **pickle_load_args)
1256 "functionality.")
1257
-> 1258 magic_number = pickle_module.load(f, **pickle_load_args)
1259 if magic_number != MAGIC_NUMBER:
1260 raise RuntimeError("Invalid magic number; corrupt file?")

UnpicklingError: invalid load key, '<'.`

Can you please tell what's the issue here, is there a version incompatibility of language or framework.

image

@Subhan-Zaheer Subhan-Zaheer changed the title Issues in loading Issues in loading Pre-trained model Mar 22, 2024
@Subhan-Zaheer
Copy link
Author

Whenever I try to load pre-trained models, I get the following error:

`--------------------------------------------------------------------------- UnpicklingError Traceback (most recent call last) in <cell line: 7>() 5 6 vtoonify = VToonify(backbone = 'dualstylegan') ----> 7 vtoonify.load_state_dict(torch.load(os.path.join(MODEL_DIR, style_type+'_generator.pt'), map_location=lambda storage, loc: storage)['g_ema']) 8 vtoonify.to(device) 9

1 frames /usr/local/lib/python3.10/dist-packages/torch/serialization.py in load(f, map_location, pickle_module, weights_only, mmap, **pickle_load_args) 1038 except RuntimeError as e: 1039 raise pickle.UnpicklingError(UNSAFE_MESSAGE + str(e)) from None -> 1040 return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args) 1041 1042

/usr/local/lib/python3.10/dist-packages/torch/serialization.py in _legacy_load(f, map_location, pickle_module, **pickle_load_args) 1256 "functionality.") 1257 -> 1258 magic_number = pickle_module.load(f, **pickle_load_args) 1259 if magic_number != MAGIC_NUMBER: 1260 raise RuntimeError("Invalid magic number; corrupt file?")

UnpicklingError: invalid load key, '<'.`

Can you please tell what's the issue here, is there a version incompatibility of language or framework.

image

@williamyang1991

@neverbiasu
Copy link

I guess it caused by invalid file path, did ur dictionary contains "<"?

@Subhan-Zaheer
Copy link
Author

No, it doesn't contain this '<'.

@williamyang1991
Copy link
Owner

Here is a similar issue
CSAILVision/places365#49

I suppose your model is not completely downloaded?

@ghost
Copy link

ghost commented May 21, 2024

@Subhan-Zaheer Were you able to solve this issue ? I am encountering same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants