# marine-pid-digitization **Repository Path**: dlml2/marine-pid-digitization ## Basic Information - **Project Name**: marine-pid-digitization - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-09-09 - **Last Updated**: 2026-09-09 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Marine P&ID Digitization Tool Converts PDF/image-based Piping & Instrumentation Diagrams into a queryable graph database that answers: - **"How do I line up from Tank A to Tank B?"** - **"Main pump failed — what's the alternative route?"** --- ## Project Status **Current Phase**: Phase 1 — Data Preparation --- ## Quick Start ```bash # 1. Create virtual environment (Python 3.11 required) pyenv local 3.11.0 python -m venv venv source venv/bin/activate # 2. Install dependencies pip install -r requirements.txt # 3. Export a P&ID page as a high-res JPG (300 DPI), place in data/raw/ # 4. Slice into tiles python scripts/tile_generator.py --input data/raw/hfo_system.jpg --split # 5. Label tiles in LabelImg # - Open Dir: data/tiles/images/train/ # - Change Save Dir: data/tiles/labels/train/ # - Format: YOLO labelImg # 6. Train YOLOv8 python scripts/train_yolo.py # 7. Detect symbols + extract OCR tags python scripts/ocr_extract.py --tiles data/tiles/images/train/ --page hfo_system # 8. Import into Neo4j python scripts/graph_import.py --all ``` --- ## Folder Structure ``` Pipeline processing/ ├── README.md ├── requirements.txt │ ├── config/ │ ├── classes.txt ← 25 marine symbol classes │ └── data.yaml ← YOLOv8 dataset config │ ├── data/ │ ├── raw/ ← Original high-res JPG exports from PDF │ ├── tiles/ │ │ ├── images/ │ │ │ ├── train/ ← 80% of labeled tiles (LabelImg Open Dir) │ │ │ └── val/ ← 20% validation tiles │ │ └── labels/ │ │ ├── train/ ← YOLO .txt label files (LabelImg Save Dir) │ │ └── val/ │ └── exports/ │ ├── tile_coordinate_log.csv ← Maps tile → source page + offsets │ └── component_maps/ ← Per-page JSON (output of ocr_extract.py) │ ├── models/ │ └── weights/ │ └── pid_detector_best.pt ← Best trained model weights │ ├── scripts/ │ ├── tile_generator.py ← Phase 1: Slice large P&IDs into tiles │ ├── train_yolo.py ← Phase 2: Fine-tune YOLOv8 │ ├── ocr_extract.py ← Phase 3: Detect symbols + read tags │ └── graph_import.py ← Phase 4: Load into Neo4j │ ├── notebooks/ ← Jupyter notebooks for experimentation ├── graph/ ← Neo4j query examples and Cypher scripts ├── outputs/ ← Final reports, line-up procedure exports └── plans/ ├── rough.md ← Original Gemini conversation notes └── PID_Digitization_Plan.md ← Full structured implementation plan ``` --- ## Neo4j Queries After importing, open Neo4j Browser at `http://localhost:7474` and run: ```cypher -- Find all pumps MATCH (c:Component {type: "Pump_Centrifugal"}) RETURN c -- Shortest path between two tanks (line-up procedure) MATCH p = shortestPath( (a:Component {id: "TANK_HFO_BUNKER_1"})-[*]-(b:Component {id: "TANK_HFO_SETTLING"}) ) RETURN p -- Alternative route when a pump fails MATCH p = shortestPath( (a:Component)-[*]-(b:Component) ) WHERE NONE(n IN nodes(p) WHERE n.id = "Pump_Centrifugal_0023") RETURN p ``` --- ## Key References - [YOLOv8 Docs](https://docs.ultralytics.com) - [PaddleOCR](https://github.com/PaddlePaddle/PaddleOCR) - [Neo4j Community Edition](https://neo4j.com/download/) - [SAHI — Small Object Detection](https://github.com/obss/sahi) - Full plan: `plans/PID_Digitization_Plan.md`