No module named 'basicsr.losses.gan_loss' #208

Open
opened 2026-01-29 21:45:42 +00:00 by claunia · 10 comments
Owner

Originally created by @wsysl1989 on GitHub (Jul 13, 2022).

D:\Python\python.exe N:/python/GFPGAN1.34/GFPGAN-master/inference_gfpgan.py
Traceback (most recent call last):
File "N:\python\GFPGAN1.34\GFPGAN-master\inference_gfpgan.py", line 9, in
from gfpgan import GFPGANer
File "N:\python\GFPGAN1.34\GFPGAN-master\gfpgan_init_.py", line 4, in
from .models import *
File "N:\python\GFPGAN1.34\GFPGAN-master\gfpgan\models_init_.py", line 10, in
model_modules = [importlib.import_module(f'gfpgan.models.{file_name}') for file_name in model_filenames]
File "N:\python\GFPGAN1.34\GFPGAN-master\gfpgan\models_init
.py", line 10, in
model_modules = [importlib.import_module(f'gfpgan.models.{file_name}') for file_name in model_filenames]
File "D:\Python\lib\importlib_init
.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "N:\python\GFPGAN1.34\GFPGAN-master\gfpgan\models\gfpgan_model.py", line 6, in
from basicsr.losses.gan_loss import r1_penalty
ModuleNotFoundError: No module named 'basicsr.losses.gan_loss'

Originally created by @wsysl1989 on GitHub (Jul 13, 2022). D:\Python\python.exe N:/python/GFPGAN1.34/GFPGAN-master/inference_gfpgan.py Traceback (most recent call last): File "N:\python\GFPGAN1.34\GFPGAN-master\inference_gfpgan.py", line 9, in <module> from gfpgan import GFPGANer File "N:\python\GFPGAN1.34\GFPGAN-master\gfpgan\__init__.py", line 4, in <module> from .models import * File "N:\python\GFPGAN1.34\GFPGAN-master\gfpgan\models\__init__.py", line 10, in <module> _model_modules = [importlib.import_module(f'gfpgan.models.{file_name}') for file_name in model_filenames] File "N:\python\GFPGAN1.34\GFPGAN-master\gfpgan\models\__init__.py", line 10, in <listcomp> _model_modules = [importlib.import_module(f'gfpgan.models.{file_name}') for file_name in model_filenames] File "D:\Python\lib\importlib\__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "N:\python\GFPGAN1.34\GFPGAN-master\gfpgan\models\gfpgan_model.py", line 6, in <module> from basicsr.losses.gan_loss import r1_penalty ModuleNotFoundError: No module named 'basicsr.losses.gan_loss'
Author
Owner

@tg-bomze commented on GitHub (Jul 13, 2022):

git clone https://github.com/TencentARC/GFPGAN.git
cd GFPGAN
git checkout bc3f0c4
pip install basicsr==1.3.5
@tg-bomze commented on GitHub (Jul 13, 2022): ``` git clone https://github.com/TencentARC/GFPGAN.git cd GFPGAN git checkout bc3f0c4 pip install basicsr==1.3.5 ```
Author
Owner

@xinntao commented on GitHub (Jul 13, 2022):

