Legend AIOil and Gas
6 min read

Reading engineering drawings for process safety

Engineering schematic drawn as blue line art: the kind of drawing Legend AI reads

Client Overview

Per QRA count, down from three engineer-days
15 min
Line-number OCR accuracy, up from 77.76%
99.49%
Isolation procedure precision, validated by the client's Loss Prevention team
96.7%
Average detection F1 on the client's drawings
0.99
Team

Client

Oil and gas operator

Industry

Industry

Oil and gas: NGL and refining

Clock

Deployment

Sealed on-premise instance

Time

Status

Active, second contract, weekly releases

Legend AI turned an oil and gas operator's P&IDs and PFDs into a queryable process graph, and automated three process-safety workflows that ran on manual drawing reads.

The mandate

An oil and gas operator engaged Fastcode to deploy Legend AI, configured to the client's symbol libraries, counting rules and export formats. The brief: automate three workflows that ran on manual drawing reads — component counting for Quantitative Risk Assessment (QRA), transfer of Elementary Process Section (EPS) boundaries from PFDs into P&IDs, and isolation-procedure generation for major equipment. Constraint: a sealed on-premise instance. No drawing, model or annotation leaves the client's infrastructure.

The problem

The client's process-safety workflows run on engineering drawings: legacy sheets from its NGL and refining facilities, scanned or PDF, spanning decades of drafting conventions. Every QRA count, isolation procedure and EPS boundary required engineers to trace symbols, lines and tags by eye. A single QRA count took an engineer three days.

Line drawings defeat models trained on photographs: hundreds of near-identical symbols per sheet, components that differ by a single stroke, text overlapping the lines it labels. Commercial digitisation tools detect some symbols but do not process PFDs, do not detect lines, and do not associate text with the component it names — the step every downstream count depends on. Off-the-shelf OCR read the client's line numbers at 77.76% accuracy. A wrong tag is a wrong risk figure.

The deployment

A four-stage stack, configured per client

Detection, OCR, association and semantic-graph construction, shipped pre-trained. Pre-trained models accelerated ground-truth creation on the client's own sheets; engineers corrected outputs in the review dashboard, and every correction became labelled data for fine-tuning the client's instance. Line-number OCR rose from 77.76% on the base model to 99.49%.

Detection and association

Vector preprocessing parses the PDF's SVG paths directly, catching revision clouds and diamond EPS tags geometrically rather than visually. Small symbols use template matching with non-maximum suppression; instruments use Hough-transform methods; equipment uses DETR-ResNet-50 and RF-DETR, fine-tuned on the client's vessel classes. Association links every text element to its symbol, line or instrument, including flanges beside valves.

The process graph

From the associated detections, Legend AI builds a directed acyclic graph of the process: components as nodes, lines as edges, flow direction propagated from arrowheads and off-page connectors. Each workflow is a query against it — EPS boundaries transferred from PFDs to P&IDs by endpoint matching, QRA counts per EPS under the client's counting rules, isolation procedures for all major equipment.

Review, export and data sovereignty

Engineers review in a dashboard (React and Django, in Docker containers on the client's infrastructure). Corrections re-run the affected analyses and feed fine-tuning. Exports: DEXPI, XML, CSV and PNG. No drawing, model or annotation leaves the client's environment.

The methodology is the subject of a patent application.

Scientific foundation

  1. Automation in Construction · under review

    Digitization and Flow Inference of Pipeline-Based Engineering Diagrams via Graph Construction

    Fastcode AI, co-authored with the client's research organisation. Author list to follow on publication.

    First-party record of this deployment's methodology. Reports average F1 of 0.99 for detection and 0.98 for association.

  2. ECCV 2020

    End-to-End Object Detection with Transformers (DETR)

    Carion, N., Massa, F., Synnaeve, G., Usunier, N., Kirillov, A., Zagoruyko, S.

    Base architecture for equipment detection. Fine-tuned on the client's vessel classes: mAP(0.50) 0.94 at 0.98 mean recall.

  3. arXiv 2025

    RF-DETR

    Preprint.

    Successor detector, evaluated for the expanded 15-class equipment set (pig launchers and receivers, drums, exchangers): mAP(0.50) 0.92 at 0.98 average recall.

  4. AAAI 2023

    TrOCR: Transformer-based Optical Character Recognition with Pre-trained Models

    Li, M., Lv, T., Chen, J., Cui, L., Lu, Y., Florencio, D., Zhang, C., Li, Z., Wei, F.

    OCR backbone. The deployment's central fine-tuning result, 77.76% to 99.49% on client line numbers, is measured against this base model.

Outcomes

Line-number OCR accuracy on the client's drawings
Legend AI, fine-tuned to the client99.49%
Base model77.76%
  • PointerQRA counting: three engineer-days to 15 minutes. Engineers review outputs instead of tracing sheets.
  • PointerIsolation procedures: 96.7% precision and 88.3% recall, validated by the client's Loss Prevention team on its own samples.
  • PointerModel quality on 75 P&IDs and 75 PFDs supplied by the client's subject-matter experts: detection F1 from 0.9477 (lines, the hardest class) to 0.9977 (flanges); text-association F1 up to 0.9986; equipment detection mAP(0.50) 0.94 at 0.98 mean recall.
  • PointerThe client now holds a queryable process graph of its drawings, which it did not have before.
  • PointerStatus: active. Second contract since late 2025, weekly deliveries continuing into 2026. Client engineers operate the pipeline after on-site training.
Against a commercial digitisation tool, on six public P&IDs (F1)
MeasureLegend AICommercial tool
Symbols0.99480.6445
Flanges0.95730.2547
Lines0.9668Not detected
Text associationSupportedNot attempted

The comparison with the commercial tool was measured by Fastcode on six public P&IDs.

Explore More Breakthroughs

Drip Labs
Drip Labs

Drip Labs

AI-powered photoshoots and Virtual Try-ons, delivering on-brand creatives at half the cost of traditional shoots.

Experience DripLabs

logologo
Request an AI summary of Fast Code AI
  • Head Office
  • Jbr Tech Park, Plot No. 77,
    6th Rd, EPIP Zone,
    Whitefield, Bengaluru,
    Karnataka 560066
  • UAE Office
  • First Floor, Incubator Building,
    Masdar City SE4505,
    Abu Dhabi
  • German Office
  • Königstraße 26
    Stuttgart 70173
  • Email
  • arjun@fastcode.ai
  • Phone
  • +91 85530 38132

© Copyright Fast Code AI 2026. All Rights Reserved