-
Notifications
You must be signed in to change notification settings - Fork 60
Add RobustScanner rec model #444
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
Conversation
1b4dabc
to
04c08ac
Compare
mindocr/data/rec_lmdb_dataset.py
Outdated
@@ -186,10 +186,18 @@ def __getitem__(self, idx): | |||
lmdb_idx, file_idx = self.data_idx_order_list[idx] | |||
sample_info = self.get_lmdb_sample_info(self.lmdb_sets[int(lmdb_idx)]["txn"], int(file_idx)) | |||
|
|||
if sample_info is None: |
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.
这两个修改要确保只能在训练集有效,验证集可能会因为这个导致精度误差。另外最好加上warning
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.
已修改,添加random_choice_if_none参数来进行判断
efe7829
to
ebe48bc
Compare
1b69be7
to
66c1e14
Compare
|
||
|
||
class SARLabelEncode(object): | ||
"""Convert between text-label and text-index""" |
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.
SARLabelEncode 跟 RecAttnLabelEncode 非常相似,可以考虑合并
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.
已查看,SARLabelEncode 和 RecAttnLabelEncode 对特殊情况的返回None的处理不同,使用的special_char不同,不建议合并
return padding_im, resize_shape, pad_shape, valid_ratio | ||
|
||
|
||
if __name__ == "__main__": |
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.
if __name__ == “__main__"
下面这段可以删除,如需要可以搬到unit test 里面
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/utils/dict/dict90.txt
Outdated
@@ -0,0 +1,90 @@ | |||
0 |
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/utils/dict/en_dict90.txt
,请确认下是不是同一个字典
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.
确认为相同字典,已删除
return [self.padding_idx] | ||
|
||
|
||
if __name__ == "__main__": |
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.
同样删除 if __name__ == '__main__
内容
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.
已删除
|
||
@register_backbone_class | ||
class RecResNet31(nn.Cell): | ||
''' |
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/models/backbones/rec_master.py
内已有resnet31,是否可以合并?
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.
已查看,网络结构基本一致,但细节上有细微区别,如maxpool2d参数、downsample、channel数量等,我会跑一次实验看精度是否会下降,如果不下降可以进行复用,但可能后续需要将resnet31提取为公共模块
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.
嗯如果可以复用可以把resnet31搬出来
|
||
|
||
class SARLoss(nn.Cell): | ||
def __init__(self, **kwargs): |
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.
SARLoss 和 AttentionLoss 非常相似,是否可以合并?
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.
两者使用的loss的计算均为CrossEntropyLoss,但模型输出的pred shape不同,处理方式不同,不建议合并
02f0be2
to
8a84075
Compare
533c3d7
to
4d7d45f
Compare
configs/rec/robustscanner/README.md
Outdated
</div> | ||
Note: SynthText and Syn90k datasets were both randomly sampled the complete SynthText dataset and complete Syn90k dataset, consisting of 2.4 million samples each. | ||
|
||
The training and evaluation datasets in LMDB format shown in the table above can be downloaded from [here](https://download.mindspore.cn/dataset/robustscanner_dataset/). The downloaded file contains several compressed files, including: |
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.
datasets uploaded to download server is a concern.
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.
Fixed, refer to AI Studio download url.
1d62cc6
to
9268235
Compare
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: 1. update model list and what's new in readme.
2. Add it to online inference.
Thank you for your contribution to the MindOCR repo.
Before submitting this PR, please make sure:
Motivation
(Write your motivation for proposed changes here.)
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)