haofanwang / inswapper

One-click Face Swapper and Restoration powered by insightface 🔥
486 stars 72 forks source link

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

Open xiaohuimc opened 11 months ago

xiaohuimc commented 11 months ago

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'
jytou commented 9 months ago

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

jndietz commented 8 months ago

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

jndietz commented 8 months ago

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.

machineminded commented 7 months ago

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

ashleykleynhans commented 7 months ago

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