RF-DETR P&ID Symbol Detector
A fine-tuned RF-DETR model for detecting Process & Instrumentation Diagram (P&ID) symbols.
The model was developed as part of the paper:
Towards Automated P&ID Digitization: Graph-Based OCR Consolidation and Global Symbol–Tag Association
Accepted at ACM Symposium on Document Engineering (DocEng 2026).
The detector recognizes the graphical symbols appearing in industrial P&IDs and is intended as the first stage of a complete P&ID digitization pipeline.
Training
The model was fine-tuned for 10 epochs on a custom P&ID symbol dataset containing 32 symbol classes. During training, both the base model and its Exponential Moving Average (EMA) weights were monitored. The EMA model was selected as the final checkpoint because it consistently achieved higher detection performance.
Detected Classes
The model detects the following classes:
| ID | Class |
|---|---|
| 0 | Not_used |
| 1 | Gate_Valve |
| 2 | Ball_Valve |
| 3 | Globe_valve_NO |
| 4 | Gate_valve_NO |
| 5 | Globe_valve_NO |
| 6 | Butterfly_valve |
| 7 | Plug_valve |
| 8 | Check_valve |
| 9 | Diaphragm_valve |
| 10 | Needle_valve |
| 11 | Half_Filled_Gate_Valve |
| 12 | Gate_Valve_NC |
| 13 | Globle_valve_NC |
| 14 | Control_Valve |
| 15 | Rotary_Valve |
| 16 | Ball_valve_NC |
| 17 | Paddle_blind |
| 18 | Spectacle_blind_Closed |
| 19 | Spectacle_blind_Open |
| 20 | Reducer |
| 21 | Flange_or_Nozzle |
| 22 | Rupture_disk |
| 23 | Pipe_Insulation_or_Tracing |
| 24 | Flow_Arrow |
| 25 | Sight_glass |
| 26 | Instrument_Field |
| 27 | Instrument_Field |
| 28 | Instrument_Panel |
| 29 | Instrument_Aux_Panel |
| 30 | Box |
| 31 | Instrument_Panel |
| 32 | Box |
Installation
pip install rfdetr supervision
For tiled inference:
pip install sahi
Load the model
from rfdetr import RFDETRBase
model = RFDETRBase(
pretrain_weights="checkpoint_best_total.pth"
)
Inference (without SAHI)
import cv2
import supervision as sv
image = cv2.imread("image.png")
detections = model.predict(
image,
threshold=0.5
)
labels = [
f"{CLASS_NAMES[c]} {conf:.2f}"
for c, conf in zip(
detections.class_id,
detections.confidence
)
]
annotated = image.copy()
annotated = sv.BoxAnnotator().annotate(
annotated,
detections
)
annotated = sv.LabelAnnotator().annotate(
annotated,
detections,
labels
)
sv.plot_image(annotated)
Inference using SAHI
For very large engineering drawings (typically PDF pages rendered at high resolution), tiled inference significantly improves recall.
Recommended parameters:
- Slice size:
1280 × 1280 - Overlap:
20%
from sahi import AutoDetectionModel
from sahi.predict import get_sliced_prediction
detection_model = AutoDetectionModel.from_pretrained(
model_type="roboflow",
model=model,
confidence_threshold=0.5,
category_mapping=CLASS_NAMES,
device="cuda",
)
result = get_sliced_prediction(
image,
detection_model=detection_model,
slice_height=1280,
slice_width=1280,
overlap_height_ratio=0.2,
overlap_width_ratio=0.2,
)
The resulting detections are available in
result.object_prediction_list
or can be converted into Supervision detections for visualization.
Example
Without SAHI:
Large drawings may miss small symbols.
With SAHI:
Large drawings are processed tile-by-tile, improving the detection of small symbols and densely packed regions.
📊 Test Performance
Overall Performance
| Metric | Score |
|---|---|
| mAP@0.50:0.95 | 97.89% |
| mAP@0.50 | 99.96% |
| Precision | 99.97% |
| Recall | 99.00% |
Per-Class Performance
| Class | mAP@50:95 | mAP@50 | Precision | Recall |
|---|---|---|---|---|
| Gate_Valve | 0.9906 | 1.0000 | 1.0000 | 0.99 |
| Ball_Valve | 0.9908 | 0.9999 | 1.0000 | 0.99 |
| Globe_valve_NO | 0.9904 | 1.0000 | 1.0000 | 0.99 |
| Gate_valve_NO | 0.9896 | 1.0000 | 1.0000 | 0.99 |
| Butterfly_valve | 0.9751 | 1.0000 | 1.0000 | 0.99 |
| Plug valve | 0.9775 | 1.0000 | 1.0000 | 0.99 |
| Check_valve | 0.9805 | 1.0000 | 1.0000 | 0.99 |
| Diaphragm_valve | 0.9812 | 1.0000 | 1.0000 | 0.99 |
| Needle_valve | 0.9950 | 1.0000 | 1.0000 | 0.99 |
| Half_Filled_Gate_Valve | 0.9915 | 1.0000 | 1.0000 | 0.99 |
| Gate_Valve_NC | 0.9881 | 1.0000 | 1.0000 | 0.99 |
| Globle_valve_NC | 0.9913 | 1.0000 | 1.0000 | 0.99 |
| Control_Valve | 1.0000 | 1.0000 | 1.0000 | 0.99 |
| Rotary_Valve | 0.9519 | 1.0000 | 1.0000 | 0.99 |
| Ball_valve_NC | 0.9608 | 1.0000 | 1.0000 | 0.99 |
| Paddle_blind | 0.9606 | 1.0000 | 1.0000 | 0.99 |
| Spectacle_blind_Closed | 0.9627 | 1.0000 | 1.0000 | 0.99 |
| Spectacle_blind_Open | 0.9651 | 0.9999 | 1.0000 | 0.99 |
| Reducer | 0.9864 | 1.0000 | 1.0000 | 0.99 |
| Flange_or_Nozzle | 0.9445 | 0.9901 | 1.0000 | 0.99 |
| Rupture_disk | 0.9843 | 0.9997 | 1.0000 | 0.99 |
| Pipe_Insulation_or_Tracing | 0.9864 | 1.0000 | 1.0000 | 0.99 |
| Flow_Arrow | 0.9447 | 1.0000 | 1.0000 | 0.99 |
| sight_glass | 0.9901 | 1.0000 | 1.0000 | 0.99 |
| Instrument_Field | 0.9881 | 0.9998 | 0.9982 | 0.99 |
| Instrument_Panel | 0.9890 | 0.9999 | 0.9947 | 0.99 |
| Instrument_Aux_Panel | 0.9875 | 0.9999 | 0.9982 | 0.99 |
| Box | 0.9482 | 1.0000 | 0.9981 | 0.99 |
🚀 Highlights
- 33 P&ID symbol classes
- mAP@50: 99.96%
- mAP@50:95: 97.89%
- Precision: 99.97%
- Recall: 99.00%
- Control Valve achieved perfect detection performance (100% mAP).
- More than 85% of the classes achieved a mAP@50:95 greater than 98%.
- The EMA model consistently outperformed the base model during training and was selected as the final released checkpoint.
- Optimized for high-resolution P&ID drawings and compatible with SAHI for sliced inference on large engineering diagrams.
Citation
If you use this model in your research, please cite:
@inproceedings{10.1145/3820755.3832800,
author = {Dimitri Romaric, Nguinwa Mbakop and Marinai, Simone},
title = {Towards Automated P&ID Digitization: Graph-Based OCR Consolidation and Global Symbol-Tag Association},
year = {2026},
isbn = {9798400727863},
publisher = {Association for Computing Machinery},
address = {New York, NY, USA},
url = {https://doi.org/10.1145/3820755.3832800},
doi = {10.1145/3820755.3832800},
abstract = {Piping and Instrumentation Diagrams (P&IDs) are essential engineering documents, but many remain available only as scanned PDFs, limiting their integration into digital workflows. Automatic extraction of structured information from these drawings is challenging due to large document sizes, small text annotations, and ambiguous symbol-tag relationships.This paper presents an end-to-end framework for automatic instrument-tag extraction and association from scanned P&IDs. A tiled OCR strategy with graph-based text merging improves text completeness and reconstructs fragmented engineering tags. For symbol detection, an RF-DETR model fine-tuned on the Dataset-P&ID benchmark achieves 99.96\% mAP@50 and 99.97\% precision, while SAHI-based inference slicing improves performance on large drawings.To automate symbol-tag association, we formulate the problem as a minimum-cost bipartite matching task that combines geometric, semantic, and spatial cues and solves it globally using the Hungarian algorithm. Results on Dataset-P&ID demonstrate accurate tag reconstruction, highly reliable symbol-tag associations, and a substantial reduction in manual annotation effort, providing an effective foundation for large-scale P&ID digitization. The code is available at https://github.com/dimitri009/STA.},
booktitle = {Proceedings of the 2026 ACM Symposium on Document Engineering},
articleno = {26},
numpages = {4},
keywords = {Document Digitization, OCR, Engineering Drawing Analysis, Symbol Detection, Information Extraction, Hungarian Algorithm},
location = {
},
series = {DocEng '26}
}
Acknowledgements
This model is built upon the excellent RF-DETR object detector and supports tiled inference through SAHI.
- RF-DETR: https://github.com/roboflow/rf-detr
- SAHI: https://github.com/obss/sahi
License
Please refer to the license accompanying this repository.