-
Notifications
You must be signed in to change notification settings - Fork 60
Add Seq2Seq Chinese model support #289
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
5cb632c
to
9120f86
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.
Looks good overall! Some improvements are needed before merge as mentioned in comments.
## 字典准备 | ||
|
||
为训练中、英文等不同语种的识别网络,用户需配置对应的字典。只有存在于字典中的字符会被模型正确预测。MindOCR现提供中、英两种字典,其中 | ||
- `英文字典`:包括大小写英文、数字和标点符号。存放于`mindocr/utils/dict/en_dict.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.
目前已训练的crnn英文识别模型(trained on MJ+ST) 所用的字典是默认的小写字母+数字,未用到这个字典?
若在自定义数据集上改用这个英文字典,其他超参如num_classes, use_space_char 也要说明如何调整。
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.
已修改为新的字典,num_classes, use_space_char 说明已更新。
- `英文字典`:包括大小写英文、数字和标点符号。存放于`mindocr/utils/dict/en_dict.txt` | ||
- `中文字典`:包括常用中文字符、大小写英文、数字和标点符号。存放于`mindocr/utils/dict/ch_dict.txt` | ||
|
||
目前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.
可否通过指定character_dict_path,并修改num_classes,来使用自定义字典 并 微调训练?
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.
已提供修改字典字符教学。
```yaml | ||
... | ||
common: | ||
character_dict_path: &character_dict_path mindocr/utils/dict/en_dict.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.
此处character_dict_path跟crnn_resnet34.yaml中的配置不一样,num_claases需同步调整,不然跑训练可能会出错。
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.
这个初始配置为crnn_resnet34_ch.yaml
,在PR #280 , num_claases
应该正确
@@ -53,7 +52,12 @@ def build_backbone(name, **kwargs): | |||
if 'pretrained' in kwargs: | |||
pretrained = kwargs['pretrained'] | |||
if not isinstance(pretrained, bool): | |||
load_model(backbone, pretrained) | |||
if remove_prefix: |
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.
可否用 load_model中已有的auto_mapping选项来自动映射?
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.
应该不行,auto_mapping会找最相近的matches,但如果想在backbone load minocr 模型的话需要把前缀backbone.去掉,差异会有9个字符
|
||
@register_backbone | ||
def rec_resnet34(pretrained: bool = True, **kwargs): | ||
model = RecResNet(in_channels=3, layers=34, **kwargs) | ||
|
||
# load pretrained weights | ||
if pretrained: | ||
if pretrained is True: | ||
raise NotImplementedError |
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.
建议给出更详细的报错信息,如 Pretrained checkpoint for rec_resnet34 does not exist.
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.
已更新
有两个问题
|
|
|
word_1657.png 你好 | ||
word_1814.png cathay | ||
``` | ||
*注意*:请将图片名和标签以 \tag 作为分隔,避免使用空格或其他分隔符。 |
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.
此处应为\tab
或\t
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.
已修改。
word_1657.png 你好 | ||
word_1814.png cathay | ||
``` | ||
*Note*: Please separate image names and labels using \tag, and avoid using spaces or other delimiters. |
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.
此处应为\tab
或\t
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.
已修改。
configs/rec/rare/README_CN.md
Outdated
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.
line19参考文献的引用应修改为:"#references" -> "#参考文献"
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.
已修改。
backbone: | ||
name: rec_resnet34 | ||
pretrained: https://download.mindspore.cn/toolkits/mindocr/rare/rare_resnet34-309dc63e.ckpt | ||
remove_prefix: 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.
此处建议添加remove_prefix
参数的注释,不然用户有点难理解
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.
docs/
下面tutorials/
和datasets/
中更新的文档是否需要在外部文档(如主页README,或RARE模型的REAMDE)给一个链接引过来?否则用户找不到这几个文档
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.
RARE模型的README已提供连接,等下CRNN 的PR也会指过去。
remove_prefix=True
to load pretrained model from MindOCRThank 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)