Spaces:
Running
Running
till-onethousand
commited on
Commit
·
5b30004
1
Parent(s):
e82297b
app.py
CHANGED
@@ -1,3 +1,5 @@
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
import PIL.Image as Image
|
3 |
|
@@ -8,21 +10,10 @@ model = None
|
|
8 |
|
9 |
def predict_image(img, conf_threshold, iou_threshold, model_name):
|
10 |
"""Predicts objects in an image using a YOLOv8 model with adjustable confidence and IOU thresholds."""
|
11 |
-
model
|
12 |
-
|
13 |
-
source=img,
|
14 |
-
conf=conf_threshold,
|
15 |
-
iou=iou_threshold,
|
16 |
-
show_labels=True,
|
17 |
-
show_conf=True,
|
18 |
-
imgsz=640,
|
19 |
-
)
|
20 |
-
|
21 |
-
for r in results:
|
22 |
-
im_array = r.plot()
|
23 |
-
im = Image.fromarray(im_array[..., ::-1])
|
24 |
|
25 |
-
return
|
26 |
|
27 |
|
28 |
iface = gr.Interface(
|
@@ -33,7 +24,7 @@ iface = gr.Interface(
|
|
33 |
gr.Slider(minimum=0, maximum=1, value=0.45, label="IoU threshold"),
|
34 |
gr.Radio(choices=["yolo11n", "yolo11s", "yolo11n-seg", "yolo11s-seg", "yolo11n-pose", "yolo11s-pose"], label="Model Name", value="yolo11n"),
|
35 |
],
|
36 |
-
outputs=gr.Image(type="
|
37 |
title="Ultralytics Gradio Application 🚀",
|
38 |
description="Upload images for inference. The Ultralytics YOLO11n model is used by default.",
|
39 |
examples=[
|
|
|
1 |
+
import os
|
2 |
+
|
3 |
import gradio as gr
|
4 |
import PIL.Image as Image
|
5 |
|
|
|
10 |
|
11 |
def predict_image(img, conf_threshold, iou_threshold, model_name):
|
12 |
"""Predicts objects in an image using a YOLOv8 model with adjustable confidence and IOU thresholds."""
|
13 |
+
os.chdir('./model')
|
14 |
+
os.system(f'./darknet detect cfg/yolov2.cfg yolov2.weights data/dog.jpg')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
+
return './model/predictions.jpg'
|
17 |
|
18 |
|
19 |
iface = gr.Interface(
|
|
|
24 |
gr.Slider(minimum=0, maximum=1, value=0.45, label="IoU threshold"),
|
25 |
gr.Radio(choices=["yolo11n", "yolo11s", "yolo11n-seg", "yolo11s-seg", "yolo11n-pose", "yolo11s-pose"], label="Model Name", value="yolo11n"),
|
26 |
],
|
27 |
+
outputs=gr.Image(type="filepath", label="Result"),
|
28 |
title="Ultralytics Gradio Application 🚀",
|
29 |
description="Upload images for inference. The Ultralytics YOLO11n model is used by default.",
|
30 |
examples=[
|
run.py
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
os.chdir('./model')
|
3 |
+
os.system('./darknet detect cfg/yolov2.cfg yolov2.weights data/dog.jpg')
|