Image-Text-to-Text
Transformers
Safetensors
qwen2_vl
german
deutsch
ocr
vision
document-ai
invoice
rechnung
structured-extraction
json-extraction
kie
ollama
vllm
llama-cpp
apache-2.0
conversational
text-generation-inference
Instructions to use keyvan-ai/german-ocr with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use keyvan-ai/german-ocr with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="keyvan-ai/german-ocr") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("keyvan-ai/german-ocr") model = AutoModelForMultimodalLM.from_pretrained("keyvan-ai/german-ocr") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use keyvan-ai/german-ocr with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "keyvan-ai/german-ocr" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "keyvan-ai/german-ocr", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/keyvan-ai/german-ocr
- SGLang
How to use keyvan-ai/german-ocr with 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 "keyvan-ai/german-ocr" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "keyvan-ai/german-ocr", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'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 "keyvan-ai/german-ocr" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "keyvan-ai/german-ocr", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use keyvan-ai/german-ocr with Docker Model Runner:
docker model run hf.co/keyvan-ai/german-ocr
| { | |
| "$schema": "https://json-schema.org/draft/2020-12/schema", | |
| "$id": "german-ocr-3/schemas/generic_document.json", | |
| "title": "GermanOCR3 Generic Document", | |
| "description": "Allgemeines deutsches Dokument-Extraktionsschema. Felder dürfen null sein, wenn nicht eindeutig erkennbar.", | |
| "type": "object", | |
| "additionalProperties": false, | |
| "required": ["document_type", "language", "raw_text", "confidence"], | |
| "properties": { | |
| "document_type": { | |
| "description": "z.B. invoice, receipt, letter, form, contract, id_card, other, unknown", | |
| "type": ["string", "null"] | |
| }, | |
| "language": { | |
| "description": "BCP-47 Sprachcode des Dokuments (typisch 'de').", | |
| "type": "string", | |
| "default": "de" | |
| }, | |
| "sender": { | |
| "type": ["object", "null"], | |
| "additionalProperties": false, | |
| "properties": { | |
| "name": {"type": ["string", "null"]}, | |
| "address": {"type": ["string", "null"]}, | |
| "email": {"type": ["string", "null"]}, | |
| "phone": {"type": ["string", "null"]}, | |
| "tax_id": {"type": ["string", "null"]}, | |
| "vat_id": {"type": ["string", "null"]} | |
| } | |
| }, | |
| "recipient": { | |
| "type": ["object", "null"], | |
| "additionalProperties": false, | |
| "properties": { | |
| "name": {"type": ["string", "null"]}, | |
| "address": {"type": ["string", "null"]}, | |
| "customer_id": {"type": ["string", "null"]} | |
| } | |
| }, | |
| "date": { | |
| "description": "Hauptdatum des Dokuments im Format YYYY-MM-DD, falls eindeutig erkennbar.", | |
| "type": ["string", "null"] | |
| }, | |
| "reference_numbers": { | |
| "type": "array", | |
| "items": { | |
| "type": "object", | |
| "additionalProperties": false, | |
| "required": ["label", "value"], | |
| "properties": { | |
| "label": {"type": "string"}, | |
| "value": {"type": "string"} | |
| } | |
| }, | |
| "default": [] | |
| }, | |
| "amounts": { | |
| "type": "array", | |
| "items": { | |
| "type": "object", | |
| "additionalProperties": false, | |
| "required": ["label", "value"], | |
| "properties": { | |
| "label": {"type": "string"}, | |
| "value": {"type": ["number", "string"]}, | |
| "currency": {"type": ["string", "null"]} | |
| } | |
| }, | |
| "default": [] | |
| }, | |
| "tables": { | |
| "type": "array", | |
| "default": [], | |
| "items": { | |
| "type": "object", | |
| "additionalProperties": false, | |
| "required": ["headers", "rows"], | |
| "properties": { | |
| "title": {"type": ["string", "null"]}, | |
| "headers": {"type": "array", "items": {"type": "string"}}, | |
| "rows": { | |
| "type": "array", | |
| "items": { | |
| "type": "array", | |
| "items": {"type": ["string", "number", "null"]} | |
| } | |
| } | |
| } | |
| } | |
| }, | |
| "raw_text": { | |
| "description": "Roher OCR-Text, möglichst layouterhaltend, deutsche Originalschreibweise behalten.", | |
| "type": ["string", "null"] | |
| }, | |
| "confidence": { | |
| "description": "Subjektive Selbsteinschätzung 0..1.", | |
| "type": ["number", "null"], | |
| "minimum": 0, | |
| "maximum": 1 | |
| }, | |
| "notes": { | |
| "type": "array", | |
| "items": {"type": "string"}, | |
| "default": [] | |
| } | |
| } | |
| } | |