haofanwang / inswapper

One-click Face Swapper and Restoration powered by insightface 🔥

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ModuleNotFoundError: No module named 'basicsr.utils.realesrgan_utils'

xiaohuimc opened this issue · comments

How to solve the import error of "basicsr. utils. realsrgan_utils"

# import sys
# sys.path.append('./CodeFormer/CodeFormer')
import sys


sys.path.append("/root/autodl-tmp/workspace/inswapper/CodeFormer/CodeFormer")
from basicsr.utils.realesrgan_utils import RealESRGANer

import os
import cv2
import torch
import torch.nn.functional as F
from torchvision.transforms.functional import normalize

from basicsr.utils import imwrite, img2tensor, tensor2img
from basicsr.utils.download_util import load_file_from_url
from facelib.utils.face_restoration_helper import FaceRestoreHelper
from facelib.utils.misc import is_gray
from basicsr.archs.rrdbnet_arch import RRDBNet
# from basicsr.utils.realesrgan_utils import RealESRGANer
from basicsr.utils.registry import ARCH_REGISTRY
be **removed in 0.17**. Please don't rely on it. You probably just need to use APIs in torchvision.transforms.functional or in torchvision.transforms.v2.functional.
  warnings.warn(
Traceback (most recent call last):
  File "/root/autodl-tmp/workspace/inswapper/swapper.py", line 243, in <module>
    from restoration import *
  File "/root/autodl-tmp/workspace/inswapper/restoration.py", line 18, in <module>
    from basicsr.utils.realesrgan_utils import RealESRGANer
ModuleNotFoundError: No module named 'basicsr.utils.realesrgan_utils'

Same error here. Besides, it would be a plus if you could indicate which version of python is preferred for this project.

I just ran into this issue today. I resolved it by erasing my venv and re-doing the install steps in the README.md.

Well, I ran into this again, and tried to remove the venv folder, but I'm still getting the error.

In my case, it's a conflict between the parent and child projects. I'm integrating inswapper into Fooocus, and I had to run pip uninstall basicsr and then it seemed to work again.

I worked around this by copying the folders from the repo into the venv's libraries folder.

This is part of CodeFormer.
If you are getting this error, it means you didn't follow the instructions correctly to install CodeFormer.