YesOCR-0.8B

English | ไธญๆ–‡

General Chineseโ€“English Bilingual OCR.

YesOCR-0.8B turns text in Chinese, English, and mixed-language images into editable plain text. Use it to transcribe document pages, screenshots, receipts, signs, and other everyday images. It aims to follow reading order and preserve the original text and line breaks.

The model is fine-tuned from Qwen3.5-0.8B, primarily using the OCR-Data dataset.

Try it

Use Python 3.10 or newer. A GPU is recommended for faster recognition; CPU inference is also supported.

Download the model, install its dependencies, and recognize the included example image:

python -m pip install huggingface_hub
hf download Yesianrohn/YesOCR-0.8B --local-dir ./YesOCR-0.8B
cd YesOCR-0.8B
python -m pip install -r requirements.txt

python inference.py --model . --image example.png --output result.txt

Example image

The recognized text is printed in the terminal and saved to result.txt:

YesOCR demo
Order: A1024
Total: 128.50

Recognize your own images

Replace your-image.png with the path to your image:

python inference.py --model . --image your-image.png --output result.txt

The same command works for Chinese, English, and mixed-language images. There is no need to select a language. The result is a transcription of the original text.

The script automatically uses a GPU when one is available. Add --device cpu to run on CPU. Once the model and dependencies are downloaded, --model . lets you use the local files offline.

Use with Transformers

You can also load Yesianrohn/YesOCR-0.8B directly in Python. The example below uses a CUDA GPU with BF16 support. Replace example.png with your image path; keep the provided OCR prompt for both Chinese and English images.

Show the complete Python example
import torch
from PIL import Image, ImageOps, PngImagePlugin
from transformers import AutoModelForImageTextToText, AutoProcessor

MODEL_ID = "Yesianrohn/YesOCR-0.8B"

# Allow PNGs with large compressed color profiles.
PngImagePlugin.MAX_TEXT_CHUNK = 64 * 1024 * 1024
PngImagePlugin.MAX_TEXT_MEMORY = 256 * 1024 * 1024

processor = AutoProcessor.from_pretrained(MODEL_ID)
model = AutoModelForImageTextToText.from_pretrained(
    MODEL_ID,
    dtype=torch.bfloat16,
    attn_implementation="sdpa",
).to("cuda").eval()

with Image.open("example.png") as source:
    image = ImageOps.exif_transpose(source).convert("RGB")

prompt = (
    "่ฏทๆŒ‰้˜…่ฏป้กบๅบ่ฝฌๅฝ•ๅ›พ็‰‡ไธญ็š„ๅ…จ้ƒจๅฏ่พจ่ฎคๆ–‡ๅญ—๏ผŒไฟ็•™ๅŽŸๆ–‡ๅ’Œๆข่กŒ๏ผŒๆ–‡ๆœฌๅ—ไน‹้—ด็ฉบไธ€่กŒใ€‚"
    "ไป…่พ“ๅ‡บ่ฝฌๅฝ•็ป“ๆžœใ€‚"
)
messages = [{
    "role": "user",
    "content": [
        {"type": "image", "image": image},
        {"type": "text", "text": "\n" + prompt},
    ],
}]

text = processor.apply_chat_template(
    messages,
    tokenize=False,
    add_generation_prompt=True,
    enable_thinking=False,
)
inputs = processor(text=[text], images=[image], return_tensors="pt").to(model.device)

with torch.inference_mode():
    output_ids = model.generate(
        **inputs,
        max_new_tokens=4096,
        do_sample=False,
        num_beams=1,
        use_cache=True,
    )

# Decode only the newly generated tokens.
new_tokens = output_ids[:, inputs["input_ids"].shape[1]:]
result = processor.batch_decode(new_tokens, skip_special_tokens=True)[0].strip()
image.close()
print(result)

For CPU inference, replace dtype=torch.bfloat16 with dtype=torch.float32 and .to("cuda") with .to("cpu").

Tips

  • Use clear images with readable text. For dense or long pages, try cropping the page into sections in reading order.
  • If a long transcription stops early, add --max-new-tokens 8192.
  • If GPU memory is insufficient, try --max-pixels 1000000.
  • Output is plain text. Complex tables, columns, and page layouts may need manual formatting.

License and credits

Published by Yesianrohn under the Apache License 2.0. Thanks to the Qwen team for the base model. See NOTICE for attribution.

Downloads last month
4
Safetensors
Model size
1B params
Tensor type
BF16
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for Yesianrohn/YesOCR-0.8B

Finetuned
(888)
this model

Dataset used to train Yesianrohn/YesOCR-0.8B