Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

11 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿญ VisionInspect AI

AI-Powered Industrial Surface Defect Detection & Intelligent Inspection Assistant

VisionInspect AI is an intelligent industrial quality inspection system that detects surface defects using a custom PatchCore-inspired anomaly detection pipeline with ResNet50 feature extraction. The application provides anomaly visualization through heatmaps, AI-generated inspection reports using Google Gemini, downloadable PDF reports, and an interactive Streamlit dashboard for real-time quality inspection.


๐ŸŒ Live Demo

๐Ÿ”— https://himanshu-visioninspect-ai.streamlit.app

๐Ÿš€ Features

  • ๐Ÿ” Surface Defect Detection using PatchCore-inspired anomaly detection
  • ๐Ÿง  Deep Feature Extraction using ResNet50
  • ๐Ÿ”ฅ Heatmap Visualization for anomaly localization
  • ๐Ÿค– AI-generated Inspection Reports using Google Gemini
  • ๐Ÿ“„ Downloadable PDF Inspection Reports
  • ๐Ÿ“Š Confidence Score & Anomaly Score
  • ๐Ÿ–ฅ Interactive Streamlit Dashboard
  • โšก CUDA (GPU) Support
  • ๐Ÿ“ Modular Project Structure

๐Ÿ›  Tech Stack

Category Technology
Language Python
Deep Learning PyTorch
Backbone ResNet50
Anomaly Detection PatchCore-inspired Method
Machine Learning Scikit-learn
Computer Vision OpenCV
Dashboard Streamlit
Generative AI Google Gemini
PDF Generation ReportLab
Image Processing Pillow
Numerical Computing NumPy

๐Ÿ“‚ Project Structure

VisionInspect-AI/
โ”‚
โ”œโ”€โ”€ app.py
โ”œโ”€โ”€ train.py
โ”œโ”€โ”€ inference.py
โ”œโ”€โ”€ feature_extractor.py
โ”œโ”€โ”€ patchcore.py
โ”œโ”€โ”€ heatmap.py
โ”œโ”€โ”€ ai_report.py
โ”œโ”€โ”€ pdf_report.py
โ”œโ”€โ”€ test_gemini.py
โ”‚
โ”œโ”€โ”€ models/
โ”œโ”€โ”€ outputs/
โ”œโ”€โ”€ screenshots/
โ”‚
โ”œโ”€โ”€ requirements.txt
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ .gitignore
โ””โ”€โ”€ .env

โš™๏ธ System Requirements

  • Python 3.11+
  • Windows / Linux / macOS
  • CUDA-compatible GPU (Optional)
  • Google Gemini API Key

๐Ÿš€ Installation

1๏ธโƒฃ Clone Repository

git clone https://github.com/<YOUR_GITHUB_USERNAME>/VisionInspect-AI.git
cd VisionInspect-AI

2๏ธโƒฃ Create Virtual Environment (Recommended)

python -m venv venv

Activate it:

Windows

.\venv\Scripts\Activate.ps1

Linux / macOS

source venv/bin/activate

3๏ธโƒฃ Install Dependencies

pip install -r requirements.txt

4๏ธโƒฃ Configure Google Gemini API

Create a .env file in the project root.

Add:

GEMINI_API_KEY=YOUR_API_KEY

Replace YOUR_API_KEY with your Google Gemini API key.


โ–ถ๏ธ Running the Application

Run the Streamlit application:

python -m streamlit run app.py

Open:

http://localhost:8501

๐Ÿง  Training

To rebuild the Memory Bank and Threshold:

python train.py

๐Ÿ” Test Inference

python inference.py

๐Ÿ“„ Workflow

  1. Upload an industrial product image.
  2. Extract deep features using ResNet50.
  3. Compare extracted features with the PatchCore Memory Bank.
  4. Compute the anomaly score.
  5. Generate an anomaly heatmap.
  6. Produce an AI inspection report using Google Gemini.
  7. Download a professional PDF inspection report.

๐Ÿ“ท Screenshots

Dashboard

Dashboard


Prediction & Heatmap

Prediction


AI Inspection Report

AI Report


PDF Inspection Report

PDF Report


๐Ÿ“Š Project Pipeline

Product Image
      โ”‚
      โ–ผ
ResNet50 Feature Extraction
      โ”‚
      โ–ผ
PatchCore Memory Bank
      โ”‚
      โ–ผ
Anomaly Detection
      โ”‚
      โ–ผ
Heatmap Generation
      โ”‚
      โ–ผ
Google Gemini AI Report
      โ”‚
      โ–ผ
PDF Inspection Report

โš ๏ธ Common Issues

Streamlit Not Found

Run:

python -m streamlit run app.py

instead of:

streamlit run app.py

Wrong Python Environment

Verify Python:

where python

Ensure it points to your active virtual environment.


Gemini API Quota Exceeded

If the free API quota is exhausted:

  • Wait until the quota resets.
  • Generate the report again.
  • The application automatically shows a fallback report until the API becomes available.

๐Ÿ”ฎ Future Enhancements

  • Multi-product support
  • Batch image inspection
  • Real-time camera inspection
  • Database integration
  • Inspection history dashboard
  • Cloud deployment
  • True PatchCore anomaly localization

๐Ÿ‘จโ€๐Ÿ’ป Author

Himanshu Singh Patel

VisionInspect AI

AI-Powered Industrial Surface Defect Detection & Intelligent Inspection Assistant


โญ If you like this project

Please consider giving it a โญ on GitHub.

About

AI-powered industrial surface defect detection using PatchCore-inspired anomaly detection, ResNet50 feature extraction, heatmap visualization, Google Gemini AI, PDF inspection reports, and Streamlit.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages