Skip to content

add det+rec ckpt prediction pipeline #216

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

Merged
merged 1 commit into from
Apr 28, 2023
Merged

Conversation

HaoyangLee
Copy link
Collaborator

@HaoyangLee HaoyangLee commented Apr 25, 2023

add dbnet+crnn ckpt inference

add ckpt predict pytest

Thank you for your contribution to the MindOCR repo.
Before submitting this PR, please make sure:

Motivation

Add detection+recognition end2end ckpt prediction pipeline.

Test Plan

tests/st/test_predict.py will be added later.

Related Issues and PRs

Issue #238

@HaoyangLee HaoyangLee force-pushed the main branch 2 times, most recently from e7ca436 to f5f92db Compare April 26, 2023 15:44

```bash
cd tools/predict/text
python predict_system.py
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里应该要输入config参数?
另外,最好能支持输入待识别图像文件夹路径

Copy link
Collaborator Author

@HaoyangLee HaoyangLee Apr 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改。

  1. 对齐友商接口,现支持传入raw_data_dir,det_ckpt_path,rec_ckpt_path。
  2. config文件路径可由det_config_path和rec_config_path参数传入,args parser中有默认值。
  3. 目前待识别图像文件夹=检测后裁剪图片保存文件夹,可由crop_save_dir参数传入,args parser中有默认值。

add det+rec ckpt prediction pipeline

add det_rec ckpt prediction pipeline

add det+rec ckpt prediction pipeline

add det+rec ckpt prediction pipeline

add dbnet+crnn ckpt inference

add ckpt predict pytest

modify st

add predict_system doc

update predict_system

update doc
Copy link
Collaborator

@SamitHuang SamitHuang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

post process needs improvement in the future.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这一步后处理固定写的是4点的文字框。这块后续要考虑对弯曲文字的支持,即根据弯曲的多边形crop图后,padding得到长宽图。

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的

@HaoyangLee HaoyangLee merged commit 827c0a5 into mindspore-lab:main Apr 28, 2023
points = sorted(list(cv2.boxPoints(bounding_box)), key=lambda x: x[0])

# index_1, index_2, index_3, index_4 = 0, 1, 2, 3
if points[1][1] > points[0][1]:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a need for an explicit sorting? cv2.boxPoints() method returns an instance of RotatedRect::points, which in turn returns sorted coordinates is the order of: bottomLeft, topLeft, topRight, bottomRight.

np.roll(..., -1) sets the starting coordinate to topLeft.

__all__ = ['PredictDataset']


class PredictDataset(BaseDataset):
Copy link
Collaborator

@hadipash hadipash May 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like PredictDataset should be a part of DetDataset rather than a separate class. Can set a flag such as prediction to load images only. Perhaps, we can do the same for RecDataset.

@@ -148,3 +148,41 @@ eval:
batch_size: 1 # TODO: due to dynamic shape of polygons (num of boxes varies), BS has to be 1
drop_remainder: False
num_workers: 2

predict:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of the separate PredictDataset class, there is many duplicates in the config file. It's easy to make a mistake when there's a lot of repetitions.

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

Successfully merging this pull request may close these issues.

5 participants