Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -2,13 +2,7 @@ import gradio as gr
|
|
2 |
from ultralytics import YOLOv10
|
3 |
import supervision as sv
|
4 |
import spaces
|
5 |
-
from huggingface_hub import hf_hub_download
|
6 |
|
7 |
-
|
8 |
-
def download_models(model_id):
|
9 |
-
hf_hub_download("kadirnar/Yolov10", filename=f"{model_id}", local_dir=f"./")
|
10 |
-
return f"./{model_id}"
|
11 |
-
|
12 |
box_annotator = sv.BoxAnnotator()
|
13 |
category_dict = {
|
14 |
0: 'person', 1: 'bicycle', 2: 'car', 3: 'motorcycle', 4: 'airplane', 5: 'bus',
|
@@ -33,7 +27,7 @@ category_dict = {
|
|
33 |
@spaces.GPU(duration=200)
|
34 |
def yolov10_inference(image, model_id, image_size, conf_threshold, iou_threshold):
|
35 |
model_path = download_models(model_id)
|
36 |
-
model = YOLOv10(
|
37 |
results = model(source=image, imgsz=image_size, iou=iou_threshold, conf=conf_threshold, verbose=False)[0]
|
38 |
detections = sv.Detections.from_ultralytics(results)
|
39 |
|
@@ -54,14 +48,14 @@ def app():
|
|
54 |
model_id = gr.Dropdown(
|
55 |
label="Model",
|
56 |
choices=[
|
57 |
-
"yolov10n
|
58 |
-
"yolov10s
|
59 |
-
"yolov10m
|
60 |
-
"yolov10b
|
61 |
-
"yolov10l
|
62 |
-
"yolov10x
|
63 |
],
|
64 |
-
value="yolov10m
|
65 |
)
|
66 |
image_size = gr.Slider(
|
67 |
label="Image Size",
|
|
|
2 |
from ultralytics import YOLOv10
|
3 |
import supervision as sv
|
4 |
import spaces
|
|
|
5 |
|
|
|
|
|
|
|
|
|
|
|
6 |
box_annotator = sv.BoxAnnotator()
|
7 |
category_dict = {
|
8 |
0: 'person', 1: 'bicycle', 2: 'car', 3: 'motorcycle', 4: 'airplane', 5: 'bus',
|
|
|
27 |
@spaces.GPU(duration=200)
|
28 |
def yolov10_inference(image, model_id, image_size, conf_threshold, iou_threshold):
|
29 |
model_path = download_models(model_id)
|
30 |
+
model = YOLOv10.from_pretrained(f"kadirnar/{model_id}")
|
31 |
results = model(source=image, imgsz=image_size, iou=iou_threshold, conf=conf_threshold, verbose=False)[0]
|
32 |
detections = sv.Detections.from_ultralytics(results)
|
33 |
|
|
|
48 |
model_id = gr.Dropdown(
|
49 |
label="Model",
|
50 |
choices=[
|
51 |
+
"yolov10n",
|
52 |
+
"yolov10s",
|
53 |
+
"yolov10m",
|
54 |
+
"yolov10b",
|
55 |
+
"yolov10l",
|
56 |
+
"yolov10x",
|
57 |
],
|
58 |
+
value="yolov10m",
|
59 |
)
|
60 |
image_size = gr.Slider(
|
61 |
label="Image Size",
|