Ashgibbs commited on
Commit
1100ea7
·
verified ·
1 Parent(s): 4ff4743

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +38 -98
README.md CHANGED
@@ -1,113 +1,53 @@
1
  ---
 
2
  license: mit
3
- language:
4
- - en
5
- base_model:
6
- - Ultralytics/YOLOv8
7
- - Ultralytics/YOLO11
 
8
  ---
9
 
10
- # 🛡️ MetalGuard AI - Cosmetic Defect Detection
11
 
12
- ![React](https://img.shields.io/badge/React-20232A?style=for-the-badge&logo=react&logoColor=61DAFB)
13
- ![FastAPI](https://img.shields.io/badge/FastAPI-005571?style=for-the-badge&logo=fastapi)
14
- ![Ultralytics YOLO](https://img.shields.io/badge/YOLOv8-FF1493?style=for-the-badge&logo=yolo)
15
- ![TypeScript](https://img.shields.io/badge/TypeScript-007ACC?style=for-the-badge&logo=typescript&logoColor=white)
16
 
17
- **MetalGuard AI** is a state-of-the-art computer vision and quality control project designed to automatically detect cosmetic defects (such as cracks, rust, scratches, crazing, and rolled-in scales) on industrial metal surfaces and marble materials.
 
 
 
 
 
 
 
 
 
18
 
19
- By leveraging cutting edge deep-learning models (Ultralytics YOLO) coupled with a modern, high-performance web dashboard, this project completely automates the traditional manual inspection processes on manufacturing lines.
 
20
 
21
- ---
22
-
23
- ## Key Features
24
-
25
- 1. **Surface Classification (`v7_model`)**:
26
- - Upload an image of a metal surface and instantly classify whether it is completely `Normal` or if it contains `Defects`.
27
- 2. **Object Detection (`v1_defect detection_model`)**:
28
- - Accurately localize where the defects are.
29
- - Draws dynamic bounding boxes around all identified defects with real-time confidence scores.
30
- 3. **Video Analysis Pipeline**:
31
- - Upload continuous feed/video from a manufacturing assembly line.
32
- - The system analyzes the video frame-by-frame.
33
- - Generates a compiled `.webm` output video containing visualized bounding boxes.
34
- - Plays the analyzed video directly in a cinematic, responsive 3-column Dashboard.
35
- 4. **Beautiful Glassmorphism UI**:
36
- - A stunning, highly-responsive React front-end powered by Vite that visualizes metrics natively.
37
-
38
- ---
39
-
40
- ## 🏗️ Project Architecture
41
-
42
- ```text
43
- 📦 MetalGuard-AI
44
- ┣ 📂 defect_project # Stores the trained YOLO weights (.pt files)
45
- ┃ ┣ 📂 v1_defect detection_model # YOLOv8 Object Detection Weights
46
- ┃ ┗ 📂 v7_model # YOLOv8 Image Classification Weights
47
- ┣ 📂 Web Dashboard # Frontend Codebase
48
- ┃ ┗ 📂 defect-dashboard # Vite + React + TS App
49
- ┃ ┣ 📂 src (App.tsx, index.css)
50
- ┃ ┗ 📜 package.json
51
- ┣ 📜 main.py # FastAPI Backend Application
52
- ┣ 📜 train_detection.py # Model training pipelines (Colab / Local)
53
- ┣ 📜 evaluate_metrics.py # Evaluation & Confusion Matrix generation
54
- ┣ 📜 README.md # You are here!
55
- ┗ 📜 .gitignore # Git rules blocking massive dataset uploads
56
- ```
57
-
58
- ---
59
-
60
- ## 🛠️ Installation & Setup
61
-
62
- Before you begin, ensure you have **Python 3.9+** and **Node.js (npm)** installed on your machine.
63
-
64
- ### 1. Clone the Repository
65
- ```bash
66
- git clone https://github.com/Ashgibbs/MetalGuard-AI.git
67
- cd MetalGuard-AI
68
- ```
69
-
70
- ### 2. Start the Backend (FastAPI + YOLO)
71
- The backend loads the heavy YOLO models into memory and serves the AI inference endpoints (`/predict`, `/predict-detection`, `/predict-video-detection`).
72
 
73
- ```bash
74
- # Install required Python packages
75
- pip install fastapi uvicorn ultralytics opencv-python-headless pillow python-multipart
76
-
77
- # Start the local development server (runs on Port 8000)
78
- uvicorn main:app --reload
79
- ```
80
- *Note: The first time it runs, it may take a few seconds to load the PyTorch weights into memory.*
81
 
82
- ### 3. Start the Frontend (React Dashboard)
83
- Open a **new terminal window**, and navigate into the dashboard folder:
 
84
 
85
- ```bash
86
- cd "Web Dashboard/defect-dashboard"
87
 
88
- # Install Node dependencies
89
- npm install
90
 
91
- # Start the Vite development server
92
- npm run dev
 
93
  ```
94
 
95
- ### 4. Open the App
96
- Visit [http://localhost:5173](http://localhost:5173) in your browser.
97
- Upload an image or a video, and watch the AI seamlessly hunt down cosmetic defects!
98
-
99
- ---
100
-
101
- ## 🧠 Model Training
102
-
103
- The models in this repository were trained using balanced industrial datasets containing thousands of defect images. The datasets themselves are ignored from this repository to save space, but you can reproduce the training using the provided scripts:
104
-
105
- - `train_colab.py`
106
- - `train_detection.py`
107
-
108
- Results, F1 curves, and Confusion Matrices generated during training are intentionally preserved in the repository alongside their respective model folders!
109
-
110
- ---
111
-
112
- ## 📄 License
113
- This projected is licensed under the MIT License.
 
1
  ---
2
+ language: en
3
  license: mit
4
+ tags:
5
+ - yolo
6
+ - ultralytics
7
+ - object-detection
8
+ - defect-detection
9
+ - industrial-inspection
10
  ---
11
 
12
+ # Cosmetic Defect Detection (YOLOv8)
13
 
14
+ This model is a YOLOv8-based object detection model trained to identify cosmetic defects on metal surfaces.
 
 
 
15
 
16
+ ## Model Details
17
+ - **Architecture**: YOLOv8n (Weights: `best.pt`)
18
+ - **Task**: Object Detection
19
+ - **Classes**:
20
+ - `Crazing`
21
+ - `Inclusion`
22
+ - `Patches`
23
+ - `Pitted`
24
+ - `Rolled-in Scale`
25
+ - `Scratches`
26
 
27
+ ## Training Results
28
+ The model was trained on the **Metal Surface Defect Dataset (NEU)**. Training results, including confusion matrices and performance plots, are available as files in this repository.
29
 
30
+ ### Performance
31
+ - **Confusion Matrix**: See `confusion_matrix.png`
32
+ - **Results Plot**: See `results.png`
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
 
34
+ ## How to use
35
+ You can load this model using the `ultralytics` library:
 
 
 
 
 
 
36
 
37
+ ```python
38
+ from ultralytics import YOLO
39
+ from huggingface_hub import hf_hub_download
40
 
41
+ # Download the model weights
42
+ model_path = hf_hub_download(repo_id="Ashgibbs/Cosmetic_Defect_Detection", filename="best.pt")
43
 
44
+ # Load the model
45
+ model = YOLO(model_path)
46
 
47
+ # Run inference
48
+ results = model.predict("path/to/image.jpg")
49
+ results[0].show()
50
  ```
51
 
52
+ ## Dataset Credit
53
+ The training was conducted using the NEU Surface Defect Dataset.