XiangZ-0 / HiT-SR

[ECCV 2024 - Oral] HiT-SR: Hierarchical Transformer for Efficient Image Super-Resolution
Apache License 2.0
82 stars 2 forks source link

KeyError: "No object named 'HITModel' found in 'model' registry!" #2

Closed AIisCool closed 2 months ago

AIisCool commented 2 months ago
python basicsr/test.py -opt options/Test/test_single_x4.yml
Disable distributed.
Path already exists. Rename it to C:\HiT-SR\results\test_single_x4_archived_20240912_035244
2024-09-12 03:52:44,898 INFO:
  name: test_single_x4
  model_type: HITModel
  scale: 4
  num_gpu: 1
  manual_seed: 1226
  datasets:[
    test_1:[
      name: Single
      type: SingleImageDataset
      dataroot_lq: datasets/single
      io_backend:[
        type: disk
      ]
      phase: test
      scale: 4
    ]
  ]
  network_g:[
    type: HiT_SRF
    upscale: 4
    in_chans: 3
    img_size: 64
    base_win_size: [8, 8]
    img_range: 1.0
    depths: [6, 6, 6, 6]
    embed_dim: 60
    num_heads: [6, 6, 6, 6]
    expansion_factor: 2
    resi_connection: 1conv
    hier_win_ratios: [0.5, 1, 2, 4, 6, 8]
    upsampler: pixelshuffledirect
  ]
  path:[
    pretrain_network_g: experiments/pretrained_models/HiT-SRF-4x.pth
    strict_load_g: True
    results_root: C:\HiT-SR\results\test_single_x4
    log: C:\HiT-SR\results\test_single_x4
    visualization: C:\HiT-SR\results\test_single_x4\visualization
  ]
  val:[
    save_img: True
    suffix: x4
    use_chop: False
  ]
  dist: False
  rank: 0
  world_size: 1
  auto_resume: False
  is_train: False

2024-09-12 03:52:44,898 INFO: Dataset [SingleImageDataset] - Single is built.
2024-09-12 03:52:44,898 INFO: Number of test images in Single: 2
Name HITModel is not found, use name: HITModel_basicsr!
Traceback (most recent call last):
  File "C:\HiT-SR\basicsr\test.py", line 44, in <module>
    test_pipeline(root_path)
  File "C:\HiT-SR\basicsr\test.py", line 34, in test_pipeline
    model = build_model(opt)
            ^^^^^^^^^^^^^^^^
  File "C:\Program Files\Python311\Lib\site-packages\basicsr\models\__init__.py", line 26, in build_model
    model = MODEL_REGISTRY.get(opt['model_type'])(opt)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Python311\Lib\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 'HITModel' found in 'model' registry!"
XiangZ-0 commented 2 months ago

Hi, sorry for the late reply. Could you check if the file HiT-SR/basicsr/models/hit_model.py exists in your repo? If so, please try to run python setup.py develop again and it should be able to find HITModel. Please let me know if that works. Thanks.

AIisCool commented 2 months ago

Thank you for the reply. Yes hit_model.py is in the correct location and I ran python setup.py develop again but I still get that error.

image

Edit:

Somehow managed to fix it but now get this error:

python basicsr/test.py -opt options/Test/test_single_x2.yml
Traceback (most recent call last):
  File "C:\HiT-SR\basicsr\test.py", line 5, in <module>
    from basicsr.data import build_dataloader, build_dataset
  File "C:\Program Files\Python311\Lib\site-packages\basicsr\__init__.py", line 3, in <module>
    from .archs import *
  File "C:\Program Files\Python311\Lib\site-packages\basicsr\archs\__init__.py", line 16, in <module>
    _arch_modules = [importlib.import_module(f'basicsr.archs.{file_name}') for file_name in arch_filenames]
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Python311\Lib\site-packages\basicsr\archs\__init__.py", line 16, in <listcomp>
    _arch_modules = [importlib.import_module(f'basicsr.archs.{file_name}') for file_name in arch_filenames]
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Python311\Lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Python311\Lib\site-packages\basicsr\archs\basicvsrpp_arch.py", line 8, in <module>
    from basicsr.archs.basicvsr_arch import ConvResidualBlocks
  File "C:\Program Files\Python311\Lib\site-packages\basicsr\archs\basicvsr_arch.py", line 7, in <module>
    from .edvr_arch import PCDAlignment, TSAFusion
  File "C:\Program Files\Python311\Lib\site-packages\basicsr\archs\edvr_arch.py", line 6, in <module>
    from .arch_util import DCNv2Pack, ResidualBlockNoBN, make_layer
ImportError: cannot import name 'DCNv2Pack' from 'basicsr.archs.arch_util' (C:\Program Files\Python311\Lib\site-packages\basicsr\archs\arch_util.py)
XiangZ-0 commented 2 months ago

Wired. I just tried on my Windows computer and everything seems fine on my side 🤔 This error looks like something is wrong with the basicsr package. Could you create a new virtual environment and follow here to re-install everything? Thanks

AIisCool commented 2 months ago

Fixed it. Is this how the output should look using HiT-SRF?

test_2

test_2_x4

XiangZ-0 commented 2 months ago

Yes, this looks good 👍