Skip to content

Latest commit

 

History

History
467 lines (331 loc) · 10.8 KB

File metadata and controls

467 lines (331 loc) · 10.8 KB

SegAgent-AI

AI-Powered Industrial Defect Inspection Platform

Binary Segmentation • Defect Analysis • Severity Assessment • Automated Reporting


Overview

SegAgent-AI transforms a research-grade surface defect segmentation model into a deployable industrial inspection platform.

The system enables users to upload inspection images, perform automated binary defect segmentation, calculate defect statistics, assess severity levels, and generate downloadable inspection reports through both a web dashboard and REST API.

This project was developed to bridge the gap between academic deep learning research and production-ready AI inspection systems.


Live Demo

The project is deployed on a Microsoft Azure virtual machine.

http://72.155.89.101:8501

API documentation:

http://72.155.89.101:8000/docs

Note: The live demo may be temporarily unavailable to reduce cloud credit usage.


Problem Statement

Industrial surface inspection often relies on manual visual assessment, which can be:

  • Time-consuming
  • Subjective
  • Error-prone
  • Difficult to scale

Although modern deep learning models can accurately segment defects, many research implementations remain limited to notebooks, offline experiments, or local scripts.

SegAgent-AI addresses this challenge by providing a complete workflow from image upload to segmentation, defect analysis, severity assessment, and automated reporting.


Project Objectives

The primary objectives of this project are:

  • Detect defective regions using deep learning-based binary segmentation
  • Generate binary segmentation masks automatically
  • Produce probability maps for model confidence visualization
  • Calculate defect area, defect pixels, and area percentage
  • Assess defect severity automatically
  • Generate downloadable HTML inspection reports
  • Provide REST API access for external integration
  • Deliver an interactive web dashboard
  • Support reproducible deployment using Docker
  • Deploy the system on Microsoft Azure

System Architecture

Input Image
      │
      ▼
Segmentation Model
      │
      ▼
Binary Mask Generation
      │
      ▼
Defect Analysis
      │
      ▼
Severity Assessment
      │
      ▼
Report Generation
      │
      ▼
Web Dashboard / REST API

Model Information

The segmentation model used in SegAgent-AI was trained on the SD-Saliency-900 dataset, a benchmark dataset for industrial surface defect segmentation.

Dataset characteristics:

  • 900 industrial inspection images
  • Pixel-level defect annotations
  • Binary segmentation task
  • Various defect types and defect sizes
  • Designed for surface defect detection and segmentation research

The model predicts:

  • Binary defect masks
  • Defect area percentage
  • Defect severity level
  • Overlay visualizations
  • Inspection reports

Key Features

Feature Description
Binary Segmentation Detects defective regions using a trained deep learning segmentation model
Probability Map Generation Produces pixel-level confidence maps
Defect Area Analysis Computes defect area percentage and pixel-level statistics
Severity Assessment Automatically estimates defect severity levels
Automated Reporting Generates downloadable HTML inspection reports
REST API Provides model access through FastAPI endpoints
Interactive Dashboard Streamlit-based web interface for image upload and result visualization
Docker Deployment Fully containerized deployment environment
Cloud Deployment Deployed on Microsoft Azure VM

Technology Stack

Layer Technologies
Deep Learning PyTorch, Swin Transformer, Custom CNN Encoder
Computer Vision OpenCV, NumPy
Backend API FastAPI, Uvicorn
Frontend Streamlit
Reporting HTML Report Generation
Containerization Docker
Cloud Deployment Microsoft Azure Virtual Machine
Model Hosting Hugging Face
Development Python 3.11
Version Control Git, GitHub
Dataset SD-Saliency-900

Repository Structure

SegAgent-AI
│
├── app
│   ├── model
│   ├── agents
│   └── utils
│
├── streamlit_app
│
├── sample_images
│
├── assets
│
├── Dockerfile
├── requirements.txt
├── .dockerignore
├── .gitignore
└── README.md

Example Results

Dashboard

Dashboard


Segmentation Output

Original Image Binary Mask Overlay Result

Generated Inspection Report

The generated report includes:

  • Defect area statistics
  • Severity assessment
  • Segmentation visualizations
  • Automated recommendations
  • Inspection summary

Installation

Clone Repository

git clone https://github.com/rasoulameri/SegAgent-AI.git
cd SegAgent-AI

Install Dependencies

pip install -r requirements.txt

Model Weights

Due to GitHub file size limitations, the trained model weights are hosted on Hugging Face.

Download the model weights from:

https://huggingface.co/rasoulameri/SegAgent-AI/resolve/main/weights_class.model

Place the downloaded file in:

app/model/weights_class.model

You can also download the weights directly using:

wget -O app/model/weights_class.model \
https://huggingface.co/rasoulameri/SegAgent-AI/resolve/main/weights_class.model

Running Locally

1. Start the Backend

Open a terminal and run:

cd SegAgent-AI
uvicorn app.main:app --reload --port 8001

The FastAPI documentation will be available at:

http://127.0.0.1:8001/docs

2. Start the Frontend

Open a second terminal and run:

cd SegAgent-AI/frontend
npm install
npm run dev

The React dashboard will be available at:

http://localhost:5173

3. Run an Inspection

  1. Open the dashboard in your browser.
  2. Upload an inspection image.
  3. Click Analyze Image.
  4. Review the generated mask, overlay visualization, defect statistics, severity assessment, and inspection report.

Example API Request

curl -X POST "http://127.0.0.1:8000/predict" \
-F "file=@sample_images/sample1.bmp"

Example response:

{
  "status": "success",
  "analysis": {
    "defect_detected": true,
    "defect_area_percent": 1.73,
    "severity": "Low"
  }
}

Docker Deployment

Build Docker Image

docker build -t segagent-ai .

Run Docker Container

docker run -p 8000:8000 -p 8501:8501 segagent-ai

Dashboard:

http://localhost:8501

API documentation:

http://localhost:8000/docs

Azure Deployment

The project was deployed on a Microsoft Azure virtual machine using Docker.

Deployment workflow:

GitHub Repository
      │
      ▼
Azure Virtual Machine
      │
      ▼
Docker Container
      │
      ├── FastAPI Backend
      └── Streamlit Dashboard

Main deployment steps:

git clone https://github.com/rasoulameri/SegAgent-AI.git
cd SegAgent-AI

wget -O app/model/weights_class.model \
https://huggingface.co/rasoulameri/SegAgent-AI/resolve/main/weights_class.model

docker build -t segagent-ai .
docker run -p 8000:8000 -p 8501:8501 segagent-ai

Current Capabilities

  • Binary segmentation inference
  • Probability map generation
  • Defect area estimation
  • Defect pixel statistics
  • Severity assessment
  • Automated HTML report generation
  • FastAPI REST API
  • Interactive Streamlit dashboard
  • Dockerized deployment
  • Microsoft Azure deployment

Future Roadmap

Platform Enhancements

  • Professional React / Next.js dashboard
  • Inspection history database
  • Multi-user authentication
  • PDF report generation
  • Batch image processing

Cloud Enhancements

  • Azure Blob Storage integration
  • Persistent report storage
  • Automated deployment pipeline
  • Monitoring and logging

AI Enhancements

  • Explainable AI module
  • Agentic decision-support framework
  • Advanced severity analysis
  • Maintenance recommendation engine

Research Background

This project is inspired by my research in industrial surface defect detection and segmentation using deep learning and computer vision techniques.

The development of SegAgent-AI has been influenced by insights gained from the following publications:

  • Ameri, R., Hsu, C.-C., & Band, S. S. (2024). A systematic review of deep learning approaches for surface defect detection in industrial applications. Engineering Applications of Artificial Intelligence, 130, 107717.

  • Ameri, R., & Hsu, C.-C. (2026). LACTNet: A Label-Aware CNN-Transformer Network for Surface Defect Segmentation. Expert Systems with Applications.

These studies provided valuable insights into industrial defect inspection, segmentation methodologies, and deployment considerations. SegAgent-AI extends these research concepts into a practical end-to-end inspection platform that integrates image analysis, automated reporting, REST APIs, and modern web technologies.


License

MIT License


📫 Contact

Rasoul Ameri
📧 rasoulameri90@gmail.com
🔗 GitHub Profile