Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

运行报错 Name RealSRModel is not found, use name: RealSRModel_basicsr! ,怎么解决? #6

Open
wacdev opened this issue Apr 3, 2023 · 8 comments

Comments

@wacdev
Copy link

wacdev commented Apr 3, 2023

image

另外这3个模型有什么区别(我是程序员,想用这个超分辨率,不太懂算法)
BI-Efficient SR
BI-Classic SR
x4 High-order

@sunny2109
Copy link
Owner

sunny2109 commented Apr 3, 2023

您这边安装了BasicSR了吗?没有的话可以参考这个来装一下。编译通过再执行应该就不会报错了。

BI-Efficient SR表示使用Bicubic来对训练数据做退化,模型是轻量的,追求性能跟efficiency的平衡。
BI-Classical SR表示使用Bicubic来对训练数据做退化,模型的计算量通常是很大的,重在提升性能。
High-order表示训练数据的退化过程更复杂,更接近真实场景,可以用来处理现实中的低质图像。X4是指对输入进行四倍超分。

如果想用来处理实际场景中的图像,推荐使用SAFMN_L_Real_LSDIR。

@wacdev
Copy link
Author

wacdev commented Apr 3, 2023

image

您好,我安装了BasicSR之后还是一样的报错 出错信息如下
/Users/z/.local/share/rtx/installs/python/3.11.2/lib/python3.11/site-packages/torchvision/transforms/functional_tensor.py:5: UserWarning: The torchvision.transforms.functional_tensor module is deprecated in 0.15 and will 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(
Disable distributed.
Path already exists. Rename it to /Users/z/git/SAFMN/results/SAFMN_Real_x4_archived_20230403_180548
2023-04-03 18:05:48,394 INFO: 
                ____                _       _____  ____
               / __ ) ____ _ _____ (_)_____/ ___/ / __ \
              / __  |/ __ `// ___// // ___/\__ \ / /_/ /
             / /_/ // /_/ /(__  )/ // /__ ___/ // _, _/
            /_____/ \__,_//____//_/ \___//____//_/ |_|
     ______                   __   __                 __      __
    / ____/____   ____   ____/ /  / /   __  __ _____ / /__   / /
   / / __ / __ \ / __ \ / __  /  / /   / / / // ___// //_/  / /
  / /_/ // /_/ // /_/ // /_/ /  / /___/ /_/ // /__ / /<    /_/
  \____/ \____/ \____/ \____/  /_____/\____/ \___//_/|_|  (_)
    
Version Information: 
	BasicSR: 1.4.2
	PyTorch: 2.1.0.dev20230323
	TorchVision: 0.16.0.dev20230323
2023-04-03 18:05:48,394 INFO: 
  name: SAFMN_Real_x4
  model_type: RealSRModel
  scale: 4
  num_gpu: 1
  manual_seed: 0
  datasets:[
    test_1:[
      name: RealTest
      type: SingleImageDataset
      dataroot_lq: datasets/real_test
      filename_tmpl: {}
      io_backend:[
        type: disk
      ]
      phase: test
      scale: 4
    ]
  ]
  network_g:[
    type: SAFMN
    dim: 128
    n_blocks: 16
    ffn_scale: 2.0
    upscaling_factor: 4
  ]
  path:[
    pretrain_network_g: experiments/pretrained_model/SAFMN_L_Real_x4.pth
    strict_load_g: True
    results_root: /Users/z/git/SAFMN/results/SAFMN_Real_x4
    log: /Users/z/git/SAFMN/results/SAFMN_Real_x4
    visualization: /Users/z/git/SAFMN/results/SAFMN_Real_x4/visualization
  ]
  val:[
    save_img: True
    suffix: None
  ]
  dist: False
  rank: 0
  world_size: 1
  auto_resume: False
  is_train: False

2023-04-03 18:05:48,394 INFO: Dataset [SingleImageDataset] - RealTest is built.
2023-04-03 18:05:48,394 INFO: Number of test images in RealTest: 1
Name RealSRModel is not found, use name: RealSRModel_basicsr!
Traceback (most recent call last):
  File "/Users/z/git/SAFMN/basicsr/test.py", line 45, in <module>
    test_pipeline(root_path)
  File "/Users/z/git/SAFMN/basicsr/test.py", line 35, in test_pipeline
    model = build_model(opt)
            ^^^^^^^^^^^^^^^^
  File "/Users/z/.local/share/rtx/installs/python/3.11.2/lib/python3.11/site-packages/basicsr/models/__init__.py", line 26, in build_model
    model = MODEL_REGISTRY.get(opt['model_type'])(opt)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/z/.local/share/rtx/installs/python/3.11.2/lib/python3.11/site-packages/basicsr/utils/registry.py", line 71, in get
    raise KeyError(f"No object named '{name}' found in '{self._name}' registry!")
KeyError: "No object named 'RealSRModel' found in 'model' registry!"

@sunny2109
Copy link
Owner

sunny2109 commented Apr 3, 2023

您是重新用pip安装了吗?版本版本之间可能冲突了。
要不您把之前的都删了重新clone一下这个项目。下载完后先安装requirement.txt里的依赖包再setup一下应该就没问题了

cd SAFMN
pip install -r requirements.txt
python setup.py develop

@wacdev
Copy link
Author

wacdev commented Apr 3, 2023

我hack了一下basicsr的代码

print(MODEL_REGISTRY.keys())

我发现只有以下的模型,是不是可以选其中某个?

dict_keys(['SRModel', 'RealESRNetModel_basicsr', 'SRGANModel', 'HiFaceGANModel', 'VideoBaseModel', 'VideoRecurrentModel', 'ESRGANModel', 'VideoRecurrentGANModel', 'EDVRModel', 'RealESR
GANModel_basicsr', 'VideoGANModel', 'StyleGAN2Model', 'SwinIRModel'])

@wacdev
Copy link
Author

wacdev commented Apr 3, 2023

image

我看了一下basicsr代码,当前代码和历史提交里面也没找到RealSRModel关键词,如上图

@sunny2109
Copy link
Owner

噢噢噢,我知道了您安装的是最新的BasicSR,里面更新了一些东西。
这里的意思是您把刚才安装的BasicSR删了,重新下载我的这个repo,然后安装requirement.txt的依赖包并setup一下就好了。

@octopushugger
Copy link

octopushugger commented May 3, 2023

I still got this issue despite having setup a new environment and installing dependencies as instructed. Got past it though by installing BasicSR 1.3.3.11. Also had to make sure Visual Studio was installed on Windows for it to compile.

pip install basicsr==1.3.3.11

@octopushugger
Copy link

octopushugger commented May 3, 2023

1.3.4.1 appears to be the latest version that doesn't get this error.

pip install basicsr==1.3.4.1

Though I'm now getting a different error so for all I know installing this version could also be the problem there haha

Edit: HA, I just realized it errors BEFORE where it errors here so I guess going back to that version was a terrible idea.

Sorry for making these messages needlessly confusing to digest but I'm still getting the "No object named 'RealSRModel'" error.

Edit2: Okay, finally got it working. The trick was to not have BasicSR installed through any other method than the provided setup.py and make sure you're using Python 3.8. I accidentally first tried running this with Python 3.10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants