--- title: Diagram Structure Extractor emoji: 📊 colorFrom: blue colorTo: green sdk: docker app_port: 8000 pinned: false license: mit --- # Diagram Structure Extractor Upload an architecture diagram and get its structure back as schema-valid JSON: every text label, box, arrow, icon, and the relationships between components. Output is a typed Pydantic model, so the JSON parses on every call. **Demo**: the Space opens on a Streamlit app. Upload a diagram or pick one of the samples to see the annotated overlay, the relationship graph and the JSON, with JSON and CSV downloads. The sidebar switches each detector stage. **API** (same host) - `POST /extract` — multipart image upload; returns the typed structure, an annotated PNG, and a flat edge CSV - `GET /health` — liveness - `GET /docs` — interactive API docs **Measured results** (relationship F1; edges are directed, and a double-headed connector counts once each way) - 14 synthetic reference architectures: **1.000** - A real draw.io export: **0.900** - 10 held-out draw.io-style diagrams: **0.789** (0.711 when first scored, before the code-review fixes) - Schema-valid JSON on every input, at every pipeline stage - Detectors: PaddleOCR text (F1 0.962), Canny boxes (1.000), directed-lines arrows (1.000 on the synthetic set), template-matched icons (1.000) Handles draw.io conventions: thin dashed connectors, small and double-headed arrowheads, elbow routing, line labels, icon nodes with captions underneath. Source: https://github.com/Mark007-R/Diagram-Structure-Extractor