Spaces:
Sleeping
Sleeping
Initial commit
Browse files- app.py +46 -0
- best.pt +3 -0
- examples/aculus_1.jpg +0 -0
- examples/aculus_2.jpg +0 -0
- examples/healthy.jpg +0 -0
- examples/peacock_2.jpg +0 -0
- examples/peacock_3.jpg +0 -0
- requirements.txt +2 -0
app.py
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import PIL.Image as Image
|
3 |
+
|
4 |
+
from ultralytics import YOLO
|
5 |
+
|
6 |
+
model = YOLO("best.pt")
|
7 |
+
|
8 |
+
|
9 |
+
def predict_image(img, conf_threshold, iou_threshold):
|
10 |
+
results = model.predict(
|
11 |
+
source=img,
|
12 |
+
conf=conf_threshold,
|
13 |
+
iou=iou_threshold,
|
14 |
+
show_labels=True,
|
15 |
+
show_conf=True,
|
16 |
+
imgsz=640,
|
17 |
+
)
|
18 |
+
|
19 |
+
for r in results:
|
20 |
+
im_array = r.plot()
|
21 |
+
im = Image.fromarray(im_array[..., ::-1])
|
22 |
+
|
23 |
+
return im
|
24 |
+
|
25 |
+
|
26 |
+
iface = gr.Interface(
|
27 |
+
fn=predict_image,
|
28 |
+
inputs=[
|
29 |
+
gr.Image(type="pil", label="Upload Image"),
|
30 |
+
gr.Slider(minimum=0, maximum=1, value=0.25, label="Confidence threshold"),
|
31 |
+
gr.Slider(minimum=0, maximum=1, value=0.45, label="IoU threshold"),
|
32 |
+
],
|
33 |
+
outputs=gr.Image(type="pil", label="Result"),
|
34 |
+
title="Ultralytics Gradio",
|
35 |
+
description="Upload images for inference. The Ultralytics YOLOv8n model is used by default.",
|
36 |
+
examples=[
|
37 |
+
"examples/healthy.jpg",
|
38 |
+
"examples/aculus_2.jpg",
|
39 |
+
"examples/aculus_1.jpg",
|
40 |
+
"examples/peacock_2.jpg",
|
41 |
+
"examples/peacock_3.jpg",
|
42 |
+
],
|
43 |
+
)
|
44 |
+
|
45 |
+
if __name__ == "__main__":
|
46 |
+
iface.launch()
|
best.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4a088db8573378e1149dab4bac8c7ab4bb1bcc174e18a30b1ec477bf0e1e7f41
|
3 |
+
size 22491555
|
examples/aculus_1.jpg
ADDED
![]() |
examples/aculus_2.jpg
ADDED
![]() |
examples/healthy.jpg
ADDED
![]() |
examples/peacock_2.jpg
ADDED
![]() |
examples/peacock_3.jpg
ADDED
![]() |
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
ultralytics
|