PeterWang512 / GANSketching

Sketch Your Own GAN: Customizing a GAN model with hand-drawn sketches.
https://peterwang512.github.io/GANSketching
MIT License
711 stars 95 forks source link

Error(s) in loading state_dict for Generator #26

Closed SEELE0 closed 1 year ago

SEELE0 commented 1 year ago

I can run the first two samples to generate the cat image, but when I run the third sample command, I get an error with the message:

 File "generate.py", line 93, in <module>
    netG.load_state_dict(checkpoint)
  File "D:\Code\Anaconda\envs\test\lib\site-packages\torch\nn\modules\module.py", line 1407, in load_state_dict
    self.__class__.__name__, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for Generator:
        Unexpected key(s) in state_dict: "convs.12.conv.weight", "convs.12.conv.blur.kernel", "convs.12.conv.modulation.weight", "convs.12.conv.modulation.bias", "convs.12.noise.weight      netG.load_state_dict(checkpoint)
PeterWang512 commented 1 year ago

Did you make sure you have passed in the argument --size 1024 in the sample script?

SEELE0 commented 1 year ago

Did you make sure you have passed in the argument --size 1024 in the sample script?

Thanks for the reply when I use the argument --size 1024 will not get this error , but maybe my Gpu 1660ti performance should not be quite enough,when use--size1024,will showCUDA out of memory. Tried to allocate 2.50 GiB (GPU 0; 6.00 GiB total capacity; 3.94 GiB already allocated; 0 bytes free; 4.54 GiB reserved in total by PyTorch) ,so i think maybe change --size from 1024 to 800 will run success ,and than show the first error message

PeterWang512 commented 1 year ago

yes, unfortunately the face model only supports size with 1024, so you will run into out of memory issue. Maybe try reducing the batch size? Something like --batch_size 5

SEELE0 commented 1 year ago

Yes, unfortunately the face model only supports a size of 1024, so memory is running out. Maybe you should try to reduce the batch size? Something like --batch_size 5

Problem solved, thanks for reply.🥳