surabhic commited on
Commit
568b901
·
verified ·
1 Parent(s): 97eaa5f

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +28 -0
  2. requirements.txt +5 -0
  3. yolov8_model.pt +3 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import cv2
2
+ import numpy as np
3
+ import gradio as gr
4
+ from ultralytics import YOLO
5
+
6
+ # Load trained model
7
+ model = YOLO("E:\\job related docs\\thegame\\yolov8\\yolov8_model.pt") # or "yolov8s.onnx"
8
+
9
+ def detect_defects(image):
10
+ # Run inference
11
+ results = model(image)
12
+ # Plot results
13
+ annotated_img = results[0].plot(line_width=2)
14
+ return annotated_img
15
+
16
+ # Gradio UI
17
+ title = "🔍 Steel Surface Defect Detector (YOLOv8)"
18
+ description = "Upload a steel surface image to detect defects (crazing, scratches, etc.)."
19
+ examples = ["defect_example1.jpg", "defect_example2.jpg"]
20
+
21
+ gr.Interface(
22
+ fn=detect_defects,
23
+ inputs=gr.Image(type="numpy"),
24
+ outputs=gr.Image(type="numpy"),
25
+ title=title,
26
+ description=description,
27
+ examples=examples,
28
+ ).launch()
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ ultralytics
2
+ gradio
3
+ numpy
4
+ opencv-python
5
+ onnxruntime
yolov8_model.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ea9b9dd4ef4fd2786bbf13ccbe86d9014e545c788afc3eb5e6bd1f9f66e4e830
3
+ size 6266171