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

[models] ViT add checkpoints and some rework to use pretrained ViT backbone in ViTSTR #1072

Merged
merged 15 commits into from
Sep 26, 2022

Conversation

felixdittrich92
Copy link
Contributor

@felixdittrich92 felixdittrich92 commented Sep 21, 2022

This PR:

  • make pretrained checkpoints available for ViT (TF and PT)
  • rework patchify make it dynamic to the input shape
  • rework pretrained backbone usage for ViTSTR with checkpoints
  • fix issue with bicubic scale and onnxruntime (use bilinear : minor cost on quality and speed up)

All added checkpoints >98% acc

Any feedback is welcome

@felixdittrich92 felixdittrich92 added type: enhancement Improvement module: models Related to doctr.models framework: pytorch Related to PyTorch backend framework: tensorflow Related to TensorFlow backend topic: text recognition Related to the task of text recognition topic: character classification Related to the task of character classification labels Sep 21, 2022
@felixdittrich92 felixdittrich92 added this to the 0.6.0 milestone Sep 21, 2022
@felixdittrich92 felixdittrich92 self-assigned this Sep 21, 2022
@felixdittrich92
Copy link
Contributor Author

felixdittrich92 commented Sep 23, 2022

@frgfm but the good on is i have learned a lesson in this PR. If we build TF models each layer should have a name otherwise we are lost in space if we iter trough the weights to find the problem 😅

@felixdittrich92 felixdittrich92 changed the title [DRAF] [models] ViT add checkpoints and some rework to use pretrained ViT backbone in ViTSTR [models] ViT add checkpoints and some rework to use pretrained ViT backbone in ViTSTR Sep 23, 2022
@felixdittrich92 felixdittrich92 marked this pull request as ready for review September 23, 2022 13:15
@codecov
Copy link

codecov bot commented Sep 23, 2022

Codecov Report

Merging #1072 (7365d49) into main (e538cc2) will decrease coverage by 0.05%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #1072      +/-   ##
==========================================
- Coverage   95.26%   95.21%   -0.06%     
==========================================
  Files         145      142       -3     
  Lines        6046     6018      -28     
==========================================
- Hits         5760     5730      -30     
- Misses        286      288       +2     
Flag Coverage Δ
unittests 95.21% <100.00%> (-0.06%) ⬇️

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

Impacted Files Coverage Δ
doctr/models/recognition/vitstr/pytorch.py 97.46% <ø> (ø)
doctr/models/classification/vit/pytorch.py 100.00% <100.00%> (ø)
doctr/models/classification/vit/tensorflow.py 100.00% <100.00%> (ø)
doctr/models/modules/vision_transformer/pytorch.py 97.72% <100.00%> (-2.28%) ⬇️
...tr/models/modules/vision_transformer/tensorflow.py 97.72% <100.00%> (-2.28%) ⬇️
doctr/models/recognition/vitstr/tensorflow.py 97.56% <100.00%> (ø)
doctr/transforms/functional/base.py 95.65% <0.00%> (ø)
doctr/utils/__init__.py
... and 2 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Collaborator

@frgfm frgfm left a comment

Choose a reason for hiding this comment

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

Thanks Felix!
Perhaps we should specify the change in perf in the documentation or somewhere? It's gonna become hard to track those changes otherwise

@felixdittrich92
Copy link
Contributor Author

Yep will add
Patches: (H, W) -> (H / 8, W / 8)
to the docstrings

doctr/models/classification/vit/pytorch.py Outdated Show resolved Hide resolved
doctr/models/classification/vit/pytorch.py Outdated Show resolved Hide resolved
doctr/models/classification/vit/pytorch.py Show resolved Hide resolved
doctr/models/classification/vit/tensorflow.py Outdated Show resolved Hide resolved
doctr/models/classification/vit/tensorflow.py Outdated Show resolved Hide resolved
doctr/models/recognition/vitstr/tensorflow.py Show resolved Hide resolved
Copy link
Collaborator

@odulcy-mindee odulcy-mindee left a comment

Choose a reason for hiding this comment

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

LGTM ! 🚀

@felixdittrich92 felixdittrich92 merged commit 6b9f375 into mindee:main Sep 26, 2022
@felixdittrich92 felixdittrich92 deleted the vit-checkpoints branch September 26, 2022 08:06
@felixdittrich92 felixdittrich92 mentioned this pull request Sep 26, 2022
85 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
framework: pytorch Related to PyTorch backend framework: tensorflow Related to TensorFlow backend module: models Related to doctr.models topic: character classification Related to the task of character classification topic: text recognition Related to the task of text recognition type: enhancement Improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants