Downloads Β· 30 days
0
NH3Connect/rfdetr-pid-detector
rfdetr-pid-detector is a object detection model from NH3Connect. Use it when you need objects located in an image. The card lists the license as apache-2.0.
Downloads Β· 30 days
0
Access
Public
Updated Aug 3, 2026
Repo size
128 MB
Likes
1
Trending 1
Click a slice to open those files.
.pth128 MB Β· 100%
From the Hugging Face model README
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.
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.
<p align="center"> <img src="metrics_plot.png" width="100%"> </p>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 |
pip install rfdetr supervision
For tiled inference:
pip install sahi
from rfdetr import RFDETRBase
model = RFDETRBase(
pretrain_weights="checkpoint_best_total.pth"
)
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)
For very large engineering drawings (typically PDF pages rendered at high resolution), tiled inference significantly improves recall.
Recommended parameters:
1280 Γ 128020%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.
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.
| Metric | Score |
|---|---|
| [email protected]:0.95 | 97.89% |
| [email protected] | 99.96% |
| Precision | 99.97% |
| Recall | 99.00% |
| 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 |
If you use this model in your research, please cite:
@inproceedings{XXXX,
title={Towards Automated P\&ID Digitization: Graph-Based OCR Consolidation and Global Symbol--Tag Association},
author={...},
booktitle={Proceedings of the ACM Symposium on Document Engineering (DocEng)},
year={2026}
}
This model is built upon the excellent RF-DETR object detector and supports tiled inference through SAHI.
Please refer to the license accompanying this repository.