CircuitVision

CircuitVision 🌿

CircuitVision Logo

From picture to simulation. An AI-powered app that automatically analyzes circuit diagrams and generates SPICE netlists.

Live Demo View on GitHub

License: Apache 2.0 Issues Ask DeepWiki

Mahmoud Sameh
Mahmoud Sameh
Jawad Khan
Jawad Khan

📚 Table of Contents

🚀 Overview

CircuitVision is an innovative application designed to bridge the gap between visual electrical circuit diagrams and functional simulations. It intelligently analyzes images of electrical circuits—whether hand-drawn, photographed, or from schematics—and transforms them into SPICE-compatible netlists, providing an easy access to the operating point parameters of the circuit. This project leverages a sophisticated pipeline of fine-tuned and custom-adapted AI models, including YOLOv11 for component detection, an adapted SAM 2 (Segment Anything Model 2) for precise segmentation and intelligent cropping, and Google’s Gemini for its robust OCR ability.

Our goal is to automate the tedious process of manual circuit transcription, enabling engineers, students, and hobbyists to quickly digitize, understand, and simulate electrical circuits with unprecedented ease and accuracy.

✨ Key Features & The Engineering Behind Them

Phase 1: Component Detection
Phase 1: Component Detection Phase 2: Topology Analysis
Phase 2: Topology Analysis Phase 3: Netlist Generation
Phase 3: Netlist Generation Phase 4: Simulation
Phase 4: Simulation

The four phases of the CircuitVision pipeline: Detection, Topology Analysis, Netlist Generation, and Simulation.

👁️ Advanced Component Detection (Fine-Tuned YOLOv11)

📐 Intelligent Cropping & Precise Segmentation (YOLO + SAM 2)

🔗 Custom-Developed Node & Connection Analysis

📝 Automated & Enriched Netlist Generation

🖥️ Intuitive User Interface & Rich Visualization

📈 Our Development Journey & Enhancements

CircuitVision is the culmination of significant research and development in applying and adapting cutting-edge AI to the specialized domain of electrical circuit analysis. We’ve moved beyond off-the-shelf model usage to:

🛠️ Technology Stack

Python PyTorch Streamlit Docker Gemini

🛠️ Setup

  1. Models & API Access:
    • YOLO & SAM 2 Models: Our system relies on specific pre-trained and fine-tuned model weights. Run the provided script to download the necessary model files:
      python download_models.py
      

      This will create models/YOLO and models/SAM2 directories and populate them. Ensure you have requests and gdown installed (pip install requests gdown).

    • Gemini API Key: You will need a Google Gemini API key. Set it as an environment variable GEMINI_API_KEY or configure it within the application as required.
  2. Dependencies: Install all required Python packages:
    pip install -r requirements.txt
    

For a consistent and isolated environment, we recommend using Docker.

  1. Build the Docker Image: From the project root directory (containing the Dockerfile):
    docker build -t circuitvision .
    
  2. Run with Docker Compose (docker-compose.yml): This is often the simplest way to manage multi-container applications or complex setups.
    docker compose up --build
    

    To run in detached mode:

    docker compose up -d --build
    

    (Ensure your GEMINI_API_KEY is available to the Docker environment, e.g., via an .env file used by Docker Compose or by passing it as an environment variable in the docker-compose.yml)

🚀 Usage

  1. Launch Application: Start the CircuitVision Streamlit app (e.g., streamlit run app.py or via Docker).
  2. Upload Image: Use the file uploader to select an image of the electrical circuit you wish to analyze.
  3. Automatic Analysis: The system will automatically:
    • Pre-process the image (EXIF rotation).
    • Perform component detection (YOLO).
    • Segment and crop the circuit (SAM 2).
    • Execute custom node analysis.
    • Generate the initial structural netlist.
    • Query Gemini for component values and types.
    • Produce the final, enriched netlist.

🧠 Training Code

Explore the core training pipelines used to build the intelligence behind CircuitVision:


🙏 Acknowledgements

We extend our deepest gratitude to our supervisor, Prof. Adel Abdennour, for his exceptional guidance, support, and invaluable insights throughout this Senior Design Project.


✒️ Citation

If you find CircuitVision useful in your research or work, please cite it as follows:

@misc{CircuitVision,
  author = {Sameh, Mahmoud and Khan, Jawad},
  title = {CircuitVision: AI-Powered Electrical Circuit Analysis & Netlist Generation},
  year = {2025},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/JKc66/CircuitVision}}
}