Metadata-Version: 2.4
Name: g-ocr
Version: 0.1.0
Summary: GOCR — schnelle, kleine deutsche OCR-/Vision-Schicht für Dokumente (CPU, kein GPU): ganzes Dokument → Text + Position (bbox) als JSON. Bilder + PDF.
Author: Keyvan Hardani
License-Expression: Apache-2.0
Project-URL: Homepage, https://german-ocr.de
Project-URL: Source, https://github.com/Keyvanhardani/g-ocr
Keywords: ocr,german,deutsch,document,invoice,rechnung,bbox,onnx,cpu
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Image Recognition
Classifier: Operating System :: OS Independent
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: NOTICE
Requires-Dist: onnxruntime>=1.16
Requires-Dist: numpy
Requires-Dist: opencv-python-headless
Requires-Dist: Pillow
Requires-Dist: pyclipper
Requires-Dist: shapely
Requires-Dist: huggingface_hub
Provides-Extra: pdf
Requires-Dist: pypdfium2>=4; extra == "pdf"
Provides-Extra: all
Requires-Dist: pypdfium2>=4; extra == "all"
Dynamic: license-file

# GOCR — schnelle, kleine deutsche OCR-/Vision-Schicht (CPU)

Liest ein **ganzes Dokument** zu **Text + Position (bbox)** als strukturiertes JSON —
**~38 MB, reine CPU, kein GPU**. Gedacht als **OCR-/Vision-Schicht für (text-only) LLM-Pipelines**
und als **Tooling**: präzise Layout-Boxen + Text rein → dein LLM macht Verständnis/Extraktion.

```bash
pip install g-ocr           # Bilder: png/jpg/webp/tiff/bmp ...
pip install "g-ocr[pdf]"    # + PDF-Support (optionales Plugin)
```
```python
import g_ocr
ocr = g_ocr.from_pretrained()
res = ocr.read("dokument.png")            # ein Bild      -> {text, regions:[{text, box, quad, score}]}
doc = ocr.read_document("rechnung.pdf")   # PDF/mehrseitig -> {n_pages, pages:[...], text}
```

## Stärken
- 🎯 **Präzise Bounding-Boxes**, ganzes Dokument, Lesereihenfolge → strukturiertes JSON
- ⚡ **CPU, bis ~16× schneller als EasyOCR** — kein GPU
- 📦 **~38 MB** · 🧱 **Fraktur-robust** · on-prem/DSGVO · 🤖 **LLM-ready**
- 🗂️ **Bilder (png/jpg/webp/tiff/bmp …) + PDF** (bis ~500 Seiten) → ein API-Aufruf, JSON pro Seite

## Benchmarks (anerkannte Sets, CPU)
![GOCR Benchmarks](assets/gocr_benchmarks.png)

**Scene-Text** (Word Accuracy ↑): IIIT5K **93,2 %** · ICDAR2013 **94,1 %** · ICDAR2015 67,6 % — IIIT5K klar vor EasyOCR (68,2 %).

**Dokument-OCR** (CER ↓ / BoW ↓) — Harness [agentic-ai-forge/ocr-benchmark-2025](https://github.com/agentic-ai-forge/ocr-benchmark-2025):

| Engine | SROIE CER | FUNSD CER | SROIE BoW | FUNSD BoW |
|---|--:|--:|--:|--:|
| PaddleOCR | **15,2** | **20,3** | **25,8** | **50,5** |
| **GOCR** | 18,9 | 22,4 | 98,9 | 130,3 |
| EasyOCR | 20,4 | 26,4 | 81,1 | 102,1 |
| Tesseract | 22,6 | 32,4 | 70,2 | 88,2 |
| OCR.space | 44,3 | 48,2 | 73,3 | 84,8 |

**Einordnung:** Auf Dokument-**CER #2 von 5** — vor EasyOCR, Tesseract & OCR.space, knapp hinter PaddleOCR,
bei ~38 MB auf reiner CPU. Beim Bag-of-Words liegt GOCR zurück (Wort-Spacing der aktuellen Gewichte — Roadmap).
Fraktur (NewsEye) ≈3× besser als EasyOCR; bei rein-modernem Deutsch führen Spezial-Engines (Umlaut-Lücke).
*FUNSD = exakte 25 Referenz-Samples, SROIE = 60er-Stichprobe; gescort mit der `metrics.py` des Referenz-Harness.*

## CLI
```bash
g-ocr dokument.png              # JSON (text + box + quad)
g-ocr rechnung.pdf              # PDF -> JSON je Seite (Plugin: g-ocr[pdf])
g-ocr dokument.png --text-only  # nur Text (Lesereihenfolge)
```

## Links
- 🤗 Modell + Card: https://huggingface.co/Keyven/g-ocr
- 🖥️ Demo: https://huggingface.co/spaces/Keyven/GOCR-Demo
- 🌐 https://german-ocr.de

## Lizenz
Apache-2.0 — siehe [`LICENSE`](LICENSE) und [`NOTICE`](NOTICE).
