williamyang1991 / VToonify

[SIGGRAPH Asia 2022] VToonify: Controllable High-Resolution Portrait Video Style Transfer
Other
3.53k stars 442 forks source link

Issues in loading Pre-trained model #73

Open Subhan-Zaheer opened 5 months ago

Subhan-Zaheer commented 5 months ago

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 commented 5 months ago

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 commented 5 months ago

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

Subhan-Zaheer commented 5 months ago

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

williamyang1991 commented 5 months ago

Here is a similar issue https://github.com/CSAILVision/places365/issues/49

I suppose your model is not completely downloaded?

ghost commented 3 months ago

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