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

[Bug] KeyError: 'LoadPanopticAnnotations is not in the mmocr::transform registry. Please check whether the value of LoadPanopticAnnotations is correct or it was registered as expected #2042

Open
2 tasks done
ozangungor12 opened this issue May 2, 2024 · 1 comment
Assignees

Comments

@ozangungor12
Copy link

ozangungor12 commented May 2, 2024

Prerequisite

Task

I have modified the scripts/configs, or I'm working on my own tasks/models/datasets.

Branch

main branch https://github.com/open-mmlab/mmocr

Environment

sys.platform: linux
Python: 3.11.7 (main, Dec 8 2023, 18:56:58) [GCC 11.4.0]
CUDA available: True
numpy_random_seed: 2147483648
GPU 0,1,2: NVIDIA RTX A6000
CUDA_HOME: /usr/local/cuda
NVCC: Cuda compilation tools, release 11.8, V11.8.89
GCC: x86_64-linux-gnu-gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
PyTorch: 2.1.2+cu118
PyTorch compiling details: PyTorch built with:

  • GCC 9.3
  • C++ Version: 201703
  • Intel(R) oneAPI Math Kernel Library Version 2022.2-Product Build 20220804 for Intel(R) 64 architecture applications
  • Intel(R) MKL-DNN v3.1.1 (Git Hash 64f6bcbcbab628e96f33a62c3e975f8535a7bde4)
  • OpenMP 201511 (a.k.a. OpenMP 4.5)
  • LAPACK is enabled (usually provided by MKL)
  • NNPACK is enabled
  • CPU capability usage: AVX2
  • CUDA Runtime 11.8

TorchVision: 0.16.2+cu118
OpenCV: 4.8.0
MMEngine: 0.10.2
MMOCR: 1.0.1+2caab0a

mmcv 2.1.0
mmdet 3.3.0
mmengine 0.10.2
mmocr 1.0.1

Reproduces the problem - code sample

from mmdet.apis import init_detector, inference_detector
from mmocr.apis import MMOCRInferencer


model = init_detector(
          self._config_file,
          checkpoint=self._checkpoint_file, 
          device=self._device
)

result = inference_detector(self._model, input)
 
self._ocr = MMOCRInferencer(
      det='PANet_CTW', 
      det_weights="weights/mmocr/panet_resnet18_fpem-ffm_600e_ctw1500_20220826_144818-980f32d0.pth", 
      rec='NRTR',
      rec_weights="weights/mmocr/nrtr_resnet31-1by8-1by4_6e_st_mj_20220916_103322-a6a2a123.pth",
      device=device_id,
  )

Reproduces the problem - command or script

git clone https://github.com/open-mmlab/mmocr.git
cd mmocr
pip install -v -e .

Reproduces the problem - error message

File "/usr/local/lib/python3.11/dist-packages/mmdet/apis/inference.py", line 159, in inference_detector
    test_pipeline = Compose(test_pipeline)
                    ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/mmcv/transforms/wrappers.py", line 66, in __init__
    transform = TRANSFORMS.build(transform)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/mmengine/registry/registry.py", line 570, in build
    return self.build_func(cfg, *args, **kwargs, registry=self)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/mmengine/registry/build_functions.py", line 100, in build_from_cfg
    raise KeyError(
KeyError: 'LoadPanopticAnnotations is not in the mmocr::transform registry. Please check whether the value of `LoadPanopticAnnotations` is correct or it was registered as expected. More details can be found at https://mmengine.readthedocs.io/en/latest/advanced_tutorials/config.html#import-the-custom-module'

Additional information

My application consists of two steps, detecting an object with Panoptic Segmentation and applying OCR on the detected region.

When I try to use mmdet with mmocr, I get the error above. If I only use mmdet or mmocr, I don't have the error anymore. So if I only run the Panoptic Segmentation or if I run OCR on the full image without the detection step, I don't have any errors. But when I try to run them both in my script, I get the following error. Here are the versions I have in my docker image.

mmcv 2.1.0
mmdet 3.3.0
mmengine 0.10.2
mmocr 1.0.1

@ozangungor12
Copy link
Author

I also realized that the problem does not happen when I first run the mmocr and then the mmdet modules.

Also, there's a warning message displayed after I run the script above.

05/02 15:18:59 - mmengine - WARNING - Failed to search registry with scope "mmocr" in the "function" registry tree. As a workaround, the current "function" registry in "mmengine" is used to build instance. This may cause unexpected failure when running the built modules. Please check whether "mmocr" is a correct scope, or whether the registry is initialized.

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

2 participants