CoolFace
Apppublic

colin1201/Latin-proofreading

sourceHugging Faceupdated 5mo agoView on Hugging Face
0likes
App README

Latin Text Proofreading System

A Hugging Face Spaces Gradio app for reviewing Latin OCR output against LLM-corrected text with image alignment.

Features

  • Upload OCR text (.txt) and LLM-proofread text (.txt)
  • Upload scanned page images (multiple files)
  • Optional exact line-to-image alignment with:
  • bbox JSON
  • hOCR (.hocr, .html, .xhtml)
  • ALTO XML (.xml)
  • Side-by-side proofreading UI:
  • Left: scanned image with focused line box
  • Right: OCR line, highlighted LLM changes, editable final text
  • Review actions:
  • Accept (use LLM line)
  • Reject (use OCR line)
  • Save manual edit
  • Token-level selective acceptance for changed tokens
  • Jump to next unresolved changed line
  • Accept all unchanged lines
  • Export as one ZIP package:
  • final_proofread.txt
  • review_log.json

Files

  • app.py - Main Gradio application
  • requirements.txt - Python dependencies
  • sample_bbox.json - Example bbox input format

Quick Start (Local)

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

Hugging Face Spaces Setup

  1. 1.Create a new Gradio Space.
  2. 2.Upload:
  3. 3.app.py
  4. 4.requirements.txt
  5. 5.README.md
  6. 6.Commit changes and let Space build.

The app should launch automatically with demo.launch().

Input Format Notes

OCR and LLM text files

  • Plain UTF-8 .txt files
  • Each line is treated as one review unit
  • Line alignment is robust to insertions/deletions

Optional bbox JSON

Use one of these shapes:

json
{
  "pages": [
    {
      "page_id": 0,
      "line_bboxes": [[50, 110, 980, 155], [48, 160, 985, 205]]
    },
    {
      "page_id": 1,
      "line_bboxes": [[55, 100, 975, 145]]
    }
  ]
}

Or:

json
{
  "0": [[50, 110, 980, 155], [48, 160, 985, 205]],
  "1": [[55, 100, 975, 145]]
}

Coordinates are pixel values in [x0, y0, x1, y1] order for each page image.

Optional OCR layout files (auto bbox extraction)

You can upload either:

  • hOCR file (.hocr, .html, .htm, .xhtml) with ocr_page / ocr_line and bbox values
  • ALTO XML (.xml) using Page + TextLine with HPOS, VPOS, WIDTH, HEIGHT

The app extracts line boxes in page order and uses them for image highlighting. If both bbox JSON and layout file are provided, bbox JSON is used first.

Export Output

When you click Export Final Package (.zip), the app generates:

  • final_proofread.txt: consolidated finalized text in reading order
  • review_log.json: complete per-line audit log (status, OCR/LLM/final text, page, bbox if available)

Notes

  • If neither bbox JSON nor valid hOCR/ALTO layout is provided, the app uses a top-to-bottom estimated line band fallback.
  • For best scholarly reproducibility, keep review_log.json with your final text.

Manual Steps You Need

  • You must provide your own OCR and LLM text files (for example sample_ocr.txt and sample_llm.txt, or your real corpus files).
  • For exact line highlighting, provide at least one of:
  • bbox JSON, or
  • hOCR/ALTO layout file.
  • Upload page images in the same reading order as the text lines/pages.