Spaces:
Sleeping
Sleeping
SeptAlfauzan
commited on
Commit
·
166ff57
1
Parent(s):
eceb06d
update: finishing minimum UI interface
Browse files- app.py +34 -3
- download.jpeg +0 -0
- models/student-behaviour-best.pt +3 -0
- yolov8n.pt +3 -0
app.py
CHANGED
|
@@ -1,9 +1,40 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
| 2 |
|
| 3 |
|
| 4 |
-
def
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
iface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import torch
|
| 3 |
+
from ultralyticsplus import YOLO, render_result
|
| 4 |
|
| 5 |
|
| 6 |
+
def launch(
|
| 7 |
+
image: gr.Image = None,
|
| 8 |
+
image_size: gr.Slider = 640,
|
| 9 |
+
conf_threshold: gr.Slider = 0.4,
|
| 10 |
+
iou_threshold: gr.Slider = 0.50,
|
| 11 |
+
):
|
| 12 |
+
try:
|
| 13 |
+
model_path = "./models/student-behaviour-best.pt"
|
| 14 |
+
model = YOLO("yolov8n.pt")
|
| 15 |
|
| 16 |
+
results = model.predict(
|
| 17 |
+
image, conf=conf_threshold, iou=iou_threshold, imgsz=image_size
|
| 18 |
+
)
|
| 19 |
+
box = results[0].boxes
|
| 20 |
+
print(box)
|
| 21 |
+
render = render_result(model=model, image=image, result=results[0])
|
| 22 |
+
return render
|
| 23 |
+
except Exception as e:
|
| 24 |
+
print(e)
|
| 25 |
+
return "./download.jpeg"
|
| 26 |
|
| 27 |
+
|
| 28 |
+
inputs = [
|
| 29 |
+
gr.Image(type="filepath", label="Input Image"),
|
| 30 |
+
gr.Slider(minimum=320, maximum=1280, value=640, step=32, label="Image Size"),
|
| 31 |
+
gr.Slider(
|
| 32 |
+
minimum=0.0, maximum=1.0, value=0.4, step=0.1, label="Confidence Threshold"
|
| 33 |
+
),
|
| 34 |
+
gr.Slider(minimum=0.0, maximum=1.0, value=0.4, step=0.1, label="IOU Threshold"),
|
| 35 |
+
]
|
| 36 |
+
|
| 37 |
+
outputs = gr.Image(type="filepath", label="Output Result")
|
| 38 |
+
|
| 39 |
+
iface = gr.Interface(fn=launch, inputs=inputs, outputs=outputs)
|
| 40 |
iface.launch()
|
download.jpeg
ADDED
|
models/student-behaviour-best.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a69d4a1fb801d469a758f70fb1d97261ab043baa785556405455b0d3cdc3f6ca
|
| 3 |
+
size 6257945
|
yolov8n.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:31e20dde3def09e2cf938c7be6fe23d9150bbbe503982af13345706515f2ef95
|
| 3 |
+
size 6534387
|