mmocr icon indicating copy to clipboard operation
mmocr copied to clipboard

the same code but different results

Open dsp6414 opened this issue 2 years ago • 7 comments

MMOCR_Tutorial --toy datasets

The following code can be executed after the training code, but cannot be executed in a separate file (demo.py).

import mmcv import matplotlib.pyplot as plt

def show_img_from_path(img_path): img = mmcv.imread(img_path) img_RGB = mmcv.bgr2rgb(img) plt.imshow(img_RGB) plt.show()

def show_img_from_array(img): img_RGB = mmcv.bgr2rgb(img) plt.imshow(img_RGB) plt.show()

from mmocr.apis import init_detector, model_inference

checkpoint = "runs/tutorial_exps/latest.pth" from mmcv import Config cfg = Config.fromfile('myconfigs/sar_r31_parallel_decoder_toy_dataset.py') input_path = 'data/ocr_toy_dataset/imgs/1036169.jpg' model = init_detector(cfg, checkpoint, device="cuda:0") result = model_inference(model, input_path) out_img = model.show_result(input_path, result, out_file='outputs/demo-out.jpg', show=False) show_img_from_array(out_img)

the error: KeyError: 'MultiRotateAugOCR is not in the pipeline registry'

dsp6414 avatar Apr 24 '22 00:04 dsp6414

total error hints: File "/home/chen/OD/MMOCR_tutorials/mmocr_demo05.py", line 22, in result = model_inference(model, input_path) File "/home/chen/anaconda3/envs/pytorch/lib/python3.8/site-packages/mmocr/apis/inference.py", line 113, in model_inference test_pipeline = Compose(cfg.data.test.pipeline) File "/home/chen/.local/lib/python3.8/site-packages/mmdet-2.23.0-py3.8.egg/mmdet/datasets/pipelines/compose.py", line 23, in init transform = build_from_cfg(transform, PIPELINES) File "/home/chen/anaconda3/envs/pytorch/lib/python3.8/site-packages/mmcv/utils/registry.py", line 44, in build_from_cfg raise KeyError( KeyError: 'MultiRotateAugOCR is not in the pipeline registry'

dsp6414 avatar Apr 24 '22 01:04 dsp6414

pytorch's envs has installed several reposities including mmdet,mmcls,mmocr

dsp6414 avatar Apr 24 '22 01:04 dsp6414

Hi @dsp6414 Try the following code in the MMOCR home directory.

pip install -v -e .
export PYTHONPATH=$(pwd):$PYTHONPATH

Mountchicken avatar Apr 24 '22 01:04 Mountchicken

I tried it. It is still the same.

dsp6414 avatar Apr 24 '22 01:04 dsp6414

i debug The file. it only executed mmdet pipline Register not mmocr. it calls Compose In mmdet.

dsp6414 avatar Apr 24 '22 02:04 dsp6414

i found The problem. import mmocr.datasets.pipelines

it is ok. I think this is a little bug.

dsp6414 avatar Apr 24 '22 02:04 dsp6414

Thanks for the update! We will fix it in #887 .

gaotongxiao avatar Apr 24 '22 03:04 gaotongxiao