Images / Intermediate

Ask questions about an image with jina ocr v1

Load the publisher's jinaai/jina-ocr-v1 model with Transformers, run OCR on a local PIL image, and inspect the decoded text for visible details.

EstimatedSource checked 9/25/2026
LOCALRENTED GPU

Before you begin

Difficulty
Intermediate
Software
Python, transformers, torch, torchvision, Pillow
Hardware
This setup uses Transformers. The exact checkpoint format, context, and runtime overhead determine its memory need; a weight-file size alone is not a GPU recommendation.
IMAGES / TRANSFORMERSSOURCE-LINKED SETUP

Ask questions about an image with jina ocr v1, step by step.

Load the publisher's jinaai/jina-ocr-v1 model with Transformers, run OCR on a local PIL image, and inspect the decoded text for visible details.

Choose a package Run its commands Check the result
01
BEFORE YOU BEGIN

The documented package

This setup uses the package documented for this task. Review its source and supported platforms before starting.

The publisher has not provided a complete memory target for this task. Check its hardware guidance before starting.

CURRENT SETUP

jina ocr v1 · official

This setup uses Transformers. The exact checkpoint format, context, and runtime overhead determine its memory need; a weight-file size alone is not a GPU recommendation.

View weight source
02
THE WORKFLOW

Set up jina ocr v1 on your machine

Pick your operating system. Every command below is for the selected package and runtime.

The publisher supplies Python code but does not specify an operating system. Linux is a practical starting environment, not a publisher-tested machine. Run the Python snippets in one session, in order.

01

Install the required Python packages

In your Python environment, install transformers, torch, torchvision, and Pillow. These are the four packages the Jina OCR v1 documentation lists for Transformers usage.

02

Prepare a document image

Place a local image file named document.png in your working directory. The model accepts one PIL image per call. The publisher's example opens document.png and converts it to RGB, so use that exact filename or update the path in your script.

03

Load jina-ocr-v1 with Transformers

Run this script to load the model from jinaai/jina-ocr-v1 with the repository's remote code, select CUDA if available, prepare the OCR inputs for document.png, generate a greedy response, and decode it.

import torch from PIL import Image from transformers import AutoModelForCausalLM, AutoProcessor MODEL_ID = 'jinaai/jina-ocr-v1' device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') processor = AutoProcessor.from_pretrained(MODEL_ID, trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained( MODEL_ID, dtype=torch.bfloat16, trust_remote_code=True, ).to(device) image = Image.open('document.png').convert('RGB') inputs = processor.prepare_ocr_inputs(image, device=device) output = model.generate(**inputs, max_new_tokens=4096, do_sample=False) print(processor.decode_ocr(output, inputs['input_ids']))
04

Check that the decoded output matches the image

The script prints the model's decoded text. Read the printed result and compare it to text that is visibly present in document.png, such as headings, body paragraphs, tables, or numbers. Confirm the answer includes the expected visible details; if the printed text is unrelated to the image, retry with an RGB image containing clear text or reduce max_new_tokens to keep decoding within memory.

03
SUCCESS CHECK · jina ocr v1

Check the image answer

Ask about a visible detail in a local test image and compare the answer to the image yourself.

This is a source-linked setup, not a YouRunAI hardware test. Confirm your exact runtime version, package, and output before relying on it.

Back to setup steps

When it doesn’t go to plan

The model cannot be loaded.

Make sure the required packages are installed and that you passed trust_remote_code=True, as the repository ships its own custom modeling code.

CUDA is unavailable and the model runs on CPU.

This is expected. Leave the device selection as torch.device('cuda' if torch.cuda.is_available() else 'cpu'); the same script will run on CPU.

Pillow cannot open document.png.

Confirm that document.png exists in the working directory and is a valid image file, then rerun the script.

REFERENCE LIBRARY

Sources and files

Original instructions, model files, and compatibility notes behind this setup.

2 SOURCES

The model behind this workflow

jina ocr v1
MY HARDWARE

Will it run on your machine?

Save your machine to see a personalized rating and its reasoning.

Add my hardware

Keep exploring