update basicsr to the latest version v1.4.0

Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: Denis Malimonov @.>
Sent: Wednesday, July 13, 2022 11:00:40 PM
To: TencentARC/GFPGAN @.
>
Cc: Subscribed @.***>
Subject: Re: [TencentARC/GFPGAN] No module named 'basicsr.losses.gan_loss' (Issue #215)

git clone https://github.com/TencentARC/GFPGAN.git
cd GFPGAN
git checkout bc3f0c4
pip install basicsr==1.3.5


Reply to this email directly, view it on GitHubhttps://github.com/TencentARC/GFPGAN/issues/215#issuecomment-1183335332, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AEFDHV6STNZ6YYFMT2LRFO3VT3KZRANCNFSM53PANWGQ.
You are receiving this because you are subscribed to this thread.Message ID: @.***>

@xinntao commented on GitHub (Jul 13, 2022): update basicsr to the latest version v1.4.0 Get Outlook for Android<https://aka.ms/AAb9ysg> ________________________________ From: Denis Malimonov ***@***.***> Sent: Wednesday, July 13, 2022 11:00:40 PM To: TencentARC/GFPGAN ***@***.***> Cc: Subscribed ***@***.***> Subject: Re: [TencentARC/GFPGAN] No module named 'basicsr.losses.gan_loss' (Issue #215) git clone https://github.com/TencentARC/GFPGAN.git cd GFPGAN git checkout bc3f0c4 pip install basicsr==1.3.5 — Reply to this email directly, view it on GitHub<https://github.com/TencentARC/GFPGAN/issues/215#issuecomment-1183335332>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AEFDHV6STNZ6YYFMT2LRFO3VT3KZRANCNFSM53PANWGQ>. You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
Author
Owner

@yubohuangai commented on GitHub (Jul 26, 2022):

Still unsolved.

Installing collected packages: basicsr
Attempting uninstall: basicsr
Found existing installation: basicsr 1.3.5
Uninstalling basicsr-1.3.5:
Successfully uninstalled basicsr-1.3.5
Successfully installed basicsr-1.4.1

@yubohuangai commented on GitHub (Jul 26, 2022): Still unsolved. Installing collected packages: basicsr Attempting uninstall: basicsr Found existing installation: basicsr 1.3.5 Uninstalling basicsr-1.3.5: Successfully uninstalled basicsr-1.3.5 Successfully installed basicsr-1.4.1
Author
Owner

@Ir1d commented on GitHub (Aug 5, 2022):

downgrading from 1.4.1 to 1.3.5 works for me

@Ir1d commented on GitHub (Aug 5, 2022): downgrading from 1.4.1 to 1.3.5 works for me
Author
Owner

@elen07zz commented on GitHub (Sep 13, 2022):

change GFPGAN-master\gfpgan\models\gfpgan_model.py

line: from basicsr.losses.gan_loss import r1_penalty
to
from basicsr.losses.losses import r1_penalty

@elen07zz commented on GitHub (Sep 13, 2022): change GFPGAN-master\gfpgan\models\gfpgan_model.py line: from basicsr.losses.gan_loss import r1_penalty to from basicsr.losses.losses import r1_penalty
Author
Owner

@wsysl1989 commented on GitHub (Sep 13, 2022):

change GFPGAN-master\gfpgan\models\gfpgan_model.py

line: from basicsr.losses.gan_loss import r1_penalty to from basicsr.losses.losses import r1_penalty

thanks,but another problem occurs,can not go on again.
Traceback (most recent call last):
File "N:\python\GFPGAN1.34\GFPGAN-master\inference_gfpgan.py", line 155, in
main()
File "N:\python\GFPGAN1.34\GFPGAN-master\inference_gfpgan.py", line 103, in main
restorer = GFPGANer(
File "N:\python\GFPGAN1.34\GFPGAN-master\gfpgan\utils.py", line 76, in init
self.face_helper = FaceRestoreHelper(
TypeError: init() got an unexpected keyword argument 'use_parse'

@wsysl1989 commented on GitHub (Sep 13, 2022): > change GFPGAN-master\gfpgan\models\gfpgan_model.py > > line: from basicsr.losses.gan_loss import r1_penalty to from basicsr.losses.losses import r1_penalty thanks,but another problem occurs,can not go on again. Traceback (most recent call last): File "N:\python\GFPGAN1.34\GFPGAN-master\inference_gfpgan.py", line 155, in <module> main() File "N:\python\GFPGAN1.34\GFPGAN-master\inference_gfpgan.py", line 103, in main restorer = GFPGANer( File "N:\python\GFPGAN1.34\GFPGAN-master\gfpgan\utils.py", line 76, in __init__ self.face_helper = FaceRestoreHelper( TypeError: __init__() got an unexpected keyword argument 'use_parse'
Author
Owner

@DZai commented on GitHub (Sep 27, 2022):

TypeError: init() got an unexpected keyword argument 'use_parse'

update basicsr to the version v1.4.2, and update facexlib to 0.2.5 works for me. No need to change gfpgan_model.py

@DZai commented on GitHub (Sep 27, 2022): > TypeError: init() got an unexpected keyword argument 'use_parse' update basicsr to the version v1.4.2, and update facexlib to 0.2.5 works for me. No need to change gfpgan_model.py
Author
Owner

@wsysl1989 commented on GitHub (Sep 27, 2022):

TypeError: init() got an unexpected keyword argument 'use_parse'

update basicsr to the version v1.4.2, and update facexlib to 0.2.5 works for me. No need to change gfpgan_model.py

thanks,update basicsr to the version v1.4.2, and update facexlib to 0.2.5 ,still change back " from basicsr.losses.gan_loss import r1_penalty".now,it works for me.

@wsysl1989 commented on GitHub (Sep 27, 2022): > > TypeError: init() got an unexpected keyword argument 'use_parse' > > update basicsr to the version v1.4.2, and update facexlib to 0.2.5 works for me. No need to change gfpgan_model.py thanks,update basicsr to the version v1.4.2, and update facexlib to 0.2.5 ,still change back " from basicsr.losses.gan_loss import r1_penalty".now,it works for me.
Author
Owner

@LightningStalker commented on GitHub (Oct 16, 2022):

change GFPGAN-master\gfpgan\models\gfpgan_model.py

line: from basicsr.losses.gan_loss import r1_penalty to from basicsr.losses.losses import r1_penalty

This also appears to work in stable-diffusion-krita-plugin though the py script is in a different location.

@LightningStalker commented on GitHub (Oct 16, 2022): > change GFPGAN-master\gfpgan\models\gfpgan_model.py > > line: from basicsr.losses.gan_loss import r1_penalty to from basicsr.losses.losses import r1_penalty This also appears to work in stable-diffusion-krita-plugin though the py script is in a different location.
Author
Owner

@wordsand commented on GitHub (Jan 24, 2024):

for my python 3.10.x and basicsr 1.4.2
change to : from basicsr.losses.gan_loss import r1_penalty
works for me.

@wordsand commented on GitHub (Jan 24, 2024): for my python 3.10.x and basicsr 1.4.2 change to : from basicsr.losses.gan_loss import r1_penalty works for me.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: TencentARC/GFPGAN#208