Instructions to use microsoft/trocr-base-printed with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use microsoft/trocr-base-printed 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="microsoft/trocr-base-printed")# Load model directly from transformers import AutoTokenizer, AutoModelForImageTextToText tokenizer = AutoTokenizer.from_pretrained("microsoft/trocr-base-printed") model = AutoModelForImageTextToText.from_pretrained("microsoft/trocr-base-printed") - Notebooks
- Google Colab
- Kaggle
Update code example
Browse files
README.md
CHANGED
|
@@ -30,7 +30,7 @@ import requests
|
|
| 30 |
|
| 31 |
# load image from the IAM database (actually this model is meant to be used on printed text)
|
| 32 |
url = 'https://fki.tic.heia-fr.ch/static/img/a01-122-02-00.jpg'
|
| 33 |
-
image = Image.open(requests.get(url, stream=True).raw)
|
| 34 |
|
| 35 |
processor = TrOCRProcessor.from_pretrained('microsoft/trocr-base-printed')
|
| 36 |
model = VisionEncoderDecoderModel.from_pretrained('microsoft/trocr-base-printed')
|
|
|
|
| 30 |
|
| 31 |
# load image from the IAM database (actually this model is meant to be used on printed text)
|
| 32 |
url = 'https://fki.tic.heia-fr.ch/static/img/a01-122-02-00.jpg'
|
| 33 |
+
image = Image.open(requests.get(url, stream=True).raw).convert("RGB")
|
| 34 |
|
| 35 |
processor = TrOCRProcessor.from_pretrained('microsoft/trocr-base-printed')
|
| 36 |
model = VisionEncoderDecoderModel.from_pretrained('microsoft/trocr-base-printed')
|