在安装 GFPGAN 的时候,一切都顺利,但是执行的时候出现了错误,哦还有一个问题,
问题一
就是如果basicsr安装不成功可以执行如下命令
pip install -i https://mirrors.aliyun.com/pypi/simple tb-nightly
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple basicsr==1.4.2
转载无法安装basicsr的解决方法_basicsr安装失败-CSDN博客
问题二
回归上面的问题,如果执行出现了如下错误
Traceback (most recent call last):File "F:\work\code\python\GFPGAN-master\inference_gfpgan.py", line 9, in <module>from gfpgan import GFPGANerFile "F:\work\code\python\GFPGAN-master\gfpgan\__init__.py", line 2, in <module>from .archs import *File "F:\work\code\python\GFPGAN-master\gfpgan\archs\__init__.py", line 10, in <module>_arch_modules = [importlib.import_module(f'gfpgan.archs.{file_name}') for file_name in arch_filenames]File "F:\work\code\python\GFPGAN-master\gfpgan\archs\__init__.py", line 10, in <listcomp>_arch_modules = [importlib.import_module(f'gfpgan.archs.{file_name}') for file_name in arch_filenames]File "D:\ProgramData\anaconda3\envs\insightface\lib\importlib\__init__.py", line 126, in import_modulereturn _bootstrap._gcd_import(name[level:], package, level)File "F:\work\code\python\GFPGAN-master\gfpgan\archs\arcface_arch.py", line 172, in <module>class ResNetArcFace(nn.Module):File "D:\ProgramData\anaconda3\envs\insightface\lib\site-packages\basicsr\utils\registry.py", line 56, in decoself._do_register(name, func_or_class, suffix)File "D:\ProgramData\anaconda3\envs\insightface\lib\site-packages\basicsr\utils\registry.py", line 42, in _do_registerassert (name not in self._obj_map), (f"An object named '{name}' was already registered "
AssertionError: An object named 'ResNetArcFace' was already registered in 'arch' registry!
问题原因
发现是由于ResNetArcFace已经被注册,搜索了下,发下我安装的另外一个库已经包含了
问题解决方案
那咋办了
方法一
一个是重新开个环境,通过conda创建一个虚拟环境,排除环境依赖,也就不存在重复使用问题
conda create --name xxx python=3.11
方法二
一个是修改源码
ResNetArc2Face
如下替换掉
然后源代码重新安装,执行解决此问题
python setup.py develop