bkr969 commited on
Commit
fec02af
·
verified ·
1 Parent(s): 87fb1e9

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +29 -0
  2. best.pt +3 -0
  3. requirements.txt +5 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from ultralytics import YOLO
3
+ from PIL import Image
4
+ import cv2 # ✅ fix: lowercase
5
+
6
+ # Load the trained YOLO model
7
+ model = YOLO('best.pt')
8
+
9
+ # Define the prediction function
10
+ def detect_objects(img):
11
+ # Run inference
12
+ results = model(img)
13
+ # Get the plotted image with bounding boxes and convert BGR to RGB
14
+ annotated_img = cv2.cvtColor(results[0].plot(), cv2.COLOR_BGR2RGB)
15
+ return Image.fromarray(annotated_img)
16
+
17
+ # Create the Gradio interface
18
+ app = gr.Interface(
19
+ fn=detect_objects,
20
+ inputs=gr.Image(type="pil"),
21
+ outputs=gr.Image(type="pil"),
22
+ title="Car Defects Object Detection using YOLO",
23
+ description="Upload an image and the model will detect objects."
24
+ )
25
+
26
+ # Launch the app
27
+ # Launch app
28
+ if __name__ == "__main__":
29
+ app.launch()
best.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3cb4502b47062bb31e9add52b064a77cd6caa25ee1be41795fead5b4f136138e
3
+ size 87659251
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ ultralytics
2
+ gradio
3
+ numpy
4
+ Pillow
5
+ opencv-python