<!-- Release notes generated using configuration in .github/release.yml at main -->
<p align="center">
<img src="https://github.com/felixdittrich92/OnnxTR/blob/main/docs/images/logo.jpg" width="50%">
</p>
What's Changed
- Sync with current docTR state
- Hf hub integration
HuggingFace Hub integration
Now you can load and/or push models to the hub directly.
Loading
python
from onnxtr.io import DocumentFile
from onnxtr.models import ocr_predictor, from_hub
img = DocumentFile.from_images(['<image_path>'])
Load your model from the hub
model = from_hub('onnxtr/my-model')
Pass it to the predictor
If your model is a recognition model:
predictor = ocr_predictor(
det_arch='db_mobilenet_v3_large',
reco_arch=model
)
If your model is a detection model:
predictor = ocr_predictor(
det_arch=model,
reco_arch='crnn_mobilenet_v3_small'
)
Get your predictions
res = predictor(img)
Push
python
from onnxtr.models import parseq, push_to_hf_hub, login_to_hub
from onnxtr.utils.vocabs import VOCABS
Login to the hub
login_to_hub()
Recogniton model
model = parseq("~/onnxtr-parseq-multilingual-v1.onnx", vocab=VOCABS["multilingual"])
push_to_hf_hub(
model,
model_name="onnxtr-parseq-multilingual-v1",
task="recognition", The task for which the model is intended [detection, recognition, classification]
arch="parseq", The name of the model architecture
override=False Set to `True` if you want to override an existing model / repository
)
Detection model
model = linknet_resnet18("~/onnxtr-linknet-resnet18.onnx")
push_to_hf_hub(
model,
model_name="onnxtr-linknet-resnet18",
task="detection",
arch="linknet_resnet18",
override=True
)
HF Hub search: [here](https://huggingface.co/models?search=onnxtr).
Collection: [here](https://huggingface.co/collections/Felix92/onnxtr-66bf213a9f88f7346c90e842)
**Full Changelog**: https://github.com/felixdittrich92/OnnxTR/compare/v0.3.2...v0.4.0