Spaces:
Running
Running
Update to Use YOLOv10 Models from Latest Ultralytics Package (#4)
Browse files- Update to Use YOLOv10 Models from Latest Ultralytics Package (c145cfd286e06004c9f33b63b413de50a0469419)
Co-authored-by: Atalay Denknalbant <atalaydenknalbant@users.noreply.huggingface.co>
- app.py +5 -8
- requirements.txt +3 -1
app.py
CHANGED
|
@@ -1,6 +1,5 @@
|
|
| 1 |
-
|
| 2 |
import gradio as gr
|
| 3 |
-
from ultralytics import
|
| 4 |
import supervision as sv
|
| 5 |
import spaces
|
| 6 |
|
|
@@ -28,11 +27,9 @@ category_dict = {
|
|
| 28 |
|
| 29 |
@spaces.GPU(duration=200)
|
| 30 |
def yolov10_inference(image, model_id, image_size, conf_threshold, iou_threshold):
|
| 31 |
-
|
| 32 |
-
model = YOLOv10.from_pretrained(f"jameslahm/{model_id}")
|
| 33 |
results = model(source=image, imgsz=image_size, iou=iou_threshold, conf=conf_threshold, verbose=False)[0]
|
| 34 |
detections = sv.Detections.from_ultralytics(results)
|
| 35 |
-
|
| 36 |
labels = [
|
| 37 |
f"{category_dict[class_id]} {confidence:.2f}"
|
| 38 |
for class_id, confidence in zip(detections.class_id, detections.confidence)
|
|
@@ -101,21 +98,21 @@ def app():
|
|
| 101 |
examples=[
|
| 102 |
[
|
| 103 |
"dog.jpeg",
|
| 104 |
-
"yolov10x
|
| 105 |
640,
|
| 106 |
0.25,
|
| 107 |
0.45,
|
| 108 |
],
|
| 109 |
[
|
| 110 |
"huggingface.jpg",
|
| 111 |
-
"yolov10m
|
| 112 |
640,
|
| 113 |
0.25,
|
| 114 |
0.45,
|
| 115 |
],
|
| 116 |
[
|
| 117 |
"zidane.jpg",
|
| 118 |
-
"yolov10b
|
| 119 |
640,
|
| 120 |
0.25,
|
| 121 |
0.45,
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from ultralytics import YOLO
|
| 3 |
import supervision as sv
|
| 4 |
import spaces
|
| 5 |
|
|
|
|
| 27 |
|
| 28 |
@spaces.GPU(duration=200)
|
| 29 |
def yolov10_inference(image, model_id, image_size, conf_threshold, iou_threshold):
|
| 30 |
+
model = YOLO(f"{model_id}.pt")
|
|
|
|
| 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 |
labels = [
|
| 34 |
f"{category_dict[class_id]} {confidence:.2f}"
|
| 35 |
for class_id, confidence in zip(detections.class_id, detections.confidence)
|
|
|
|
| 98 |
examples=[
|
| 99 |
[
|
| 100 |
"dog.jpeg",
|
| 101 |
+
"yolov10x",
|
| 102 |
640,
|
| 103 |
0.25,
|
| 104 |
0.45,
|
| 105 |
],
|
| 106 |
[
|
| 107 |
"huggingface.jpg",
|
| 108 |
+
"yolov10m",
|
| 109 |
640,
|
| 110 |
0.25,
|
| 111 |
0.45,
|
| 112 |
],
|
| 113 |
[
|
| 114 |
"zidane.jpg",
|
| 115 |
+
"yolov10b",
|
| 116 |
640,
|
| 117 |
0.25,
|
| 118 |
0.45,
|
requirements.txt
CHANGED
|
@@ -1,2 +1,4 @@
|
|
| 1 |
supervision
|
| 2 |
-
|
|
|
|
|
|
|
|
|
| 1 |
supervision
|
| 2 |
+
ultralytics
|
| 3 |
+
spaces
|
| 4 |
+
gradio
|