Image-to-Text
Transformers
Safetensors
PyTorch
ONNX
English
Ukrainian
htr-convtext
feature-extraction
ocr
icr
handwriting-recognition
ukrainian
ctc
custom_code
Instructions to use Valerii02/ukr-htr-convtext with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Valerii02/ukr-htr-convtext with Transformers:
# Use a pipeline as a high-level helper # Warning: Pipeline type "image-to-text" is no longer supported in transformers v5. # You must load the model directly (see below) or downgrade to v4.x with: # pip install "transformers<5.0.0" from transformers import pipeline pipe = pipeline("image-to-text", model="Valerii02/ukr-htr-convtext", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Valerii02/ukr-htr-convtext", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Valerii Sielikhov
Initial release: Ukrainian OCR/ICR model with HF custom model/processor and ONNX export
b5b608e Download tests/test_processor.py from Valerii02/ukr-htr-convtext: direct link, hf CLI and curl.
- Browser
- Download file 1.07 kB
-
https://huggingface.co/Valerii02/ukr-htr-convtext/resolve/main/tests/test_processor.py
- Command line
-
hf download hf://Valerii02/ukr-htr-convtext/tests/test_processor.py
-
curl -L -o test_processor.py https://huggingface.co/Valerii02/ukr-htr-convtext/resolve/main/tests/test_processor.py
1.07 kB
| from __future__ import annotations | |
| import numpy as np | |
| from PIL import Image | |
| from processing_htr import HTRProcessor | |
| def test_preprocess_shape_stride_alignment() -> None: | |
| processor = HTRProcessor(characters=["а", "б", "в"], image_height=64, image_max_width=256, width_stride=32) | |
| img = Image.fromarray((np.random.rand(53, 117) * 255).astype(np.uint8)) | |
| out = processor(images=img, return_tensors="np")["pixel_values"] | |
| assert out.shape[0] == 1 | |
| assert out.shape[1] == 1 | |
| assert out.shape[2] == 64 | |
| assert out.shape[3] % 32 == 0 | |
| def test_ctc_batch_decode() -> None: | |
| processor = HTRProcessor(characters=["а", "б", "в"], image_height=64, image_max_width=256, width_stride=32) | |
| logits = np.array( | |
| [ | |
| [[0.1, 0.9, 0.0, 0.0], [0.1, 0.0, 0.9, 0.0]], | |
| [[0.1, 0.9, 0.0, 0.0], [0.1, 0.0, 0.9, 0.0]], | |
| [[0.9, 0.0, 0.0, 0.0], [0.9, 0.0, 0.0, 0.0]], | |
| ], | |
| dtype=np.float32, | |
| ) # T,N,C | |
| texts = processor.batch_decode(logits, logit_layout="tnc") | |
| assert texts == ["а", "б"] | |