CoolFace
Apppublic

chmielvu/newspaper-ocr-cpu

sourceHugging Facemitupdated 24d agoView on Hugging Face
0likes
App README

Polish Newspaper OCR (CPU)

A CPU Basic adaptation of Ayaan-Sharif/ocr-layout-detection-poc for scanned Polish newspapers and magazines.

Pipeline

  • —Docling layout analysis with layout_heron_default.
  • —RapidOCR using ONNX Runtime on CPU.
  • —Polish recognition with lang=["pl"].
  • —Full-page OCR for scanned pages.
  • —One worker at a time to fit Hugging Face CPU Basic hardware.
  • —No external OCR API, LLM, or hosted inference service.

CPU Basic provides two vCPUs and 16 GB RAM. The app therefore processes no more than five selected PDF pages per request. Submit consecutive ranges to process a larger document.

Output

The Gradio endpoint is /process_pdf, so it is compatible with the local resumable batch client used by this project.

Each request returns:

  • —Markdown containing the OCR result.
  • —A ZIP download containing <original-stem>.md.
  • —<original-stem>_metadata.json with source pages, OCR configuration, layout configuration, and elapsed time.

The original source PDF is never modified. Space storage is ephemeral; download results after each request.

Page ranges

The UI uses one-based page numbers. Examples:

  • —1-5
  • —7
  • —1,3,5

Blank input selects the first five pages. A request containing more than five pages is rejected.

Local development

bash
pip install -r requirements.txt
python app.py

Models are downloaded by Docling and RapidOCR on first use. Keep the dependency pin and the single-worker queue when deploying to CPU Basic.