Skip to content

abdullah-engg/PID-Digitizer-App

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

28 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

P&ID Digitizer 4.0 - Advanced AI-Powered Process Diagram Analysis

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!

πŸš€ Live Demo

Streamlit App

🌐 Try it now: https://pid-digitizer-app-4.streamlit.app/

✨ Key Features

πŸ€– AI-Powered Analysis

  • 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

🎨 Interactive Canvas (NEW!)

  • 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

πŸ“Š Advanced Visualization

  • 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

πŸ“₯ Comprehensive Export Options

  • 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

πŸ› οΈ Technology Stack

  • 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

🎯 How It Works

1. Upload & Analyze

  • Upload P&ID image (PNG, JPG, JPEG)
  • AI analyzes and extracts components automatically
  • View original image with AI-detected bounding boxes

2. Interactive Design

  • Switch to Design Mode for editing
  • Add missing components from the palette
  • Draw connections between components
  • Rename and position components as needed

3. Export Complete Design

  • Switch to View Mode for clean presentation
  • Generate PDF with both AI-detected and user-added components
  • Download in multiple formats (JSON, CSV, XML)

πŸš€ Quick Start

Local Development

  1. Clone the repository:

    git clone https://github.com/your-repo/PID-Digitizer-with-Editable-Graph.git
    cd PID-Digitizer-with-Editable-Graph
  2. Install dependencies:

    pip install -r requirements.txt
  3. 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"
  4. Run the application:

    streamlit run app.py

Streamlit Cloud Deployment

  1. Fork this repository
  2. Set up Google Cloud project (see detailed instructions in DEPLOYMENT.md)
  3. Deploy to Streamlit Cloud:
    • Go to share.streamlit.io
    • Connect your GitHub repository
    • Configure secrets with your Google Cloud project details
    • Deploy!

πŸ“Š Data Structure

The application extracts and manages the following data categories:

AI-Detected Components

  • 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

User-Added Components

  • 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

🎨 Interactive Canvas Features

Component Palette

  • 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

Drawing Tools

  • πŸ–±οΈ 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

Navigation Controls

  • Scroll Wheel: Zoom in/out
  • Ctrl + Drag: Pan around canvas
  • Middle Mouse: Pan around canvas
  • πŸ”+ / πŸ”-: Manual zoom controls
  • 🏠 Reset: Reset zoom and position

Design Management

  • πŸ’Ύ 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

πŸ“ˆ Performance & Capabilities

  • 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

πŸ”§ Configuration

Environment Variables

  • GOOGLE_CLOUD_PROJECT_ID: Your Google Cloud project ID
  • GOOGLE_CLOUD_LOCATION: GCP region (default: us-central1)
  • GOOGLE_CLOUD_MODEL_ID: AI model (default: gemini-2.5-pro)

Streamlit Secrets

Configure in Streamlit Cloud dashboard:

[gcp]
project_id = "your-project-id"
location = "us-central1"
model_id = "gemini-2.5-pro"

πŸ›‘οΈ Security & Privacy

  • 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

🎯 Use Cases

Engineering Firms

  • 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

Process Industries

  • 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

Educational Institutions

  • Learning Tools: Interactive P&ID creation and analysis
  • Research Projects: Analyze process diagrams for academic research
  • Student Projects: Create professional-quality P&ID diagrams

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ†˜ Support & Documentation

πŸš€ What's New in Version 4.0

Major Enhancements

  • βœ… 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

Technical Improvements

  • βœ… Fabric.js Integration: Professional canvas graphics
  • βœ… State Management: Robust session persistence
  • βœ… Event Handling: Smooth user interactions
  • βœ… Performance Optimization: Efficient rendering and updates

πŸ™ Acknowledgments

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

About

A web application that streamlines the digitization of hand-drawn or printed Piping and Instrumentation Diagrams (P&IDs). It identifies and converts individual components into industry-compliant formats, while also providing an interactive visual editor. Users can modify layouts in-browser and export the final P&ID as a PDF or component files.

Topics

Resources

Stars

10 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors