How chirag4862/doclayout-yolo works
DocLayout-YOLO turns an uploaded or CLI-supplied document image into detected layout regions, optional OCR text, and structured results; it can also render annotated images. The Streamlit and CLI entry points both initialize an ONNX session and invoke detection. Detection preprocesses the image, runs inference, and postprocesses boxes; output handling groups detections and optionally extracts text. The README also documents a Python API and configurable class mapping. Edges are limited to relationships shown in the excerpts or README; the model internals and unsampled implementation details are not inferred.
Main entry points: app.py Interactive demo · run_detection.py CLI runner · session.py ONNX session setup · detector.py Layout detector
Components 15
User entry points
- Interactive demo
app.py - CLI runner
scripts/run_detection.py
Layout inference
- Layout detector
layout_detector/detector.py - ONNX Runtime
Output processing
- OCR and JSON builder
layout_detector/utils.py - PaddleOCR
- Detection rendering
layout_detector/detector.py - JSON file writer
layout_detector/utils.py - Structured JSON
- Annotated image
Model resources
- ONNX session setup
layout_detector/session.py - YOLO weights
best.onnx - Class mapping
config/metadata.yaml
Other components
- Document user
- CLI user
Connections 21
- Document user → Interactive demo: uploads image
app.py - CLI user → CLI runner: provides image
scripts/run_detection.py - Interactive demo → ONNX session setup: creates session
app.py - CLI runner → ONNX session setup: creates session
scripts/run_detection.py - ONNX session setup → YOLO weights: loads weights
layout_detector/session.py - ONNX session setup → Class mapping: reads classes
layout_detector/session.py - Interactive demo → Layout detector: runs detection
app.py - CLI runner → Layout detector: runs detection
scripts/run_detection.py - Layout detector → ONNX Runtime: runs inference
layout_detector/detector.py - Interactive demo → OCR and JSON builder: builds OCR output
app.py - CLI runner → OCR and JSON builder: builds OCR output
scripts/run_detection.py - OCR and JSON builder → PaddleOCR: extracts text
layout_detector/utils.py - Interactive demo → PaddleOCR: initializes OCR
app.py - CLI runner → PaddleOCR: initializes OCR
scripts/run_detection.py - Interactive demo → Detection rendering: draws detections
app.py - CLI runner → Detection rendering: draws detections
scripts/run_detection.py - CLI runner → JSON file writer: saves results
scripts/run_detection.py - JSON file writer → Structured JSON: writes JSON
layout_detector/utils.py - Interactive demo → Structured JSON: offers download
app.py - Interactive demo → Annotated image: offers download
app.py - CLI runner → Annotated image: saves image
scripts/run_detection.py