An intelligent web application that uses Google's Vertex AI (Gemini) to analyze P&ID (Piping and Instrumentation Diagram) images and extract structured data. Now featuring an Interactive Canvas for complete P&ID design capabilities!
π Try it now: https://pid-digitizer-app-4.streamlit.app/
- Advanced AI Detection: Uses Google's Gemini 2.5 Pro model for accurate P&ID interpretation
- Comprehensive Component Recognition: Detects equipment, instrumentation, valves, lines, junctions, safety devices
- Smart Connection Detection: Automatically identifies process connections and control relationships
- Enhanced Line Detection: Improved algorithm generates more comprehensive process flow diagrams
- Real-time Processing: Fast analysis with progress indicators
- Component Palette: Add equipment, instrumentation, valves, junctions, safety devices
- Drag & Drop: Position components anywhere on the canvas
- Line Drawing Tool: Draw connections between components with arrow heads
- Zoom & Pan: Full navigation controls (scroll wheel zoom, Ctrl+drag pan, dedicated pan tool)
- Component Renaming: Double-click or use sidebar editor to rename components
- Design Modes: Switch between Design Mode (editing) and View Mode (clean display)
- Save/Load Designs: Persist your custom designs across sessions
- Interactive Knowledge Graph: Drag nodes, zoom, hover for component details
- Visual AI Detections: Original image with AI-detected bounding boxes
- Orthogonal Routing: Clean L-shaped connections for professional appearance
- Multiple View Modes: Design mode for editing, view mode for presentation
- Real-time Updates: Changes immediately reflected in all views
- PDF Export: Professional P&ID diagrams with both AI-detected and user-added components
- Multiple Formats: JSON, CSV, XML export options
- Custom Metadata: Add drawing name, number, system number, revision
- Complete Integration: PDFs include both AI analysis and manual design work
- High-Quality Output: 300 DPI PDFs suitable for professional use
- Frontend: Streamlit with custom HTML5 Canvas
- AI/ML: Google Vertex AI (Gemini 2.5 Pro)
- Graphics: Fabric.js for interactive canvas, Pyvis for network visualization
- Image Processing: OpenCV, PIL
- Data Visualization: NetworkX, Matplotlib
- Data Processing: Pandas, NumPy
- PDF Generation: Matplotlib with high-DPI output
- Upload P&ID image (PNG, JPG, JPEG)
- AI analyzes and extracts components automatically
- View original image with AI-detected bounding boxes
- Switch to Design Mode for editing
- Add missing components from the palette
- Draw connections between components
- Rename and position components as needed
- Switch to View Mode for clean presentation
- Generate PDF with both AI-detected and user-added components
- Download in multiple formats (JSON, CSV, XML)
-
Clone the repository:
git clone https://github.com/your-repo/PID-Digitizer-with-Editable-Graph.git cd PID-Digitizer-with-Editable-Graph -
Install dependencies:
pip install -r requirements.txt
-
Set up Google Cloud credentials:
- Create a Google Cloud project
- Enable Vertex AI API
- Create a service account with Vertex AI permissions
- Set environment variables:
export GOOGLE_CLOUD_PROJECT_ID="your-project-id" export GOOGLE_CLOUD_LOCATION="us-central1" export GOOGLE_CLOUD_MODEL_ID="gemini-2.5-pro"
-
Run the application:
streamlit run app.py
- Fork this repository
- Set up Google Cloud project (see detailed instructions in DEPLOYMENT.md)
- Deploy to Streamlit Cloud:
- Go to share.streamlit.io
- Connect your GitHub repository
- Configure secrets with your Google Cloud project details
- Deploy!
The application extracts and manages the following data categories:
- Equipment: Pumps, tanks, vessels, reactors, heat exchangers
- Instrumentation: Pressure indicators, temperature sensors, flow meters, controllers
- Lines: Process piping, instrument lines, electrical connections
- Valves: Control valves, check valves, safety valves, isolation valves
- Junctions: Pipe intersections, tees, crosses, manifolds
- Control Relationships: Control loops, signal connections, feedback systems
- Annotations: Text labels, notes, specifications
- Safety Devices: Relief valves, rupture discs, safety systems
- Custom Equipment: Add equipment not detected by AI
- Additional Instrumentation: Add sensors, indicators, controllers
- Manual Connections: Draw process flow connections
- Custom Labels: Rename and customize component labels
- Equipment: π Pumps, vessels, tanks, reactors
- Instrumentation: π Pressure indicators, temperature sensors, flow meters
- Valves: π§ Control valves, check valves, safety valves
- Junctions: π Pipe junctions, tees, crosses
- Safety Devices: π‘οΈ Relief valves, rupture discs, safety systems
- π±οΈ Select/Move: Select and reposition components
- β Pan: Pan around the canvas (also Ctrl+drag or middle mouse)
- π Draw Line: Draw connections with arrow heads
- ποΈ Delete: Remove unwanted components or connections
- Scroll Wheel: Zoom in/out
- Ctrl + Drag: Pan around canvas
- Middle Mouse: Pan around canvas
- π+ / π-: Manual zoom controls
- π Reset: Reset zoom and position
- πΎ Save Design: Save your canvas layout
- π Load Design: Restore previously saved designs
- βοΈ Component Editor: Rename components via sidebar
- Double-click: Rename components directly on canvas
- Analysis Time: 10-30 seconds per image (depending on complexity)
- Image Size: Optimized for images up to 10MB
- Supported Formats: PNG, JPG, JPEG
- Canvas Performance: Smooth interaction with up to 100+ components
- Export Quality: 300 DPI PDFs for professional use
- Real-time Updates: Immediate visual feedback for all operations
GOOGLE_CLOUD_PROJECT_ID: Your Google Cloud project IDGOOGLE_CLOUD_LOCATION: GCP region (default: us-central1)GOOGLE_CLOUD_MODEL_ID: AI model (default: gemini-2.5-pro)
Configure in Streamlit Cloud dashboard:
[gcp]
project_id = "your-project-id"
location = "us-central1"
model_id = "gemini-2.5-pro"- No Data Storage: Images are processed in memory and not stored permanently
- Secure Processing: All AI processing happens through Google Cloud Vertex AI
- Credential Management: Google Cloud credentials are securely managed
- Temporary Files: All temporary files are automatically cleaned up
- Session Privacy: User designs are maintained only during the session
- P&ID Digitization: Convert paper drawings to digital format
- Design Enhancement: Add missing components to existing P&IDs
- Documentation: Generate professional PDFs for client delivery
- Quality Control: Verify completeness of process diagrams
- Asset Management: Digitize legacy P&ID drawings
- Maintenance Planning: Create accurate process flow diagrams
- Training Materials: Generate clear, interactive process diagrams
- Compliance: Ensure P&IDs meet industry standards
- Learning Tools: Interactive P&ID creation and analysis
- Research Projects: Analyze process diagrams for academic research
- Student Projects: Create professional-quality P&ID diagrams
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Live Demo: https://pid-digitizer-app-4.streamlit.app/
- Issues: Report bugs and feature requests on GitHub Issues
- Documentation: Check DEPLOYMENT.md for detailed setup instructions
- Interactive Canvas Guide: See INTERACTIVE_CANVAS_README.md for detailed canvas features
- Community: Join our discussions in GitHub Discussions
- β Interactive Canvas: Complete P&ID design capabilities
- β Enhanced Line Detection: More comprehensive connection generation
- β Professional PDF Export: High-quality diagrams with custom metadata
- β Component Management: Add, rename, and position components
- β Advanced Navigation: Zoom, pan, and view controls
- β Design Persistence: Save and load custom designs
- β Real-time Integration: Seamless AI + manual design workflow
- β Fabric.js Integration: Professional canvas graphics
- β State Management: Robust session persistence
- β Event Handling: Smooth user interactions
- β Performance Optimization: Efficient rendering and updates
- Google Cloud Vertex AI team for the powerful Gemini model
- Streamlit team for the excellent web framework
- Fabric.js community for the interactive canvas capabilities
- OpenCV community for image processing capabilities
- Pyvis and NetworkX teams for network visualization
π Star this repository if you find it useful!
π Try the live demo: https://pid-digitizer-app-4.streamlit.app/