Instructions to use paran3xus/typress_ocr with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use paran3xus/typress_ocr 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="paran3xus/typress_ocr")# Load model directly from transformers import AutoTokenizer, AutoModelForImageTextToText tokenizer = AutoTokenizer.from_pretrained("paran3xus/typress_ocr") model = AutoModelForImageTextToText.from_pretrained("paran3xus/typress_ocr") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: mit
|
| 3 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
---
|
| 4 |
+
# Typst Euqation OCR Model
|
| 5 |
+
A pretrained TrOCR model for Typst equation OCR tasks.
|
| 6 |
+
|
| 7 |
+
## Usage
|
| 8 |
+
```python
|
| 9 |
+
from PIL import Image
|
| 10 |
+
from transformers import TrOCRProcessor, VisionEncoderDecoderModel
|
| 11 |
+
|
| 12 |
+
processor = TrOCRProcessor.from_pretrained("paran3xus/typst_eq_ocr")
|
| 13 |
+
model = VisionEncoderDecoderModel.from_pretrained('paran3xus/typst_eq_ocr')
|
| 14 |
+
|
| 15 |
+
image_fps = [
|
| 16 |
+
'testimg/1.png',
|
| 17 |
+
]
|
| 18 |
+
images = [Image.open(fp).convert('RGB') for fp in image_fps]
|
| 19 |
+
pixel_values = processor(images=images, return_tensors="pt").pixel_values
|
| 20 |
+
generated_ids = model.generate(pixel_values)
|
| 21 |
+
generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)
|
| 22 |
+
[print(i) for i in generated_text]
|
| 23 |
+
```
|