Skip to content

[Docs] How to use TextDetInferencer #2068

@zfxw

Description

@zfxw

Branch

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

📚 The doc issue

I trained a Textdet model with my own data, I can see a good detection result with following command
python tools/test.py ~/mmocr/work_dirs/dbnet_resnet18_fpnc_1200e_blfsh/dbnet_resnet18_fpnc_1200e_blfsh.py ~/mmocr/work_dirs/dbnet_resnet18_fpnc_1200e_blfsh/epoch_400.pth --show-dir imgs/.

But when I tried to use TextDetInferencer with following code

from mmocr.apis import TextDetInferencer

# Load models into memory
infer = TextDetInferencer(model='<Home>/mmocr/work_dirs/dbnet_resnet18_fpnc_1200e_blfsh/dbnet_resnet18_fpnc_1200e_blfsh.py', weights='<Home>/mmocr/work_dirs/dbnet_resnet18_fpnc_1200e_blfsh/epoch_400.pth', scope='mmocr')

# Perform inference
result = infer('<Home>/BLFSH_training_data/OpenMM_textbox_training_data/test/202402020_124623_cr02.png')
print(result)

All the bounding boxes are out of image bounds, and here is the error:

10/10 21:06:44 - 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.
/opt/conda/miniconda3/lib/python3.8/site-packages/mmengine/visualization/visualizer.py:196: UserWarning: Failed to add <class 'mmengine.visualization.vis_backend.LocalVisBackend'>, please provide the `save_dir` argument.
  warnings.warn(f'Failed to add {vis_backend.__class__}, '
/opt/conda/miniconda3/lib/python3.8/site-packages/mmengine/visualization/visualizer.py:831: UserWarning: Warning: The polygon is out of 
bounds, the drawn polygon may not be in the image

Why the polygon could be out of the bounds? Am I using TextDetInferencer properly?

I really appreciate if you can help. Thank you

Suggest a potential alternative/fix

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions