-
Notifications
You must be signed in to change notification settings - Fork 57
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
support cls predict module #769
Conversation
tools/infer/text/README.md
Outdated
@@ -238,6 +238,56 @@ Evaluation of the text spotting inference results on Ascend 910 with MindSpore 2 | |||
2. Unless extra inidication, all experiments are run with `--det_limit_type`="min" and `--det_limit_side`=720. | |||
3. SVTR is run in mixed precision mode (amp_level=O2) since it is optimized for O2. | |||
|
|||
## Text Direction Classification |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这块不用单独呈现,e2e的时候加上就行
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已调整代码结构,将cls模块作为一个可选功能(默认不启用)组件放在检测-识别e2e流程当中,不单独呈现,请检视
tools/infer/text/config.py
Outdated
"--save_cls_result", | ||
type=str2bool, | ||
default=True, | ||
help="whether to use cls model", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的表述,--save_cls_result应该不是whether to use cls model吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改
tools/infer/text/predict_system.py
Outdated
img_pred = f"{fn}_crop_{i}" + "\t" + cls_res[0] + "\n" | ||
lines.append(img_pred) | ||
|
||
with open(save_path, "w", encoding="utf-8") as f_cls: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里with open要指定mode是"a"。如果在推理多张图片的情况下,指定"w"的话,会导致结果只存在一张图片的信息。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已更正
tests/st/test_cls.py
Outdated
|
||
In the example above, image_dir can be either the file directory of images set or the address of a single image file | ||
|
||
Test image files address see: https://github.com/zhangjunlongtech/Material/tree/main/CLS/test_for_cls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个删掉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已删除
tools/infer/text/README.md
Outdated
python tools/infer/text/predict_system.py --image_dir {path_to_img or dir_to_imgs} \ | ||
--det_algorithm DB++ \ | ||
--rec_algorithm CRNN \ | ||
--use_cls True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
还是不太好,和上面的参数一样改成 --cls_algorithm M3 吧,默认是None,choise当前只有M3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改
Thank you for your contribution to the MindOCR repo.
Before submitting this PR, please make sure:
Motivation
Test Plan
1. Test the TextClassifier class separately
This PR provides a test script that separately tests the TextClassifier class. The test script runs tests based on the following process :
(Due to the directory reference structure, the test script cannot be run directly under the test directory)
In the example above, image_dir can be either the file directory of an image set or the address of a single image file
The target classification image is
The cls task output should looks like this
2. End-to-end testing
Run the following command for an end-to-end test:
The target image is
The e2e task output should looks like this
If --cls_algorithm is not configured, the cls process is not executed by default.
Under this condition, the non-positive image recognition accuracy is low:
3. e2e multi-graph online inference
e2e multi-graph online inference is tested, and the test file directory is as follows:
|-test_cls
|- example_img03_for_e2e.png
|- example_img04_for_e2e.png
The test command is as follows:
The test results are as follows, and the results are in line with expectations: