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

[Refactor] refactor transformer modules #618

Merged
merged 24 commits into from
Dec 4, 2021

Conversation

cuhk-hbsun
Copy link
Collaborator

  1. Move transformer modules and layers to models/common
  2. Reimplement NRTR model

@codecov
Copy link

codecov bot commented Nov 25, 2021

Codecov Report

Merging #618 (93faa0d) into main (d3d5618) will increase coverage by 0.30%.
The diff coverage is 96.89%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #618      +/-   ##
==========================================
+ Coverage   84.92%   85.22%   +0.30%     
==========================================
  Files         143      145       +2     
  Lines        9810     9856      +46     
  Branches     1469     1482      +13     
==========================================
+ Hits         8331     8400      +69     
+ Misses       1150     1128      -22     
+ Partials      329      328       -1     
Flag Coverage Δ
unittests 85.22% <96.89%> (+0.30%) ⬆️

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

Impacted Files Coverage Δ
mmocr/models/textrecog/encoders/satrn_encoder.py 100.00% <ø> (ø)
mmocr/utils/ocr.py 75.34% <ø> (-0.36%) ⬇️
mmocr/apis/inference.py 71.32% <78.94%> (+0.73%) ⬆️
mmocr/models/textrecog/decoders/nrtr_decoder.py 97.18% <92.30%> (ø)
mmocr/models/common/layers/transformer_layers.py 96.87% <96.87%> (ø)
mmocr/models/common/modules/transformer_module.py 98.68% <98.68%> (ø)
...s/textrecog/backbones/nrtr_modality_transformer.py 100.00% <100.00%> (+74.07%) ⬆️
mmocr/models/textrecog/encoders/nrtr_encoder.py 100.00% <100.00%> (ø)
mmocr/models/textrecog/layers/satrn_layers.py 100.00% <100.00%> (ø)
mmocr/models/textdet/necks/fpnf.py 80.00% <0.00%> (-0.40%) ⬇️
... and 22 more

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 d3d5618...93faa0d. Read the comment docs.

mmocr/apis/inference.py Outdated Show resolved Hide resolved
Comment on lines 75 to 105
dataset_type = cfg.data[set_type].type
if dataset_type in ['OCRDataset', 'OCRSegDataset']:
if cfg.data[set_type].pipeline[1].type == 'MultiRotateAugOCR':
warnings.warn(warning_msg)
cfg.data[set_type].pipeline = [
cfg.data[set_type].pipeline[0],
*cfg.data[set_type].pipeline[1].transforms
]
elif dataset_type == 'ConcatDataset':
for dataset in cfg.data[set_type].datasets:
if dataset.pipeline[1].type == 'MultiRotateAugOCR':
warnings.warn(warning_msg)
dataset.pipeline = [
dataset.pipeline[0], *dataset.pipeline[1].transforms
]
elif dataset_type == 'UniformConcatDataset':
uniform_pipeline = cfg.data[set_type].pipeline
if uniform_pipeline is not None:
if uniform_pipeline[1].type == 'MultiRotateAugOCR':
warnings.warn(warning_msg)
cfg.data[set_type].pipeline = [
uniform_pipeline[0], *uniform_pipeline[1].transforms
]
for dataset in cfg.data[set_type].datasets:
if dataset.pipeline is not None:
if dataset.pipeline[1].type == 'MultiRotateAugOCR':
warnings.warn(warning_msg)
dataset.pipeline = [
dataset.pipeline[0],
*dataset.pipeline[1].transforms
]
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's okay but also a bit ugly. @Harold-lkk any refactor suggestion?

@cuhk-hbsun cuhk-hbsun merged commit 0a1787d into open-mmlab:main Dec 4, 2021
gaotongxiao pushed a commit to gaotongxiao/mmocr that referenced this pull request Jul 15, 2022
* base refactor

* update config

* modify implementation of nrtr

* add config file

* add mask

* add operation order

* fix contiguous bug

* update config

* fix pytest

* fix pytest

* update readme

* update readme and metafile

* update docstring

* fix norm cfg and dict size

* rm useless

* use mmocr builder instead

* update pytest

* update

* remove useless

* fix ckpt name

* fix path

* include all config file into pytest

* update inference

* Update test_recog_config.py
gaotongxiao pushed a commit to gaotongxiao/mmocr that referenced this pull request Jul 15, 2022
* base refactor

* update config

* modify implementation of nrtr

* add config file

* add mask

* add operation order

* fix contiguous bug

* update config

* fix pytest

* fix pytest

* update readme

* update readme and metafile

* update docstring

* fix norm cfg and dict size

* rm useless

* use mmocr builder instead

* update pytest

* update

* remove useless

* fix ckpt name

* fix path

* include all config file into pytest

* update inference

* Update test_recog_config.py
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.

2 participants