Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,20 +1,21 @@
|
|
1 |
import gradio as gr
|
2 |
from PIL import Image
|
|
|
3 |
import sys
|
4 |
|
5 |
-
#
|
6 |
-
sys.path.append("yolov12")
|
7 |
|
8 |
-
#
|
9 |
-
from
|
10 |
|
11 |
-
#
|
12 |
-
model = YOLO("yolov12/
|
13 |
|
14 |
def detect_damage(image: Image.Image):
|
15 |
results = model(image)
|
16 |
-
is_damaged = False
|
17 |
|
|
|
18 |
for result in results:
|
19 |
for box in result.boxes:
|
20 |
class_id = int(box.cls[0])
|
@@ -31,7 +32,7 @@ demo = gr.Interface(
|
|
31 |
inputs=gr.Image(type="pil"),
|
32 |
outputs=gr.JSON(label="Detection Result"),
|
33 |
title="🍎 Apple Damage Detector (YOLOv12)",
|
34 |
-
description="Upload an image of an apple to
|
35 |
)
|
36 |
|
37 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from PIL import Image
|
3 |
+
import os
|
4 |
import sys
|
5 |
|
6 |
+
# Make yolov12 folder importable
|
7 |
+
sys.path.append(os.path.abspath("yolov12"))
|
8 |
|
9 |
+
# Import your YOLO class
|
10 |
+
from yolo import YOLO # Now from yolov12/yolo.py
|
11 |
|
12 |
+
# Load your custom YOLOv12 model
|
13 |
+
model = YOLO("yolov12/best.pt")
|
14 |
|
15 |
def detect_damage(image: Image.Image):
|
16 |
results = model(image)
|
|
|
17 |
|
18 |
+
is_damaged = False
|
19 |
for result in results:
|
20 |
for box in result.boxes:
|
21 |
class_id = int(box.cls[0])
|
|
|
32 |
inputs=gr.Image(type="pil"),
|
33 |
outputs=gr.JSON(label="Detection Result"),
|
34 |
title="🍎 Apple Damage Detector (YOLOv12)",
|
35 |
+
description="Upload an image of an apple to detect if it's damaged."
|
36 |
)
|
37 |
|
38 |
demo.launch()
|