Releases: mindee/doctr
v1.0.0
Note: docTR 1.0.0 requires python >= 3.10
What's Changed
Breaking Change
TensorFlow has been removed as a supported backend. docTR now comes with PyTorch as the default and only deep learning backend.
The installation options torch and tf have been removed. You can now install docTR simply with:
pip install python-doctrThis will install docTR with PyTorch support by default.
Training script filenames have been updated to remove backend-specific extensions. For example:
recognition/train_pytorch.py → recognition/train.py
New features
- A new crnn_vgg16_bn checkpoint was added
What's Changed
Breaking Changes 🛠
Bug Fixes
- [bug] Fix viptr onnx export issue by @felixT2K in #1966
- [Fix] Correct condition for image dilation in orientation estimation by @Razlaw in #1971
Improvements
- [models] New crnn_vgg16_bn checkpoint by @felixdittrich92 in #1969
- [CI] Add windows to build ci jobs by @felixdittrich92 in #1981
Miscellaneous
- [misc] post release v0.12.0 by @felixT2K in #1965
- [misc/quality] Adjust imports by @felixdittrich92 in #1984
- [misc] Rename reference scripts & corr CI job paths by @felixdittrich92 in #1985
New Contributors
- @Tanmay20030516 made their first contribution in #1980
Full Changelog: v0.12.0...v1.0.0
v0.12.0
Note: docTR 0.12.0 requires python >= 3.10
Note: docTR 0.12.0 requires either TensorFlow >= 2.15.0 or PyTorch >= 2.0.0
Warning
TensorFlow Backend Deprecation Notice
Using docTR with TensorFlow as a backend is deprecated and will be removed in the next major release (v1.0.0).
We recommend switching to the PyTorch backend, which is more actively maintained and supports the latest features and models.
Alternatively, you can use OnnxTR, which does not require TensorFlow or PyTorch.
This decision was made based on several considerations:
- Allows better focus on improving the core library
- Frees up resources to develop new features faster
- Enables more targeted optimizations with PyTorch
Warning
This release is the last minor release supporting TensorFlow as backend
What's changed
New features
- A new lightweight recognition model
viptr_tinywas added - New built-in dataset added - COCO-Text V2
- A new custom model loading interface
# NEW
model = vitstr_small(pretrained=False, pretrained_backbone=False)
model.from_pretrained("<PATH_TO>") # local path or url to .pt or .h5
# Instead of depending on the backend
reco_params = torch.load('<path_to_pt>', map_location="cpu")
reco_model.load_state_dict(reco_params)
# Or with TensorFlow
reco_model.load_weights(..)What's Changed
Breaking Changes 🛠
- [Feat] Simplify and unify model loading - from_pretrained by @felixdittrich92 in #1915
- [Build] Add TensorFlow deprecation warnings by @felixdittrich92 in #1948
New Features
- [datasets] COCO-Text V2 integration by @sarjil77 in #1888
- [references] Recognition - Allow built-in datasets usage by @sarjil77 in #1904
- [Feat] PyTorch - VIP backbone and VIPTR recognition module by @lkosh in #1912
Bug Fixes
- [Fix] Duplicated forward call in rec train scripts by @felixT2K in #1862
- [Fix] Fix invalid hOCR format & PDF/A compatiblity with the kie preditor by @felixdittrich92 in #1870
- [CI/CD] Fix conda dependency issue by @felixT2K in #1937
- [Fix] Fix merge of short strings by @Razlaw in #1947
- [bug] fix missing import by @felixT2K in #1958
- Fix: Update min_loss only on improved validation loss to ensure best … by @sneakybatman in #1961
Improvements
- [Docs] Fix typos by @jk4e in #1885
- added russian vocab by @Madhavi258 in #1902
- [FIXED] Add proper Hebrew Unicode chars vocab by @johnlockejrr in #1909
- [classification] Add PyTorch pretrained VIP checkpoints by @felixdittrich92 in #1920
- Use OpenCV instead of Shapely to compute area & length by @lachesis in #1922
- [datasets] feat: add croatian vocabulary by @cyanic-selkie in #1923
- [docs] Fix VIPTR docstring by @felixT2K in #1924
- Migrating training scripts to torchrun by @lkosh in #1933
- [datasets] Massively extend the pre-defined vocabs by @felixdittrich92 in #1928
- [datasets] Update indic & arabic & other vocabs by @felixdittrich92 in #1941
- [Fix] Improve merge for recognition of long words (#1936) by @Razlaw in #1939
- [docs] Add tools section by @felixdittrich92 in #1950
- Give instructions on how to enable GPU acceleration on apple silicon by @ulfaslak in #1955
- [models] Add viptr tiny checkpoint by @felixdittrich92 in #1963
Miscellaneous
- [misc] post release v0.11.0 & public docker cron job adjustment by @felixdittrich92 in #1860
- [misc] Avoid tf onnx test to fail the CI & mypy fixes by @felixdittrich92 in #1903
- [Docs] Fix typo in docstring by @jk4e in #1927
- [misc] Fix mypy & merge test by @felixT2K in #1945
- [docs] Add new community model (arabic) to docs by @felixT2K in #1956
- [models] Drop viptr base config by @felixT2K in #1962
- [misc] Increase minor version v0.12 by @felixT2K in #1964
New Contributors
- @jk4e made their first contribution in #1885
- @Madhavi258 made their first contribution in #1902
- @johnlockejrr made their first contribution in #1909
- @sebastianMindee made their first contribution in #1917
- @lkosh made their first contribution in #1912
- @lachesis made their first contribution in #1922
- @cyanic-selkie made their first contribution in #1923
- @ulfaslak made their first contribution in #1955
- @sneakybatman made their first contribution in #1961
Full Changelog: v0.11.0...v0.12.0
v0.11.0
Note: docTR 0.11.0 requires python >= 3.10
Note: docTR 0.11.0 requires either TensorFlow >= 2.15.0 or PyTorch >= 2.0.0
What's changed
New features
- Added
torch.compilesupport (PyTorch backend) - Improved model training logging
- Created a small labeling tool designed for docTR (early stage) --> doctr-labeler
Compile your model
Compiling your PyTorch models with torch.compile optimizes the model by converting it to a graph representation and applying backends that can improve performance.
This process can make inference faster and reduce memory overhead during execution.
Further information can be found in the PyTorch documentation
import torch
from doctr.models import (
ocr_predictor,
vitstr_small,
fast_base,
mobilenet_v3_small_crop_orientation,
mobilenet_v3_small_page_orientation,
crop_orientation_predictor,
page_orientation_predictor
)
# Compile the models
detection_model = torch.compile(
fast_base(pretrained=True).eval()
)
recognition_model = torch.compile(
vitstr_small(pretrained=True).eval()
)
crop_orientation_model = torch.compile(
mobilenet_v3_small_crop_orientation(pretrained=True).eval()
)
page_orientation_model = torch.compile(
mobilenet_v3_small_page_orientation(pretrained=True).eval()
)
predictor = models.ocr_predictor(
detection_model, recognition_model, assume_straight_pages=False
)
# NOTE: Only required for non-straight pages (`assume_straight_pages=False`) and non-disabled orientation classification
# Set the orientation predictors
predictor.crop_orientation_predictor = crop_orientation_predictor(crop_orientation_model)
predictor.page_orientation_predictor = page_orientation_predictor(page_orientation_model)
compiled_out = predictor(doc)What's Changed
New Features
- [Feat] Add torch.compile support by @felixdittrich92 in #1791
- feat: ✨ tqdm slack by @odulcy-mindee in #1837
- [docs] Add note about labeling tool to training section by @felixdittrich92 in #1839
- feat: ✨ ClearML training loss logging by @odulcy-mindee in #1844
Bug Fixes
- [Fix] documentation deploy CI/CD job by @felixdittrich92 in #1781
- [CI] Fix PR labeler job & Rollback doc deploy deps by @felixdittrich92 in #1786
- [build] Fix tensorflow build dep by @felixdittrich92 in #1807
- fix: 🐛 sanitize docker tag step by @odulcy-mindee in #1809
- [Bug] Fix vocabs and add corresponding test case by @felixdittrich92 in #1813
- [Bug] Replace mem leaking torch gaussian_blur in augmentations by @felixdittrich92 in #1822
- [Fix] Fix tqdm slack message write : monkeypatch by @felixdittrich92 in #1852
- [Fix] Fix loading targets in WILDRECEIPT init by @Razlaw in #1859
Improvements
- [TF] Change eager mode by @felixdittrich92 in #1763
- [models] Change Resize kwargs to args for each zoo predictor by @cmoscardi in #1765
- [Docs] Add community docs by @felixdittrich92 in #1766
- [CI/CD] update Dependabot by @felixdittrich92 in #1768
- adding pytorch DDP script of detection task by @sarjil77 in #1777
- docs: fix faulty code for prediction and recognition demos by @khanfarhan10 in #1800
- feat: ✨ specify
output_dirin reference scripts by @odulcy-mindee in #1820 - [references] Unify sched + optim config and add AdamW as option by @felixdittrich92 in #1825
- [misc] Update header year & clearer built-in datasets progress bar msg by @felixdittrich92 in #1831
- Adding Gujarati Language support by @sarjil77 in #1845
- [references] Update Logging by @felixdittrich92 in #1847
Miscellaneous
- [misc] post release modifications v0.10.0 by @felixdittrich92 in #1756
- Introducing docTR Guru on Gurubase.io by @kursataktas in #1760
- [tests/style] Fix tf test and formatting by @felixdittrich92 in #1762
- [build] Upgrade py 3.10 by @felixdittrich92 in #1770
- [misc] Change prefered backend from tf to torch by @felixdittrich92 in #1779
- bump: ⬆️ CUDA Version by @odulcy-mindee in #1769
- [CI/code quality] Add clear github runner caches job + mypy fixes by @felixdittrich92 in #1783
- ci(dependabot): remove frgfm from automatic reviewers by @frgfm in #1787
- [CI] public docker job - change commit tag to version by @felixdittrich92 in #1789
- [misc] Small DDP script adjustments by @felixT2K in #1793
- [misc] Replace in deprecation dropped httpx.AsyncClient app arg by @felixT2K in #1802
- [docs] Tiny documentation export page fix by @felixdittrich92 in #1824
- [CI/CD] Replace deprecated parts conda & publish by @felixdittrich92 in #1842
- [misc] Increase minor version to v0.11.0 by @felixdittrich92 in #1858
New Contributors
- @agarkovv made their first contribution in #1758
- @kursataktas made their first contribution in #1760
- @cmoscardi made their first contribution in #1765
- @sarjil77 made their first contribution in #1777
- @Razlaw made their first contribution in #1859
Full Changelog: v0.10.0...v0.11.0
v0.10.0
Note: docTR 0.10.0 requires python >= 3.9
Note: docTR 0.10.0 requires either TensorFlow >= 2.15.0 or PyTorch >= 2.0.0
What's Changed
Soft Breaking Changes (TensorFlow backend only) 🛠
- Changed the saving format from
/weightsto.weights.h5
NOTE: Please update your custom trained models and HuggingFace hub uploaded models, this will be the last release supporting manual loading from /weights.
New features
- Added numpy 2.0 support @felixdittrich92
- New and updated notebooks was added @felixdittrich92 --> notebooks
- Custom orientation model loading @felixdittrich92
- Additional functionality to control the pipeline when dealing with rotated documents @milosacimovic @felixdittrich92
- Bulit-in datasets can now be loaded directly for detection with
detection_task=Truecomparable to the existingrecognition_task=True@felixdittrich92
Disable page orientation classification
- If you deal with documents which contains only small rotations (~ -45 to 45 degrees), you can disable the page orientation classification to speed up the inference.
- This will only have an effect with
assume_straight_pages=Falseand/orstraighten_pages=Trueand/ordetect_orientation=True.
from doctr.models import ocr_predictor
model = ocr_predictor(pretrained=True, assume_straight_pages=False, disable_page_orientation=True)Disable crop orientation classification
- If you deal with documents which contains only horizontal text, you can disable the crop orientation classification to speed up the inference.
- This will only have an effect with
assume_straight_pages=Falseand/orstraighten_pages=True.
from doctr.models import ocr_predictor
model = ocr_predictor(pretrained=True, assume_straight_pages=False, disable_crop_orientation=True)Loading custom exported orientation classification models
You can now load your custom trained orientation models, the following snippet demonstrates how:
from doctr.io import DocumentFile
from doctr.models import ocr_predictor, mobilenet_v3_small_page_orientation, mobilenet_v3_small_crop_orientation
from doctr.models.classification.zoo import crop_orientation_predictor, page_orientation_predictor
custom_page_orientation_model = mobilenet_v3_small_page_orientation("<PATH_TO_CUSTOM_EXPORTED_ONNX_MODEL>")
custom_crop_orientation_model = mobilenet_v3_small_crop_orientation("<PATH_TO_CUSTOM_EXPORTED_ONNX_MODEL>"))
predictor = ocr_predictor(pretrained=True, assume_straight_pages=False, detect_orientation=True)
# Overwrite the default orientation models
predictor.crop_orientation_predictor = crop_orientation_predictor(custom_crop_orientation_model)
predictor.page_orientation_predictor = page_orientation_predictor(custom_page_orientation_model)What's Changed
Breaking Changes 🛠
- [TF] First changes on the road to Keras v3 by @felixdittrich92 in #1724
- [Build] update minor version & update torch to >= 2.0 by @felixdittrich92 in #1747
New Features
- Disable page and crop orientation by @milosacimovic in #1735
Bug Fixes
- [Bug] fix straighten pages by @felixdittrich92 in #1697
- [Fix] Remove image padding after rotation correction with
straighten_pages=Trueby @felixdittrich92 in #1731 - [datasets] Allow detection task for built-in datasets by @felixdittrich92 in #1717
- [Bug] Fix eval scripts + possible overflow in Resize by @felixdittrich92 in #1715
- [demo] Add missing viz dep for demo by @felixT2K in #1751
Improvements
- [Datasets] Add Vietnamese letters by @MinhChien9 in #1693
- feat: added ukrainian vocab by @holyCowMp3 in #1700
- [orientation] Enable usage of custom trained orientation models by @felixdittrich92 in #1708
- [demo] Automate doctr demo update via CI job by @felixdittrich92 in #1742
- [TF] Move model building & unify train scripts by @felixdittrich92 in #1744
- [demo/docs] Update notebook docs & minor demo update / fix by @felixT2K in #1755
- [Reconstitution] Improve reconstitution by @felixdittrich92 in #1750
Miscellaneous
- [misc] post release 0.9.1 by @felixT2K in #1689
- [build] NumPy 2.0 support by @felixdittrich92 in #1709
New Contributors
- @MinhChien9 made their first contribution in #1693
- @holyCowMp3 made their first contribution in #1700
- @milosacimovic made their first contribution in #1735
Full Changelog: v0.9.0...v0.10.0
v0.9.0
Note: docTR 0.9.0 requires python >= 3.9
Note: docTR 0.9.0 requires either TensorFlow >= 2.11.0 or PyTorch >= 1.12.0.
What's Changed
Soft Breaking Changes 🛠
- The default
detectionmodel changed fromdb_resnet50tofast_base.
NOTE: Can be reverted by passing the detection modelpredictor = ocr_predictor(det_arch="db_resnet50", pretrained=True) - The default value of
resolve_blockschanged fromTruetoFalse
NOTE: Can be reverted by passingresolve_blocks=Trueto theocr_predictor
New features
- Fast models got pretrained checkpoints by @odulcy-mindee @felixdittrich92
- Introducing a contributions module which replaces the obj detection and builds a place for more pipelines by @felixdittrich92
- Improved orientation detection by @felixdittrich92 @odulcy-mindee
- Improved and updated API template by @felixdittrich92
- Include
objectness_scorein results by @felixdittrich92 - Add word crop general orientation to output by @felixdittrich92
- Split library into parts (optional dependencies) by @felixdittrich92
- Add page orientation predictor by @felixdittrich92 @odulcy-mindee
- Add onnx inference doc by @felixdittrich92
✨ Installation ✨
We have splitted docTR into some optional parts to make it a bit more lightweight and to exclude parts which are not required for inference.
Optional parts are:
- visualization (to support
.show()) - html support (to support
.from_url(...)) - contribution module
# for TensorFlow without any optional dependencies
pip install "python-doctr[tf]"
# for PyTorch without any optional dependencies
pip install "python-doctr[torch]"
# Installs pytorch and all available optional parts
pip install "python-doctr[torch,viz,html,contib]"
✨ ONNX and OnnxTR ✨
We have build a standalone library to provide a super lightweight way to use existing docTR onnx exported models or your custom onces.
benefits:
- kown docTR interface (
ocr_predictor, etc.) - no
PyTorchorTensorFlowrequired - build on top ofonnxruntime - more lightweight package with faster inference latency and less required resources
- 8-Bit quantized models for faster inference on CPU
Give it a try and check it out: OnnxTR
docTR docs: ONNX / OnnxTR
What's Changed
Breaking Changes 🛠
- [models] Change default model to
fast_base- soft breaking change by @felixdittrich92 in #1588 - [misc] update README & fix mypy & change resolve blocks default by @felixT2K in #1686
New Features
- [prototype] object det replacement / init contrib modules by @felixdittrich92 in #1534
Bug Fixes
- [FIX] Fix mistake in FASTConvLayer and tf reparameterization by @felixdittrich92 in #1506
- [Fix] sar_resnet31 TF + PT by @felixdittrich92 in #1513
- [Fix] crop orientation KIE by @felixdittrich92 in #1548
- [Fix] allign orientation train script to current orientation model (counter clockwise instead of clockwise) & make OrientationPredictor dynamic by @felixdittrich92 in #1559
- [Fix / transforms] RandomHorizontalFlip & RandomCrop by @felixdittrich92 in #1572
- [FIX] parseq onnx export by @felixdittrich92 in #1585
- [Fix] close PIL images when loading images to tensor/numpy by @helpmefindaname in #1598
- [conda] Fix meta.yaml package function name by @felixdittrich92 in #1603
- [bug] remove TF multiprocessing workers by @felixdittrich92 in #1635
- [IO] Pdf File close after opening by @justinjosephmkj in #1624
- [bug] exclude scores if rot and eval straight by @felixdittrich92 in #1639
- Fixed assume_straight_pages for custom models by @Fabioomega in #1681
Improvements
- [docs] documentation for changing predictors batch sizes by @felixdittrich92 in #1514
- feat: ✨ torch fast_tiny checkpoint by @odulcy-mindee in #1518
- [models] Add benchmark fast_tiny and reparameterize by default by @felixdittrich92 in #1519
- feat: ✨ PT fast base checkpoint by @odulcy-mindee in #1526
- feat: ✨ PT fast small checkpoint by @odulcy-mindee in #1529
- [API] update api for multi file and pdf support by @felixdittrich92 in #1522
- [feature] Add word crop general orientation to output by @felixdittrich92 in #1546
- feat: ✨ torch
mobilenet_v3_small_orientationchkpt by @odulcy-mindee in #1557 - [metrics] speed up polygon iou (for --rotation) by keeping balanced memory footprint by @felixdittrich92 in #1561
- [orientation] augment angle while training by @felixdittrich92 in #1567
- [orientation] Part 1: Add page orientation predictor by @felixdittrich92 in #1566
- feat: ✨ torch mobilenet_v3_small_crop_orientation by @odulcy-mindee in #1571
- feat: ✨ improve mobilenet_v3_page_orientation checkpoint by @odulcy-mindee in #1573
- [transforms] Add RandomResize (like ZoomOut) by @felixdittrich92 in #1574
- [references] Update detection augmentations by @felixdittrich92 in #1577
- [TF] add fast models and benchmarks by @felixdittrich92 in #1583
- [transforms] small random resize improvement by @felixdittrich92 in #1584
- [docs] Add onnx inference doc by @felixdittrich92 in #1601
- feat: ✨ torch db_mobilenet_v3_large checkpoint by @odulcy-mindee in #1632
- [detection] move padding removal directly to detection by @felixdittrich92 in #1627
- feat: ✨ tf mobilenet_v3_small_page_orientation checkpoint by @odulcy-mindee in #1636
- [builder] Add objectness scores by @felixdittrich92 in #1625
- [orientation] page orientation improvements by @felixdittrich92 in #1553
- [Datasets] Add hindi & bangla vocabs by @felixT2K in #1687
Miscellaneous
- [misc] apply 0.8.1 post release modifications by @felixdittrich92 in #1498
- Replace unidecode with text-unidecode. by @jonatankawalek in #1509
- [misc] update dev deps by @felixdittrich92 in #1510
- [benchmark] fast base pytorch by @felixdittrich92 in #1523
- [benchmark] fast small benchmark by @felixdittrich92 in #1527
- [Misc] drop py 3.8 support by @felixdittrich92 in #1457
- [CI] update CI actions by @felixdittrich92 in #1558
- Exclude deps & split into optional parts by @felixdittrich92 in #1551
- [references] remove missed parts of old obj det by @felixdittrich92 in #1568
- [tests/onnx] Add onnx and model out check by @felixdittrich92 in #1569
- [Fix] Pin py3.11 for MacOS latest / update publish version checks by @felixdittrich92 in #1503
- [build] Finally to py 3.9 by @felixdittrich92 in #1647
New Contributors
- @jonatankawalek made their first contribution in #1509
- @helpmefindaname made their first contribution in #1598
- @justinjosephmkj made their first contribution in #1624
- @Fabioomega made their first contribution in #1681
Full Changelog: v0.8.1...v0.9.0
v0.8.1
Note: doctr 0.8.1 requires either TensorFlow >= 2.11.0 or PyTorch >= 1.12.0.
What's Changed
-
Fixed conda receipt and CI jobs for conda and pypi releases
-
Fixed some broken links
-
Pre-Release: FAST text detection model from FAST: Faster Arbitrarily-Shaped Text Detector with Minimalist Kernel Representation -> Checkpoints will be provided with the next release
v0.8.0
Note: doctr 0.8.0 requires either TensorFlow >= 2.11.0 or PyTorch >= 1.12.0.
What's Changed
Breaking Changes 🛠
db_resnet50_rotation(PyTorch) andlinknet_resnet18_rotation(TensorFlow) are removed (All models can handle rotated documents now).show(doc)changed to.show()
New features
- All models have pretrained checkpoints now by @odulcy-mindee
- All detection models was retrained on rotated samples by @odulcy-mindee
- Improved orientation detection for documents rotated between -90 and 90 degrees by @felixdittrich92
- Conda deployment job & receipt added by @frgfm
- Official docTR docker images are added by @odulcy-mindee => docker-images
- New benchmarks and documentation improvements by @felixdittrich92
WildReceiptdataset added by @HamzaGbada- EarlyStopping callback added to all training scripts by @SkaarFacee
- Hook mechanism added to
ocr_predictorto maniplulate the detection predictions in the middle of the pipeline to your needs by @felixdittrich92
from doctr.model import ocr_predictor
class CustomHook:
def __call__(self, loc_preds):
# Manipulate the location predictions here
# 1. The outpout structure needs to be the same as the input location predictions
# 2. Be aware that the coordinates are relative and needs to be between 0 and 1
return loc_preds
my_hook = CustomHook()
predictor = ocr_predictor(pretrained=True)
# Add a hook in the middle of the pipeline
predictor.add_hook(my_hook)
# You can also add multiple hooks which will be executed sequentially
for hook in [my_hook, my_hook, my_hook]:
predictor.add_hook(hook)What's Changed
Breaking Changes 🛠
- [prototype] compute orientation on segmentation map by @felixdittrich92 in #1336
New Features
- feat: ✨ Official docker images for docTR by @odulcy-mindee in #1322
- Add wildreceipt dataset by @HamzaGbada in #1359
- Added early stopping feature by @SkaarFacee in #1397
- [PT / TF] Add TextNet - FAST backbone by @felixdittrich92 in #1425
- feat: Adds conda recipe & corresponding CI jobs by @frgfm in #1414
- [prototype] Extend detection result customization by @felixdittrich92 in #1449
Bug Fixes
- [FIX] antialising in PreProcessor by @felixdittrich92 in #1324
- [Fix] prob computation for parseq and vitstr models by @felixdittrich92 in #1327
- [FIX] clip overflowing probs by @felixdittrich92 in #1335
- [Fix] PT - convert BF16 tensor to float before calling .numpy() by @chunyuan-w in #1342
- [Fix] Prob comp in vitstr and parseq for empty words by @felixT2K in #1345
- [Fix] TF - add bf16 numpy dtype conversion by @felixT2K in #1346
- [Fix] fix growing mem usage pytorch crnn by @felixdittrich92 in #1357
- [Fix] tf augmentations by @felixT2K in #1360
- Fix broken weasyprint link by @simonw in #1367
- feat: ✨ use
tqdminstead offastprogressin reference scripts by @odulcy-mindee in #1389 - [FIX] Fix mypy errors by @felixdittrich92 in #1419
- [FIX] db loss TF and PT also for training with rotated samples by @felixdittrich92 in #1396
- [FIX] Dice loss computation in both backends by @felixdittrich92 in #1442
- [FIX] Fix streamlit demo by @felixdittrich92 in #1447
- [Fix / Misc] Fix conda CI build and publish job and update actions by @felixdittrich92 in #1453
- [Fix] Catch Divide by zero explicit by @felixdittrich92 in #1471
Improvements
- feat: ✨ PT ViTSTR Small Checkpoint by @odulcy-mindee in #1319
- feat: ✨ PT Parseq Checkpoint by @odulcy-mindee in #1320
- [scripts] Add backbone freeze for recognition scripts and update augmentations also for DDP script by @felixdittrich92 in #1328
- [PyTorch] replace no_grad with inference_mode by @felixdittrich92 in #1323
- [transforms] update random apply to work also with targets by @felixdittrich92 in #1333
- [TF] unify detection augmentations by @felixdittrich92 in #1351
- feat: ✨ PT SAR Resnet31 Checkpoint by @odulcy-mindee in #1362
- feat: ✨ PT ViTSTR Base checkpoint by @odulcy-mindee in #1361
- TF change antialias to true by @felixT2K in #1348
- feat: ✨ PT Linknet Resnet18 Checkpoint by @odulcy-mindee in #1387
- [demo] remove limitation and update demo by @felixdittrich92 in #1390
- feat: ✨ PT Linknet Resnet50 Checkpoint by @odulcy-mindee in #1391
- feat: ✨ PT Linknet Resnet 34 Checkpoint by @odulcy-mindee in #1393
- [Fixes / docs] Add more vocabs / Fix Style / HF hub / API Dep by @felixdittrich92 in #1412
- fix: 🐛 add sqlite dependency by @odulcy-mindee in #1421
- feat: ✨ new TF Linknet Resnet checkpoints by @odulcy-mindee in #1424
- feat: ✨ PT db_resnet34 checkpoint by @odulcy-mindee in #1433
- [references] TF / PT crop & document orientation classifier train scripts by @felixdittrich92 in #1432
- [PT] remove submodule from textnet arch by @felixdittrich92 in #1436
- [references] Add poly scheduler for detection training by @felixdittrich92 in #1444
- [references] Add interval saving for detection trainings by @felixdittrich92 in #1454
- feat: ✨ PT db_resnet50 checkpoint by @odulcy-mindee in #1465
- read labels in utf-8 and log input string on vocab error by @eikaramba in #1479
- feat: ✨ tf db_resnet50 checkpoint by @odulcy-mindee in #1480
- feat: ✨ TF db mobilenet v3 large new ckpt by @odulcy-mindee in #1483
- [Docs] extend doc with DocumentBuilder options by @felixdittrich92 in #1486
- feat: ✨ TF db mobilenet v3 large new ckpt by @odulcy-mindee in #1487
Miscellaneous
- chore: apply post release modifications v0.7.0 by @felixdittrich92 in #1309
- docs: ✏️ fix images on pypi by @odulcy-mindee in #1310
- Update Dockerfile (GPU Support, Workdir, Permissions) by @ffalkenberg in #1313
- [misc] rename helper function for bf16 to float32 casting by @felixdittrich92 in #1347
- hebrew letters by @uriva in #1355
- docs: ✏️ add
WILDRECEIPTin docs and fixREADME.mdby @odulcy-mindee in #1363 - [misc] increase to 0.8.0 and temp pin onnx by @felixT2K in #1365
- [Fix] Typo in README.md by @eltociear in #1374
- Relax Pillow and OpenCV version bounds. by @nh2 in #1373
- [misc & build] replace isort pydocstyle and black with ruff by @felixdittrich92 in #1379
- [Misc] rename char classifiation scripts and dependency pin by @felixdittrich92 in #1469
- [Docs] add PyTorch / TensorFlow benchmarks by @felixdittrich92 in #1321
- [misc] rename channel by @felixdittrich92 in #1488
New Contributors
- @ffalkenberg made their first contribution in #1313
- @chunyuan-w made their first contribution in #1342
- @uriva made their first contribution in #1355
- @simonw made their first contribution in #1367
- @nh2 made their first contribution in #1373
- @SkaarFacee made their first contribution in #1397
- @eikaramba made their first contribution in #1479
Full Changelog: v0.7.0...v0.8.0
v0.7.0
Note: doctr 0.7.0 requires either TensorFlow >= 2.11.0 or PyTorch >= 1.12.0.
Note: We will release the missing PyTorch checkpoints with 0.7.1
What's Changed
Breaking Changes 🛠
- We changed the
preserve_aspect_ratioparameter toTrueby default in #1279
=> To restore the old behaviour you can passpreserve_aspect_ratio=Falseto thepredictorinstance
New features
- Feat: Make detection training and inference Multiclass by @aminemindee in #1097
- Now all TensorFlow models have pretrained weights by @odulcy-mindee
- The docs was updated and model corresponding benchmarks was added by @felixdittrich92
- Two new recognition models was added (ViTSTR and PARSeq) in both frameworks by @felixdittrich92 @nikokks
Add of the KIE predictor
The KIE predictor is a more flexible predictor compared to OCR as your detection model can detect multiple classes in a document. For example, you can have a detection model to detect just dates and adresses in a document.
The KIE predictor makes it possible to use detector with multiple classes with a recognition model and to have the whole pipeline already setup for you.
from doctr.io import DocumentFile
from doctr.models import kie_predictor
# Model
model = kie_predictor(det_arch='db_resnet50', reco_arch='crnn_vgg16_bn', pretrained=True)
# PDF
doc = DocumentFile.from_pdf("path/to/your/doc.pdf")
# Analyze
result = model(doc)
predictions = result.pages[0].predictions
for class_name in predictions.keys():
list_predictions = predictions[class_name]
for prediction in list_predictions:
print(f"Prediction for {class_name}: {prediction}")The KIE predictor results per page are in a dictionary format with each key representing a class name and it's value are the predictions for that class.
What's Changed
Breaking Changes 🛠
- Feat: Make detection training and inference Multiclass by @aminemindee in #1097
New Features
- feat: ✨ PyTorch Recognition Model Multi-GPU support by @odulcy-mindee in #1164
- [Feat] Add PARSeq model TF and PT by @nikokks in #1205
- [Feat] Predictor precision PT backend by @felixdittrich92 in #1204
- feat: ✨ ClearML support for TensorFlow by @odulcy-mindee in #1257
Bug Fixes
- fix classification model cuda move by @odulcy-mindee in #1125
- fix: 🔧 docker api use GitHub repository by @odulcy-mindee in #1148
- Error in unpacking archive of SROIE dataset by @HamzaGbada in #1178
- [Fix] remove autogen version.py fix docs build and fix version identifier by @felixT2K in #1180
- [FIX] Error in unpacking archive of CORD dataset by @HamzaGbada in #1190
- chore(deps-dev): update docutils requirement from <0.20 to <0.21 by @dependabot in #1198
- speed up VIT models and fix patch size by @felixdittrich92 in #1219
- [Fix] PARSeq pytorch fixes by @felixdittrich92 in #1227
- [Fix] PARSeq tensorflow fixes by @felixdittrich92 in #1228
- [fix/chore] fix bug in tf det eval script / update dep version specifier by @felixdittrich92 in #1232
- fix: 🐛 fix bug when training object detection by @aminemindee in #1254
- [Fix] fix obj det train and suppress endless warning prints by @felixdittrich92 in #1267
- [Fix] add ignore keys if classes differ - KIE training by @felixdittrich92 in #1271
- change the way model is saved in ddp by @venkatapathy in #1289
Improvements
- Improve pypdfium2 integration again by @mara004 in #1096
- [build] replaces flake8 with ruff by @felixT2K in #1179
- [datasets] Add IIIT HWS dataset by @felixT2K in #1199
- feat: ✨ TF linknet_resnet18 checkpoint by @odulcy-mindee in #1231
- [tests/bug] improve tests and fix a minor bug by @felixdittrich92 in #1229
- [PyTorch] update transforms pytorch (classification / det / rec) by @felixdittrich92 in #1253
- [docs] custom model load by @felixdittrich92 in #1263
- feat: ✨ TF ViTSTR Small checkpoint by @odulcy-mindee in #1273
- [predictor] aspect ratio true by default by @felixdittrich92 in #1279
- feat: ✨ TF SAR Resnet31 checkpoint by @odulcy-mindee in #1281
Miscellaneous
- chore: apply post release modifications v0.6.0 by @felixdittrich92 in #1081
- chore: dev version downgrade from 0.7.0 to 0.6.1 by @felixdittrich92 in #1082
- chore(deps-dev): update black requirement from <23.0,>=22.1 to >=22.1,<24.0 by @dependabot in #1140
- chore(deps-dev): update docutils requirement from <0.18 to <0.20 by @dependabot in #1101
- docs: Minor typo fix by @khanfarhan10 in #1150
- Update utils.py by @weiwangmeta in #1177
- [tests/TF/build] enable missing classification onnx tests and set tensorflow lower bound to 2.11 by @felixT2K in #1182
- [build] update pytorch dependency by @felixT2K in #1188
- [build] drop py3.6/3.7 support and update CI default to py3.8/3.9 by @felixT2K in #1184
- [CI] change old cache action and skip TF classification onnx export temporarily by @felixT2K in #1201
- [Fix] add missing mean/std defaults, add missing weight init for sar by @felixT2K in #1212
- [classification] vit and magc_resnet checkpoints by @felixdittrich92 in #1221
- [tests] update test cases by @felixT2K in #1233
- chore: apply PIL major changes and increase min version specifier by @felixT2K in #1237
- [chore]: Pypdfium2 compatibility fix by @felixT2K in #1239
- [chore]: Replace
tensorflow_addonsby @felixdittrich92 in #1252 - [style] Fix markdown style warnings by @felixdittrich92 in #1260
- [docs] update export page to ONNX by @felixdittrich92 in #1261
- [PyPi] Fix image display by @felixdittrich92 in #1268
- [chore] increase version and update maintainers by @felixT2K in #1264
- [demo] update models list for Tf / PT backend by @felixdittrich92 in #1280
- [chore] update to new torchvision API in models as well by @felixT2K in #1291
- [chore]: clean dependencies by @felixT2K in #1287
- feat: ✨ TF Parseq checkpoint by @odulcy-mindee in #1305
- feat: ✨ TF ViTSTR Base checkpoint by @odulcy-mindee in #1306
- [docs] update benchmark page by @felixdittrich92 in #1234
New Contributors
- @dependabot made their first contribution in #1140
- @eltociear made their first contribution in #1119
- @khanfarhan10 made their first contribution in #1150
- @weiwangmeta made their first contribution in #1177
- @HamzaGbada made their first contribution in #1178
- @felixT2K made their first contribution in #1180
- @nikokks made their first contribution in #1205
- @odulcy made their first contribution in #1246
- @venkatapathy made their first contribution in #1289
Full Changelog: v0.6.0...v0.7.0
v0.6.0
Highlights of the release:
Note: doctr 0.6.0 requires either TensorFlow >= 2.9.0 or PyTorch >= 1.8.0.
Full integration with Huggingface Hub (docTR meets Huggingface)
- Loading from hub:
from doctr.io import DocumentFile
from doctr.models import ocr_predictor, from_hub
image = DocumentFile.from_images(['data/example.jpg'])
# Load a custom detection model from huggingface hub
det_model = from_hub('Felix92/doctr-torch-db-mobilenet-v3-large')
# Load a custom recognition model from huggingface hub
reco_model = from_hub('Felix92/doctr-torch-crnn-mobilenet-v3-large-french')
# You can easily plug in this models to the OCR predictor
predictor = ocr_predictor(det_arch=det_model, reco_arch=reco_model)
result = predictor(image)
- Pushing to the hub:
from doctr.models import recognition, login_to_hub, push_to_hf_hub
login_to_hub()
my_awesome_model = recognition.crnn_mobilenet_v3_large(pretrained=True)
push_to_hf_hub(my_awesome_model, model_name='doctr-crnn-mobilenet-v3-large-french-v1', task='recognition', arch='crnn_mobilenet_v3_large')
Documentation: https://mindee.github.io/doctr/using_doctr/sharing_models.html
Predefined datasets can be used also for recognition task
from doctr.datasets import CORD
# Crop boxes as is (can contain irregular)
train_set = CORD(train=True, download=True, recognition_task=True)
# Crop rotated boxes (always regular)
train_set = CORD(train=True, download=True, use_polygons=True, recognition_task=True)
img, target = train_set[0]
Documentation: https://mindee.github.io/doctr/using_doctr/using_datasets.html
New models (both frameworks)
- classification: VisionTransformer (ViT)
- recognition: Vision Transformer for Scene Text Recognition (ViTSTR)
Bug fixes recognition models
- MASTER and SAR architectures are now operational in both frameworks (TensorFlow and PyTorch)
ONNX support (experimential)
- All models can now be exported into ONNX format (only TF mobilenet left for 0.7.0)
NOTE: full production pipeline with ONNX / build is planned for 0.7.0 (the models can be only exported up to the logits without any post processing included)
Further features
- our demo is now also PyTorch compatible, thanks to @odulcy-mindee
- it is now possible to detect the language of the extracted text, thanks to @aminemindee
What's Changed
Breaking Changes 🛠
- feat: ✨ allow beam width > 1 in the CRNN postprocessor by @khalidMindee in #630
- [Fix] TensorFlow SAR_Resnet31 implementation by @felixdittrich92 in #925
New Features
- [onnx] classification models export by @felixdittrich92 in #830
- feat: Added Vietnamese entry in VOCAB by @calibretaliation in #878
- feat: Added Czech to the set of vocabularies in datasets/vocabs.py by @Xargonus in #885
- feat: Add ability to upload PT/TF models to Huggingface Hub by @felixdittrich92 in #881
- [feature][tf/pt] integrate from_hub for all tasks by @felixdittrich92 in #892
- [feature] Part 2 from use datasets for recognition by @felixdittrich92 in #891
- [datasets] Add MJSynth (Synth90K) by @felixdittrich92 in #827
- [docu]: add documentation for datasets by @felixdittrich92 in #905
- add a Slack Community badge by @fharper in #936
- Feat/add language detection by @aminemindee in #1023
- add ViT as classification model TF and PT by @felixdittrich92 in #1050
- [models] add ViTSTR TF and PT and update ViT to work as backbone by @felixdittrich92 in #1055
Bug Fixes
- [PyTorch][references] fix pretrained with different vocabs by @felixdittrich92 in #874
- [classification] Fix cfgs by @felixdittrich92 in #883
- docs: Fixed typo in installation instructions by @frgfm in #901
- [Fix] imgur5k test by @felixdittrich92 in #903
- fix: Fixed load_pretrained_params in PyTorch when ignoring keys by @frgfm in #902
- [Fix]: Documentation add missing in vocabs and correct tab in sharing models by @felixdittrich92 in #904
- Fix links in readme by @jsn5 in #937
- [Fix] PyTorch MASTER implementation by @felixdittrich92 in #941
- [Fix] MJSynth dataset: filter corrupted or missing images by @felixdittrich92 in #956
- [Fix] SVT dataset: clip box values and add shape and label check by @felixdittrich92 in #955
- [Fix] Tensorflow MASTER implementation by @felixdittrich92 in #949
- [FIX] MASTER AMP and onnxruntime issue with master PT by @felixdittrich92 in #986
- pytest-api test: fix ping server step by @odulcy-mindee in #997
- docs/index: fix two minor typos by @mara004 in #1002
- Fix orientation details export by @aminemindee in #1022
- Changed return type of multithread_exec to iterator by @mtvch in #1019
- [datasets] Fix recognition parts of SynthText and IMGUR5K by @felixdittrich92 in #1038
- [Fix] rotation classifier input move to model device by @felixdittrich92 in #1039
- [models] Vit: fix intermediate size scale and unify TF to PT by @felixdittrich92 in #1063
Improvements
- chore: Applied post release modifications v0.5.1 by @felixdittrich92 in #870
- [refactor][fix]: Part1 from use datasets for recognition task by @felixdittrich92 in #889
- ci: Add swagger ping in API CI job by @frgfm in #906
- [docs] Add naming conventions for upload models to hf hub by @felixdittrich92 in #921
- docs: Improved error message of encode_string by @frgfm in #929
- [Refactor] PyTorch SAR_Resnet31 make it ONNX exportable (again) by @felixdittrich92 in #930
- Add support page in README by @jonathanMindee in #946
- [references] Add eval recognition and update eval detection scripts by @felixdittrich92 in #933
- update pypdfium2 dep and improve code quality by @felixdittrich92 in #953
- docs: Moved need help section after code snippet by @frgfm in #959
- chore: Updated TF requirements to fix grouped convolutions on CPU by @frgfm in #963
- style: Fixed mypy and moved tool configs to pyproject.toml by @frgfm in #966
- Updating the readme by @Atomme1 in #938
- Update docs in
using_doctrby @odulcy-mindee in #993 - feat: add a basic example of text detection by @ianardee in #999
- Add pytorch demo by @odulcy-mindee in #1008
- [build] move requirements to pyproject.toml by @felixdittrich92 in #1031
- Migrate static data from github to monitoring middleware. by @marvinmindee in #1033
- Changes needed to be able to use doctr on AWS Lambda by @mtvch in #1017
- [Fix] unify recognition dataset parts return signature by @felixdittrich92 in #1041
- Updated README.md for custom fonts by @carl-krikorian in #1051
- [refactor] detection script by @felixdittrich92 in #1060
- [models] ViT add checkpoints and some rework to use pretrained ViT backbone in ViTSTR by @felixdittrich92 in #1072
- upgrade pypdfium2 by @felixdittrich92 in #1075
- ViTSTR disable pretrained backbone by default by @felixdittrich92 in #1080
Miscellaneous
- [Refactor] commit tags by @felixdittrich92 in #871
- Update
io/pdf.pyto new pypdfium2 API by @mara004 in #944 - docs: Documentation the reason for keras version specifier by @frgfm in #958
- [datasets] update IC / SROIE / FUNSD / CORD by @felixdittrich92 in #983
- [datasets] revert whitespace filtering and fix svhn reco by @felixdittrich92 in #987
- fix: update tensorflow-addons to match tensorflow version by @ianardee in #998
- move transformers implementation to modules by @felixdittr...
v0.5.1
This minor release includes: improvement of the documentation thanks to @felixdittrich92, bugs fixed, support of rotation extended to Tensorflow backend, a switch from PyMuPDF to pypdfmium2 and a nice integration to the Hugginface Hub thanks to @fg-mindee !
Note: doctr 0.5.0 requires either TensorFlow 2.4.0 or PyTorch 1.8.0.
Highlights
Improvement of the documentation
The documentation has been improved adding a new theme, illustrations, and docstring has been completed and developed.
This how it renders:
Rotated text detection extended to Tensorflow backend
We provide weights for the linknet_resnet18_rotation model which has been deeply modified: We implemented a new loss (based on Dice Loss and Focal Loss), we changed the computation of the targets so that polygons are shrunken the same way they are in the DBNet which improves highly the precision of the segmenter and we trained the model preserving the aspect ratio of the images.
All these improvements led to much better results, and the pretrained model is now very robust.
Preserving the aspect ratio in the detection task
You can now choose to preserve the aspect ratio in the detection_predictor:
>>> from doctr.models import detection_predictor
>>> predictor = detection_predictor('db_resnet50_rotation', pretrained=True, assume_straight_pages=False, preserve_aspect_ratio=True)
This option can also be activated in the high level end-to-end predictor:
>>> from doctr.model import ocr_predictor
>>> model = ocr_predictor('linknet_resnet18_rotation', pretrained=True, assume_straight_pages=False, preserve_aspect_ratio=True)
Integration within the HugginFace Hub
The artefact detection model is now available on the HugginFace Hub, this is amazing:
On DocTR, you can now use the .from_hub() method so that those 2 snippets are equivalent:
# Pretrained
from doctr.models.obj_detection import fasterrcnn_mobilenet_v3_large_fpn
model = fasterrcnn_mobilenet_v3_large_fpn(pretrained=True)
and:
# HF Hub
from doctr.models.obj_detection.factory import from_hub
model = from_hub("mindee/fasterrcnn_mobilenet_v3_large_fpn")
Breaking changes
Replacing the PyMuPDF dependency with pypdfmium2 which is license compatible
We replaced for the PyMuPDF dependency with pypdfmium2 for a license-compatibility issue, so we loose the word and objects extraction from source pdf which was done with PyMuPDF. It wasn't used in any models so it is not a big issue, but anyway we will work in the future to re-integrate such a feature.
Full changelog
What's Changed
Breaking Changes 🛠
- fix: polygon orientation + line aggregation by @charlesmindee in #801
- refactor: Switched from PyMuPDF to pypdfium2 by @fg-mindee in #829
New Features
- feat: Added RandomHorizontalFLip in TF by @SiddhantBahuguna in #779
- Imgur5k dataset integration by @felixdittrich92 in #785
- feat: Added support of GPU for predictors in PyTorch by @fg-mindee in #808
- Add SynthWordGenerator to text reco training scripts by @felixdittrich92 in #825
- fix: Fixed some ResNet architecture imprecisions by @fg-mindee in #828
- feat: Added shadow augmentation for all backends by @fg-mindee in #811
- feat: Added loading method for PyTorch artefact detection models from HF Hub by @fg-mindee in #836
- feat: add rotated linknet_resnet18 tensorflow ckpts by @charlesmindee in #817
Bug Fixes
- fix: Fixed rotation of img + target by @fg-mindee in #784
- fix: show sample when batch size is 1 by @charlesmindee in #787
- ci: Fixed PR label check job by @fg-mindee in #792
- ci: Fixed typo in the script ref by @fg-mindee in #794
- [datasets] fix description by @felixdittrich92 in #795
- fix: linknet target computation by @charlesmindee in #803
- ci: Fixed issue templates by @fg-mindee in #806
- fix: Reverted mistake in demo by @fg-mindee in #810
- Restore remap boxes by @Rob192 in #812
- fix: Fixed SAR model for training and inference in PyTorch by @fg-mindee in #831
- fix: Fixed expand_line for horizontal & vertical cases by @fg-mindee in #842
- fix: Fixes inplace target modifications for AbstractDatasets by @fg-mindee in #848
- fix: Fixed landing page and title underlines by @fg-mindee in #860
- docs: Fixed HTML title by @fg-mindee in #864
Improvements
- docs: Updated headers of python files by @fg-mindee in #781
- [datasets] unify np_dtype and fix comments by @felixdittrich92 in #782
- fix: Clip in rotation transform + eval_straight mode for training by @charlesmindee in #786
- refactor: Avoids instantiating orientation predictor when unnecessary by @fg-mindee in #809
- feat: add straight-eval arg in evaluate script by @charlesmindee in #793
- feat: add dice loss in linknet by @charlesmindee in #816
- feat: add shrinked target in linknet + dilation in postprocessing by @charlesmindee in #822
- feat: replace bce by focal loss in linknet loss by @charlesmindee in #824
- docs: add rotation in docs by @charlesmindee in #846
- feat: add aspect ratio for ocr predictor by @charlesmindee in #835
- feat: add target to resize transform for aspect ratio training (detection task) by @charlesmindee in #823
- update bug report ticket with Active backend field by @felixdittrich92 in #853
- Theme + css #1 by @felixdittrich92 in #856
- docs: Adds illustration in the docstrings of doctr.datasets by @felixdittrich92 in #857
- docs: Updated docstrings of io, transforms & utils by @felixdittrich92 in #859
- docs: Updated folder hierarchy of doc source and nootbooks to rst file by @felixdittrich92 in #862
- Doc models #5 by @felixdittrich92 in #861
- fix: linknet hyperparameters postprocessing + demo for rotation model by @charlesmindee in #865
Miscellaneous
- chore: Applied post release modifications by @fg-mindee in #780
- Switch to new pypdfium2 API by @mara004 in #845
New Contributors
Full Changelog: v0.5.0...v0.5.1





