voxelmorph / voxelmorph

Unsupervised Learning for Image Registration
Apache License 2.0
2.29k stars 581 forks source link

_pickle.UnpicklingError: invalid load key, 'H'. #543

Open WXY-Belief opened 1 year ago

WXY-Belief commented 1 year ago

hello, when runing your code, there exist a error as follow: Traceback (most recent call last): File "D:\PycharmProjects\3D_align\voxelmorph-dev\register.py", line 77, in model = vxm.networks.VxmDense.load(args.model, device) File "D:\PycharmProjects\3D_align\voxelmorph-dev\voxelmorph\torch\modelio.py", line 74, in load checkpoint = torch.load(path, map_location=torch.device(device)) File "C:\Users\24667.conda\envs\wxy_env\lib\site-packages\torch\serialization.py", line 795, in load return _legacy_load(opened_file, map_location, pickle_module, pickle_load_args) File "C:\Users\24667.conda\envs\wxy_env\lib\site-packages\torch\serialization.py", line 1002, in _legacy_load magic_number = pickle_module.load(f, pickle_load_args) _pickle.UnpicklingError: invalid load key, 'H'.

lchauvin commented 6 months ago

I'm getting the same error. Any help ?

I tried with models: synthmorph.deform.2.h5, vxm_dense_brain_T1_3D_mse.h5, shapes-dice-vel-3-res-8-16-32-256f.h5 and brains-dice-vel-0.5-res-16-256f.h5

I precise that I'm using pytorch backend. Are models provided only for tensorflow ?

A-shazli commented 6 months ago

This is a Keras model .H to open in pytorch i think it should be .pt dont know if there is a way to convert .h to .pt

lchauvin commented 1 month ago

It seems someone tried:

https://github.com/voxelmorph/voxelmorph/pull/596

But to be honest, it doesn't work for me, because load_tf_weights needs an instance of the model as parameter, and only the classes is passed, so named_modules() fail.