How to use from
SGLang
Install from pip and serve model
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
    --model-path "Sprakbanken/TrOCR-norhand-v3" \
    --host 0.0.0.0 \
    --port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
	-H "Content-Type: application/json" \
	--data '{
		"model": "Sprakbanken/TrOCR-norhand-v3",
		"prompt": "Once upon a time,",
		"max_tokens": 512,
		"temperature": 0.5
	}'
Use Docker images
docker run --gpus all \
    --shm-size 32g \
    -p 30000:30000 \
    -v ~/.cache/huggingface:/root/.cache/huggingface \
    --env "HF_TOKEN=<secret>" \
    --ipc=host \
    lmsysorg/sglang:latest \
    python3 -m sglang.launch_server \
        --model-path "Sprakbanken/TrOCR-norhand-v3" \
        --host 0.0.0.0 \
        --port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
	-H "Content-Type: application/json" \
	--data '{
		"model": "Sprakbanken/TrOCR-norhand-v3",
		"prompt": "Once upon a time,",
		"max_tokens": 512,
		"temperature": 0.5
	}'
Quick Links

Model Card for Sprakbanken/TrOCR-norhand-v3

This is a TrOCR-model for OCR (optical character recognition) of handwritten historic documents written in Norwegian.
It can be used to recognize text in images of handwritten text.

How to Get Started with the Model

Use the code below to get started with the model.

from transformers import TrOCRProcessor, VisionEncoderDecoderModel
from PIL import Image

processor = TrOCRProcessor.from_pretrained("Sprakbanken/TrOCR-norhand-v3")
model = VisionEncoderDecoderModel.from_pretrained("Sprakbanken/TrOCR-norhand-v3")

image = Image.open("path_to_image.jpg").convert("RGB")

pixel_values = processor(image, return_tensors="pt").pixel_values
generated_ids = model.generate(pixel_values)

generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]

Model Details

This model is microsoft/trocr-base-handwritten fine-tuned on the Huggingface version of the NorHand v3 dataset.

Model Description

Uses

You can use the raw model for handwritten text recognition (HTR) on single text-line images in Norwegian.

Out-of-Scope Use

The model only works with images of lines of text. If you have images of entire pages of text, you must segment the text into lines first to benefit from this model.

Downloads last month
367
Safetensors
Model size
0.3B params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for Sprakbanken/TrOCR-norhand-v3

Finetuned
(49)
this model

Spaces using Sprakbanken/TrOCR-norhand-v3 5