mXlab / cavernes

New art project involving GANs and cave paintings
GNU General Public License v3.0
1 stars 0 forks source link

Unable to run video.py: unable to load save model #1

Closed sofian closed 3 years ago

sofian commented 3 years ago

I tried to run the script from a Collab environment. I am getting the following error. I tried to reinstall lightweight-gan with version 0.12.3 but it does not work

!pip install lightweight-gan==0.12.3 pytorch-fid

Error:

continuing from previous epoch - 122
loading from version 0.12.3
unable to load save model. please try downgrading the package to the version specified by the saved model
Traceback (most recent call last):
  File "video.py", line 55, in <module>
    model_begin = load_model(args.epoch_begin, args.model_dir)
  File "video.py", line 24, in load_model
    model.load(num, path)
  File "/content/cavernes/lightweight_gan/lightweight_gan.py", line 1262, in load
    raise e
  File "/content/cavernes/lightweight_gan/lightweight_gan.py", line 1259, in load
    self.GAN.load_state_dict(load_data['GAN'])
  File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1224, in load_state_dict
    self.__class__.__name__, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for LightweightGAN:
    Missing key(s) in state_dict: "D.to_logits.0.weight", "D.to_logits.0.bias", "D.to_logits.2.weight", "D.to_logits.2.bias", "D_aug.D.to_logits.0.weight", "D_aug.D.to_logits.0.bias", "D_aug.D.to_logits.2.weight", "D_aug.D.to_logits.2.bias". 
    Unexpected key(s) in state_dict: "D.to_logits.3.weight", "D.to_logits.3.bias", "D.to_logits.1.weight", "D.to_logits.1.bias", "D_aug.D.to_logits.3.weight", "D_aug.D.to_logits.3.bias", "D_aug.D.to_logits.1.weight", "D_aug.D.to_logits.1.bias"
hugobb commented 3 years ago

I'm in holidays until the end of the week, will try to fix this beginning of next week.

hugobb commented 3 years ago

I have modified the collab, so that it load the model directly from the google drive. It seems to work for me. @sofian Let me know if this fixes the bug for you.

sofian commented 3 years ago

I can now run everything. It generates videos, however, the videos are blank; in VLC they generate errors so I can't read them.

hugobb commented 3 years ago

@sofian This should be fixed now. It was actually not loading the model correctly because it was missing the config file. Now the collab should run correctly :)