Case study. Production pipeline that reads industrial P&ID drawings (Piping & Instrumentation Diagrams) and extracts every instrument bubble and equipment tag into structured JSON — running fully offline on a locked-down Windows machine, no GPU required. Client code and data are private under agreement; this page documents the architecture and measured results.
Industrial plants (power, chemical, oil & gas) hold tens of thousands of legacy P&ID drawings. Extracting the instrument tags from them for maintenance systems is done by hand — typically 2–4 hours per drawing — and the environment makes cloud AI impossible: air-gapped machines, no internet, no GPU. This engagement targeted a 30,000+ drawing backlog.
PDF (vector or scanned)
│
├─► title-block classification ──► drawing family · manufacturer · number · title
│
├─► instrument-bubble detection ──► OpenCV Hough circles (no training data needed)
│
├─► tag reading
│ · vector PDFs: direct text-layer extraction (exact, no OCR)
│ · scanned: CPU OCR (RapidOCR-ONNX) / VLM (Qwen2.5-VL, 4-bit) for tiny stacked text
│
├─► confusion-aware lexicon correction ──► weighted Levenshtein snapping OCR near-misses
│ (1↔I · 0↔O · 8↔B · 5↔S · 2↔Z) to the plant's valid-tag master list
│
├─► ISA-5.1 tag parsing ──► PREFIX-TYPE-NUMBER + instrument-vs-equipment inference
│
└─► outputs ──► client-schema JSON · annotated PNG overlays · accuracy scorecard
Two execution paths share one orchestrator: a CPU path that runs on the locked production box, and an optional GPU path (free Colab/Kaggle T4) where a 4-bit-quantized vision-language model reads degraded bubble text that CPU OCR can't.
| Capability | Result |
|---|---|
| Instrument-bubble detection recall | 97–99% |
| Drawing classification (family / manufacturer / number / title) | 100% |
| ISA-5.1 tag parsing | 100% |
| Recovery of OCR near-misses via lexicon correction | 100% |
| VLM reads on degraded scanned input | ~86% |
| Text-layer extraction on vector PDFs | exact (16/16 on validation set) |
Every claim above comes from a scorecard module that measures recall/precision/exact-match against client-provided ground-truth files — accuracy is demonstrated per batch, not promised.
- No training data — bubble detection had to work geometrically (Hough circles) rather than via a trained detector
- Air-gapped constraint — every dependency CPU-only, permissively licensed, installable offline
- Tiny, degraded text — stacked two-line tags inside 30 px bubbles defeat classic OCR; solved with a quantized VLM + snapping output to the plant's 22k-tag master list so a near-miss becomes an exact match
- Auditability — every extracted tag carries its bounding box (in PDF points) and confidence; annotated overlays let reviewers verify visually in seconds
Python · OpenCV · RapidOCR-ONNX · pypdfium2 / pdfminer.six · RapidFuzz · PyTorch · Hugging Face Transformers · Qwen2.5-VL-7B (4-bit, BitsAndBytes) · NumPy · Pillow
Muhammad Maowiz Saleem — GitHub · LinkedIn · maowizsaleem009@gmail.com Related work: step2pdf — CAD → drawing automation · HVAC blueprint takeoff