-
Notifications
You must be signed in to change notification settings - Fork 56
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
refactor inference #267
refactor inference #267
Conversation
"DecodeImage": transforms.DecodeImage, | ||
"NormalizeImage": transforms.NormalizeImage, | ||
"ToCHWImage": transforms.ToCHWImage, | ||
"GridResize": transforms.ResizeImage, |
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.
这个ResizeImage操作是保留长宽比的吗? 有设置keep_ratio选项,这对最终的文字检测识别预测结果影响挺大。建议默认是保留H W比,即对应mindocr/data/transforms中的ScalePadImage操作。
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.
另外, pp推理大部分情况默认也是 keep_ratio
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.
已修改
- 新增了ScalePadImage操作,和训练端对应起来,方便以后统一和同步,默认使用ScalePadImage
- 原始的ResizeImage新增keep_ratio参数,True等价于ScalePadImage,为False的时候就是不保留H/W比的Resize
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.
因训练模型没有使用ScalePadImage,所以这里GridResize映射为ScalePadImage导致精度略微降低
故GridResize先映射为ResizeImage(keep_ratio=False),后续等训练模型支持后再修改
- ResizeImage: | ||
- NormalizeImage: | ||
mean: imagenet | ||
std: imagenet |
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.
这个建议显示地把mean,std的值写出来,因为paddle有些yaml里std没用imagenet的std,而且默认imagnet的mean, std是RGB顺序,而这里的img mode是BGR (而paddle忽略了这一点,训练时将错就错了)
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.
TODO: 后续考虑如何及时与mindocr目录的代码同步。
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.
后处理代码:后续在mindocr目录的后处理代码中,补齐一些(例如映射回原始shape)操作后,应该就可以共用了
预处理代码:这部分比较稍麻烦,比如Resize的image_shape,在训练端是从__init__传入,但是推理端需要从__call__传入(因为每次Resize的shape可能不一样)
from ....infer import TextClassifier, TaskType | ||
|
||
|
||
class CLSPreNode(ModuleBase): |
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.
CLSPreNode
命名方式跟 别的地方ClsPostprocess
不一致,建议改成ClsPreNode
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.
py_infer/src/
下有infer_args.py
和args/
,是否将py_infer/src/args/
改为py_infer/src/configs/
更为清晰
已修改 |
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.
Looks better!
TODO: improve resize for test images with different shape
Thank you for your contribution to the MindOCR repo.
Before submitting this PR, please make sure:
Motivation
det_model_name/det_config_path、 cls_model_name/cls_config_path、 rec_model_name/rec_config_path
其中model_name会关联一个config_path,用户设置其一即可自动获取yaml中的参数
Test Plan
(How should this PR be tested? Do you require special setup to run the test or repro the fixed bug?)
Related Issues and PRs
(Is this PR part of a group of changes? Link the other relevant PRs and Issues here. Use https://help.github.com/en/articles/closing-issues-using-keywords for help on GitHub syntax)