[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 · Issue #2042 · open-mmlab/mmocr · GitHub
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[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
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.
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.
Activity
ozangungor12 commentedon May 2, 2024
I also realized that the problem does not happen when I first run the
mmocrand then themmdetmodules.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.