'NoneType' object has no attribute 'load_state_dict' #115

Closed
opened 2026-01-29 21:42:43 +00:00 by claunia · 2 comments
Owner

Originally created by @pratikgujral on GitHub (Dec 12, 2021).

Hi,

I am running the code "as is" on Google Colab (GPU runtime). Upon executing the following line in the code
!python inference_gfpgan.py --upscale 2 --test_path inputs/upload --save_root results --model_path experiments/pretrained_models/GFPGANCleanv1-NoCE-C2.pth --bg_upsampler realesrgan, I am getting the following error:

Traceback (most recent call last):
  File "inference_gfpgan.py", line 113, in <module>
    main()
  File "inference_gfpgan.py", line 56, in main
    half=True)  # need to set False in CPU mode
  File "/usr/local/lib/python3.7/dist-packages/realesrgan/utils.py", line 49, in __init__
    model.load_state_dict(loadnet[keyname], strict=True)
AttributeError: 'NoneType' object has no attribute 'load_state_dict'

image

It looks like the external code for ESR GAN has changed.

How do I get around this error?

Originally created by @pratikgujral on GitHub (Dec 12, 2021). Hi, I am running the code "as is" on Google Colab (GPU runtime). Upon executing the following line in the code `!python inference_gfpgan.py --upscale 2 --test_path inputs/upload --save_root results --model_path experiments/pretrained_models/GFPGANCleanv1-NoCE-C2.pth --bg_upsampler realesrgan`, I am getting the following error: ``` Traceback (most recent call last): File "inference_gfpgan.py", line 113, in <module> main() File "inference_gfpgan.py", line 56, in main half=True) # need to set False in CPU mode File "/usr/local/lib/python3.7/dist-packages/realesrgan/utils.py", line 49, in __init__ model.load_state_dict(loadnet[keyname], strict=True) AttributeError: 'NoneType' object has no attribute 'load_state_dict' ``` ![image](https://user-images.githubusercontent.com/5672819/145715272-3abb7501-40c4-45bc-b6fe-02fc2c6b757e.png) It looks like the external code for ESR GAN has changed. How do I get around this error?
Author
Owner

@xinntao commented on GitHub (Dec 12, 2021):

Thanks for reporting this issue. I have fixed it now. Please have a try:-)

@xinntao commented on GitHub (Dec 12, 2021): Thanks for reporting this issue. I have fixed it now. Please have a try:-)
Author
Owner

@bochkarev-artem commented on GitHub (Dec 12, 2021):

fast response, thank you!

@bochkarev-artem commented on GitHub (Dec 12, 2021): fast response, thank you!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: TencentARC/GFPGAN#115