Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,15 +1,15 @@
|
|
1 |
import gradio as gr
|
2 |
from PIL import Image
|
3 |
import sys
|
4 |
-
import os
|
5 |
|
6 |
-
#
|
7 |
sys.path.append("yolov12")
|
8 |
|
9 |
-
#
|
10 |
-
from models.yolo import YOLO
|
11 |
|
12 |
-
|
|
|
13 |
|
14 |
def detect_damage(image: Image.Image):
|
15 |
results = model(image)
|
@@ -26,10 +26,12 @@ def detect_damage(image: Image.Image):
|
|
26 |
|
27 |
return {"is_damaged": is_damaged}
|
28 |
|
29 |
-
demo = gr.Interface(
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
|
|
|
|
34 |
|
35 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from PIL import Image
|
3 |
import sys
|
|
|
4 |
|
5 |
+
# Add yolov12 to Python path
|
6 |
sys.path.append("yolov12")
|
7 |
|
8 |
+
# Correct import from yolov12 repo
|
9 |
+
from yolov12.models.yolo import YOLO
|
10 |
|
11 |
+
# β
Correct path to the actual weights file
|
12 |
+
model = YOLO("yolov12/runs/detect/train7/weights/best.pt")
|
13 |
|
14 |
def detect_damage(image: Image.Image):
|
15 |
results = model(image)
|
|
|
26 |
|
27 |
return {"is_damaged": is_damaged}
|
28 |
|
29 |
+
demo = gr.Interface(
|
30 |
+
fn=detect_damage,
|
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 check if it's damaged using your custom YOLOv12 model."
|
35 |
+
)
|
36 |
|
37 |
demo.launch()
|