GCME AI-Recognition Network for Engineering Technology
Precision in Every Connection
GARNET is an AI-powered tool designed to automate symbol detection, classification, and connectivity analysis in Piping and Instrumentation Diagrams (P&IDs). Built for engineers and maintenance teams, it combines state-of-the-art object detection (YOLOv8) with graph-based analytics to transform P&ID workflows.
- Symbol Detection: Identify valves (gate, globe, check), pumps, tanks, and more using YOLOv8.
- Automated Counting: Generate counts for each symbol type in a P&ID.
- Graph-Based Analysis: Model P&IDs as networks to analyze connectivity, critical paths, and system dependencies.
- Export Results: Export detection results and connectivity graphs to CSV, PDF, or JSON.
- User-Friendly Interface: Simple CLI and scriptable API for integration into existing workflows.
-
Clone the Repository:
git clone https://github.com/your-username/GARNET.git cd GARNET
-
Install Dependencies:
pip install -r requirements.txt
Run the web interface to upload P&IDs, select models, and view results in real time:
-
Start the Web Server:
uvicorn main:app --reload
Access the app at
http://localhost:8000
. -
Using the Web Interface:
- Upload a P&ID: Select an image file (JPG/PNG).
- Model Configuration: Choose a model type (e.g., YOLOv5, YOLOv8) and upload custom weights (
.pt
file). - Run Inference: Click "Submit" to detect symbols and display results.
- Results: View annotated images, symbol counts, and download reports (CSV/JSON).
Run inference on multiple P&IDs in a folder using predict_images.py
:
-
Command-Line Arguments:
python predict_images.py \ --image_path path/to/pids_folder \ --model_type yolov8 \ --model_path path/to/model_weights.pt \ --output_path results/
-
Output:
- Annotated images (saved in output_path).
- CSV file with symbol counts (
output_path/symbol_counts.csv
).
Example code snippet:
from garnet.inference import predict_images
predict_images(
image_path="path/to/pids_folder",
model_type="yolov8",
model_path="path/to/model_weights.pt",
output_path="results/"
)
Based on our reference methodology, the following pipeline will be implemented:
-
Preprocessing
- Load and normalize the P&ID image.
- Optional: Denoising, binarization, and removal of scanning artifacts.
-
Object Detection
- Detect P&ID symbols using YOLOv11/YOLOv8.
- Classes include valves, pumps, tanks, instruments, and custom symbols.
- Export detections as bounding boxes (YOLO or COCO format).
-
Text Recognition
- Use EasyOCR or PaddleOCR for text extraction (supports horizontal and vertical text).
- Merge OCR results from multiple rotations.
- Output text annotations (JSON).
-
Line Extraction
- Remove detected symbols and text areas from the image to isolate pipelines.
- Apply morphological operations to extract lines (handles 90° turns and intersections).
- Merge fragmented line segments.
-
Line-Symbol Connection
- Detect intersection points between line segments and symbol bounding boxes.
- Assign connectivity relationships between symbols and lines.
-
Graph Construction
- Convert connected symbols and pipelines into a NetworkX graph.
- Nodes = symbols (with attributes like tag, type).
- Edges = pipelines (with attributes like length, type).
-
Graph Analysis
- Perform connectivity analysis: critical paths, loops, flow direction inference.
- Detect isolated components or redundant loops.
-
DEXPI Export
- Convert the annotated P&ID into DEXPI-compliant XML.
- Include geometry, symbol metadata, and connectivity.
-
Visualization and Reporting
- Overlay detected objects, text, and pipelines on the original P&ID.
- Export results as PNG/PDF/JSON.
- Provide interactive graph visualization (future feature).
Note: This pipeline is designed to be modular, so each step can be run independently or as part of the full digitization workflow.
Reference: Adapted from "End-to-End Digitization of Image Format Piping and Instrumentation Diagrams" (2024).
Note: A staged, runnable pipeline with CLI is available in garnet/pid_extractor.py
. See garnet/README_pid_pipeline.md
for usage, stages, tuning knobs, and output artifacts.
To train custom YOLO models for P&ID symbols:
yolo train \
data=data.yaml \
model=yolov8n.pt \
epochs=100 \
imgsz=640 \
batch=16
GARNET uses the YOLOv8 dataset format. Example structure:
dataset/
├── train/
│ ├── images/ # P&ID images (.jpg, .png)
│ └── labels/ # YOLO-format labels (.txt)
├── val/
│ ├── images/
│ └── labels/
└── data.yaml # Dataset config (class names, paths)
Example data.yaml
:
train: dataset/train/images
val: dataset/val/images
nc: 6 # Number of classes
names: ["valve", "gate_valve", "globe_valve", "check_valve", "pump", "tank"]
Detection | Graph Analysis |
---|---|
![]() |
![]() |
Example output: Symbol counts and connectivity graph for a P&ID.
Additional planned outcomes from the GARNET project include:
- MTO for Valves: Automated generation of material take-off lists for all detected valve types, including specifications and quantities.
- Line List: Extraction and tabulation of pipeline data, including line tags, sizes, service, and connected equipment.
Contributions are welcome! Please fork the repository and submit a pull request.
For major changes, open an issue first to discuss your ideas.
This project is licensed under the MIT License. See LICENSE for details.
For questions or collaborations, contact:
- Your Name - [email protected]
- GCME (GC Maintenance and Engineering Co., Ltd.) - www.gcme.com