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

[PT / TF] Add TextNet - FAST backbone #1425

Merged
merged 12 commits into from
Jan 22, 2024

Conversation

felixdittrich92
Copy link
Contributor

@felixdittrich92 felixdittrich92 commented Jan 15, 2024

This PR:

Overview (tiny version)

"""
TORCH:

==============================================================
textnet     TextNet              (-1, 126)           0
├─0         Conv2d               (-1, 64, 16, 16)    1,728
├─1         BatchNorm2d          (-1, 64, 16, 16)    257
├─2         ReLU                 (-1, 64, 16, 16)    0
├─3         Sequential           (-1, 512, 1, 1)     0
|    └─0    Sequential           (-1, 64, 8, 8)      187,147
|    └─1    Sequential           (-1, 128, 4, 4)     505,868
|    └─2    Sequential           (-1, 256, 2, 2)     2,011,148
|    └─3    Sequential           (-1, 512, 1, 1)     8,019,980
├─4         Sequential           (-1, 126)           0
|    └─0    AdaptiveAvgPool2d    (-1, 512, 1, 1)     0
|    └─1    Flatten              (-1, 512)           0
|    └─2    Linear               (-1, 126)           64,638
==============================================================

Trainable params: 10,769,470
Non-trainable params: 0
Total params: 10,769,470
--------------------------------------------------------------
Model size (params + buffers): 41.18 Mb
Framework & CUDA overhead: 236.00 Mb
Total RAM usage: 277.18 Mb
--------------------------------------------------------------
Floating Point Operations on forward: 96.74 MFLOPs
Multiply-Accumulations on forward: 48.39 MMACs
Direct memory accesses on forward: 59.30 MDMAs



TF:
 Layer (type)                Output Shape              Param #
=================================================================
 conv2d (Conv2D)             (None, 16, 16, 64)        1728

 batch_normalization (Batch  (None, 16, 16, 64)        256
 Normalization)

 activation (Activation)     (None, 16, 16, 64)        0

 sequential (Sequential)     (None, 8, 8, 64)          187136

 sequential_1 (Sequential)   (None, 4, 4, 128)         505856

 sequential_2 (Sequential)   (None, 2, 2, 256)         2011136

 sequential_3 (Sequential)   (None, 1, 1, 512)         8019968

 sequential_4 (Sequential)   (None, 126)               64638

=================================================================
Total params: 10790718 (41.16 MB)
Trainable params: 10767678 (41.08 MB)
Non-trainable params: 23040 (90.00 KB)
_________________________________________________________________
None
"""

Any feedback is welcome 🤗

TODO:

  • provide checkpoints
  • check code again

@felixdittrich92 felixdittrich92 added this to the 0.8.0 milestone Jan 15, 2024
@felixdittrich92 felixdittrich92 added topic: documentation Improvements or additions to documentation module: models Related to doctr.models framework: pytorch Related to PyTorch backend framework: tensorflow Related to TensorFlow backend topic: text detection Related to the task of text detection type: new feature New feature labels Jan 15, 2024
@felixdittrich92
Copy link
Contributor Author

CC @nikokks

@felixdittrich92 felixdittrich92 marked this pull request as ready for review January 15, 2024 13:52
@felixdittrich92 felixdittrich92 changed the title [DRAFT] [PT / TF] Add TextNet - FAST backbone [PT / TF] Add TextNet - FAST backbone Jan 15, 2024
@felixdittrich92 felixdittrich92 self-assigned this Jan 15, 2024
Copy link

codecov bot commented Jan 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (ff9982b) 95.76% compared to head (82de763) 95.86%.
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1425      +/-   ##
==========================================
+ Coverage   95.76%   95.86%   +0.10%     
==========================================
  Files         155      161       +6     
  Lines        6941     7085     +144     
==========================================
+ Hits         6647     6792     +145     
+ Misses        294      293       -1     
Flag Coverage Δ
unittests 95.86% <100.00%> (+0.10%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@felixdittrich92
Copy link
Contributor Author

felixdittrich92 commented Jan 16, 2024

@odulcy-mindee Checkpoints are added if everything is fine feel free to upload that we can change the URLs :)

All models reached an Accuracy between 96-98%

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.

Wohohoho, thank you @felixdittrich92 ! 🚀

doctr/models/classification/textnet/tensorflow.py Outdated Show resolved Hide resolved
doctr/models/classification/textnet/pytorch.py Outdated 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.

Thank you @felixdittrich92, really great job here !

@felixdittrich92 felixdittrich92 merged commit a010972 into mindee:main Jan 22, 2024
66 of 67 checks passed
@felixdittrich92 felixdittrich92 deleted the textnet branch January 22, 2024 07:05
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: documentation Improvements or additions to documentation topic: text detection Related to the task of text detection type: new feature New feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants