Skip to content

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

Merged
merged 1 commit into from
Jul 6, 2023
Merged

Conversation

tonytonglt
Copy link
Contributor

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)

@tonytonglt tonytonglt force-pushed the main branch 4 times, most recently from 1b4dabc to 04c08ac Compare June 26, 2023 07:44
@@ -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:
Copy link
Collaborator

Choose a reason for hiding this comment

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

这两个修改要确保只能在训练集有效,验证集可能会因为这个导致精度误差。另外最好加上warning

Copy link
Contributor Author

@tonytonglt tonytonglt Jun 30, 2023

Choose a reason for hiding this comment

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

已修改,添加random_choice_if_none参数来进行判断

@tonytonglt tonytonglt force-pushed the main branch 16 times, most recently from efe7829 to ebe48bc Compare June 30, 2023 03:04
@tonytonglt tonytonglt force-pushed the main branch 6 times, most recently from 1b69be7 to 66c1e14 Compare July 3, 2023 12:39


class SARLabelEncode(object):
"""Convert between text-label and text-index"""
Copy link
Collaborator

Choose a reason for hiding this comment

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

SARLabelEncode 跟 RecAttnLabelEncode 非常相似,可以考虑合并

Copy link
Contributor Author

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__":
Copy link
Collaborator

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 里面

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已删除

@@ -0,0 +1,90 @@
0
Copy link
Collaborator

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,请确认下是不是同一个字典

Copy link
Contributor Author

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__":
Copy link
Collaborator

Choose a reason for hiding this comment

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

同样删除 if __name__ == '__main__ 内容

Copy link
Contributor Author

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):
'''
Copy link
Collaborator

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,是否可以合并?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已查看,网络结构基本一致,但细节上有细微区别,如maxpool2d参数、downsample、channel数量等,我会跑一次实验看精度是否会下降,如果不下降可以进行复用,但可能后续需要将resnet31提取为公共模块

Copy link
Collaborator

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):
Copy link
Collaborator

Choose a reason for hiding this comment

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

SARLoss 和 AttentionLoss 非常相似,是否可以合并?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

两者使用的loss的计算均为CrossEntropyLoss,但模型输出的pred shape不同,处理方式不同,不建议合并

@tonytonglt tonytonglt force-pushed the main branch 2 times, most recently from 02f0be2 to 8a84075 Compare July 4, 2023 06:21
@tonytonglt tonytonglt requested a review from HaoyangLee July 4, 2023 07:23
@tonytonglt tonytonglt force-pushed the main branch 3 times, most recently from 533c3d7 to 4d7d45f Compare July 5, 2023 01:43
</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:
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

@tonytonglt tonytonglt force-pushed the main branch 3 times, most recently from 1d62cc6 to 9268235 Compare July 5, 2023 03:36
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.

TODO: 1. update model list and what's new in readme.
2. Add it to online inference.

@SamitHuang SamitHuang merged commit b8092f2 into mindspore-lab:main Jul 6, 2023
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