Skip to content
/ GARNET Public

GCME AI-Recognition Network for Engineering Technology

License

Notifications You must be signed in to change notification settings

may3rd/GARNET

Repository files navigation

🛠️ GARNET: AI-Driven P&ID Symbol Detection and Analysis

GCME AI-Recognition Network for Engineering Technology
Precision in Every Connection

YOLOv8 OpenCV NetworkX

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.


🚀 Features

  • 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.

📦 Installation

  1. Clone the Repository:

    git clone https://github.com/your-username/GARNET.git
    cd GARNET
  2. Install Dependencies:

    pip install -r requirements.txt

🖥️ Usage

1. Web Application (Interactive Inference)

Run the web interface to upload P&IDs, select models, and view results in real time:

  1. Start the Web Server:

    uvicorn main:app --reload

    Access the app at http://localhost:8000.

  2. 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).

Web Interface Demo


2. Batch Inference Script

Run inference on multiple P&IDs in a folder using predict_images.py:

  1. 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/
  2. 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/"
)

3. Todo: Graph-Based Connectivity Analysis (Coming Soon!)

  • Feature: Automatically generate connectivity graphs from P&IDs.
  • Planned Workflow:
    1. Detect symbols and pipelines.
    2. Build a graph network using NetworkX.
    3. Analyze critical paths, cycles, and dependencies.
    4. Export graphs as PNG/PDF or integrate with CAD tools.

4. Model Training (Optional)

To train custom YOLO models for P&ID symbols:

yolo train \
    data=data.yaml \
    model=yolov8n.pt \
    epochs=100 \
    imgsz=640 \
    batch=16

📂 Dataset

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"]

📊 Results

Detection Graph Analysis
Detected Symbols Graph Visualization

Example output: Symbol counts and connectivity graph for a P&ID.


🤝 Contributing

Contributions are welcome! Please fork the repository and submit a pull request.
For major changes, open an issue first to discuss your ideas.


📜 License

This project is licensed under the MIT License. See LICENSE for details.


📧 Contact

For questions or collaborations, contact:

About

GCME AI-Recognition Network for Engineering Technology

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published