Skip to content
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

[Model] Add MASTER #807

Merged
merged 39 commits into from
May 5, 2022
Merged

[Model] Add MASTER #807

merged 39 commits into from
May 5, 2022

Conversation

JiaquanYe
Copy link
Contributor

This PR is for adding text recognition algorithm 'MASTER' code in mmocr repository.

Motivation

Develop text recognition algorithm 'MASTER' with mmocr framework.

Modification

Implement MASTER components in mmocr framework
Implement MASTER train config in mmocr

Checklist

Before PR:

I have run pre-commit and get some Failed,it is necessary to fix this?
yapf.....................................................................Failed

  • hook id: yapf
  • files were modified by this hook

docformatter.............................................................Failed

  • hook id: docformatter
  • files were modified by this hook

And I do unit test, and get some error info, which is unrelated with MASTER code.
====================================================== short test summary info ======================================================
FAILED tests/test_apis/test_single_gpu_test.py::test_single_gpu_test_recog[../configs/textrecog/sar/sar_r31_parallel_decoder_academic .py]
FAILED tests/test_apis/test_single_gpu_test.py::test_single_gpu_test_recog[../configs/textrecog/crnn/crnn_academic_dataset.py] - R...
FAILED tests/test_apis/test_single_gpu_test.py::test_single_gpu_test_recog[../configs/textrecog/seg/seg_r31_1by16_fpnocr_academic.py]
FAILED tests/test_apis/test_single_gpu_test.py::test_single_gpu_test_det[../configs/textdet/psenet/psenet_r50_fpnf_600e_icdar2017.py]
FAILED tests/test_apis/test_single_gpu_test.py::test_single_gpu_test_kie[../configs/kie/sdmgr/sdmgr_unet16_60e_wildreceipt.py] - R...
FAILED tests/test_apis/test_single_gpu_test.py::test_single_gpu_test_kie_novisual[../configs/kie/sdmgr/sdmgr_novisual_60e_wildreceipt .py]

@gaotongxiao gaotongxiao changed the title Feature/iss 794 [Model] Add MASTER Mar 2, 2022
@codecov
Copy link

codecov bot commented Mar 2, 2022

Codecov Report

Merging #807 (e0bfdf2) into main (fbc138d) will decrease coverage by 0.02%.
The diff coverage is 82.16%.

❗ Current head e0bfdf2 differs from pull request most recent head 8f19d14. Consider uploading reports for the commit 8f19d14 to get more accurate results

@@            Coverage Diff             @@
##             main     #807      +/-   ##
==========================================
- Coverage   83.77%   83.74%   -0.03%     
==========================================
  Files         168      170       +2     
  Lines       11202    11359     +157     
  Branches     1724     1743      +19     
==========================================
+ Hits         9384     9513     +129     
- Misses       1449     1468      +19     
- Partials      369      378       +9     
Flag Coverage Δ
unittests 83.74% <82.16%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
mmocr/utils/ocr.py 77.36% <ø> (ø)
mmocr/models/textrecog/plugins/common.py 67.14% <62.29%> (-32.86%) ⬇️
mmocr/models/textrecog/decoders/master_decoder.py 94.56% <94.56%> (ø)
mmocr/models/textrecog/recognizer/master.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 137713f...8f19d14. Read the comment docs.

@Mountchicken
Copy link
Collaborator

Hi JiaquanYe!
Thank you for your great contribution👍. Sorry for the late reply, we will review your PR in the following days.

mmocr/models/textrecog/backbones/resnet_master.py Outdated Show resolved Hide resolved
mmocr/models/textrecog/convertors/master.py Outdated Show resolved Hide resolved
mmocr/models/textrecog/decoders/master_decoder.py Outdated Show resolved Hide resolved
mmocr/models/textrecog/encoders/positional_encoder.py Outdated Show resolved Hide resolved
mmocr/models/textrecog/layers/context_block.py Outdated Show resolved Hide resolved
configs/_base_/recog_models/master.py Outdated Show resolved Hide resolved
mmocr/models/textrecog/encoders/positional_encoder.py Outdated Show resolved Hide resolved
mmocr/models/textrecog/decoders/master_decoder.py Outdated Show resolved Hide resolved
mmocr/models/textrecog/recognizer/master.py Outdated Show resolved Hide resolved
mmocr/models/textrecog/recognizer/master.py Outdated Show resolved Hide resolved
@gaotongxiao
Copy link
Collaborator

Hi @JiaquanYe , do you still have time to refactor the code? If not, it's totally fine and we can help you with the rest of the process.

@JiaquanYe
Copy link
Contributor Author

JiaquanYe commented Apr 2, 2022 via email

@gaotongxiao
Copy link
Collaborator

@JiaquanYe Awesome!

@gaotongxiao
Copy link
Collaborator

BTW, please install pre-commit hooks and follow the guide to pass the lint test. They help you format your code :) Remember if you have run into an error saying 'gem' is not found, just install Ruby 2.7 as said in the guide.

@JiaquanYe JiaquanYe reopened this Apr 22, 2022
@JiaquanYe
Copy link
Contributor Author

@JiaquanYe The training process is still continuing and so far it looks like it is possible to reproduce the accuracy of the original paper, so I'll help you do the rest of the work. Thank you for your contribution!❤.

OK. Thanks for your help during this time! @Mountchicken @gaotongxiao

@JiaquanYe
Copy link
Contributor Author

I accidentally click the close PR button, now I reopen now...

Copy link
Collaborator

@gaotongxiao gaotongxiao left a comment

Choose a reason for hiding this comment

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

Things remain to be done except for the comments:

  • Model's readme
  • Model's metafile
  • Checkpoint & log
  • Repo's Readme (zh & cn)
  • Tests for decoder

@Mountchicken @xinke-wang We can wrap up this PR together in the following days.

configs/_base_/schedules/schedule_adadelta_5e.py Outdated Show resolved Hide resolved
configs/_base_/schedules/schedule_adam_step_5e.py Outdated Show resolved Hide resolved
configs/_base_/schedules/schedule_adam_step_6e.py Outdated Show resolved Hide resolved
configs/textrecog/master/master_academic.py Outdated Show resolved Hide resolved
mmocr/models/common/modules/transformer_module.py Outdated Show resolved Hide resolved
mmocr/models/textrecog/plugins/common.py Outdated Show resolved Hide resolved
mmocr/models/textrecog/plugins/common.py Show resolved Hide resolved
tests/data/ocr_toy_dataset/debug_label.txt Outdated Show resolved Hide resolved
mmocr/models/textrecog/layers/context_block.py Outdated Show resolved Hide resolved
mmocr/models/textrecog/losses/ce_loss.py Outdated Show resolved Hide resolved
@gaotongxiao
Copy link
Collaborator

Hi @JiaquanYe , one more question: Does this implementation uses any code from any other open-source project? If so, please let us know so that we can cite them as well :)

@JiaquanYe
Copy link
Contributor Author

Hi @JiaquanYe , one more question: Does this implementation uses any code from any other open-source project? If so, please let us know so that we can cite them as well :)

I have refered to this two repositories MASTER-pytorch , MASTER-TF when I develop MASTER-mmocr. I think you can cite these two repositories.

@gaotongxiao
Copy link
Collaborator

@JiaquanYe OKay!

mmocr/utils/ocr.py Outdated Show resolved Hide resolved
@xinke-wang
Copy link
Collaborator

Need to add MASTER to the docs/en/model_summary.md

@Mountchicken
Copy link
Collaborator

Need to add MASTER to the docs/en/model_summary.md

Done.

@gaotongxiao gaotongxiao merged commit 061d353 into open-mmlab:main May 5, 2022
gaotongxiao added a commit to gaotongxiao/mmocr that referenced this pull request Jul 15, 2022
* fix open-mmlab#794: add MASTER

* fix conflict add MASTER

* fix conflict add MASTER

* fix conflict add MASTER

* fix conflict add MASTER

* fix conflict add MASTER

* fix conflict add MASTER

* fix conflict add MASTER

* Fix linting

* after git rebase main

* after git rebase main

* fix conflict add MASTER

* fix conflict add MASTER

* after git rebase main

* fix conflict add MASTER

* fix conflict add MASTER

* fix conflict add MASTER

* after git rebase main

* add GCAModule to plugins

* coexist master and master_old

* fix merge mmocr 0.5.0 conflict

* fix lint error

* update

* [fix] remove remains in __init__

* [update] update code in review

* update readme for master

* Add docstr to MasterDecoder, refined MasterDecoder, remove MASTERLoss

* Unify the output length of MasterDecoder in train and test mode; add test for it, remove MasterLoss

* update readme

* update

* update metafile,README,demo/README,config,ocr.py

* Update mmocr/utils/ocr.py

* update

Co-authored-by: gaotongxiao <gaotongxiao@gmail.com>
Co-authored-by: Mountchicken <mountchicken@outlook.com>
gaotongxiao added a commit to gaotongxiao/mmocr that referenced this pull request Jul 15, 2022
* fix open-mmlab#794: add MASTER

* fix conflict add MASTER

* fix conflict add MASTER

* fix conflict add MASTER

* fix conflict add MASTER

* fix conflict add MASTER

* fix conflict add MASTER

* fix conflict add MASTER

* Fix linting

* after git rebase main

* after git rebase main

* fix conflict add MASTER

* fix conflict add MASTER

* after git rebase main

* fix conflict add MASTER

* fix conflict add MASTER

* fix conflict add MASTER

* after git rebase main

* add GCAModule to plugins

* coexist master and master_old

* fix merge mmocr 0.5.0 conflict

* fix lint error

* update

* [fix] remove remains in __init__

* [update] update code in review

* update readme for master

* Add docstr to MasterDecoder, refined MasterDecoder, remove MASTERLoss

* Unify the output length of MasterDecoder in train and test mode; add test for it, remove MasterLoss

* update readme

* update

* update metafile,README,demo/README,config,ocr.py

* Update mmocr/utils/ocr.py

* update

Co-authored-by: gaotongxiao <gaotongxiao@gmail.com>
Co-authored-by: Mountchicken <mountchicken@outlook.com>
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.

None yet

4 participants