atalaydenknalbant commited on
Commit
c145cfd
1 Parent(s): 41b26c3

Update to Use YOLOv10 Models from Latest Ultralytics Package

Browse files

This pull request updates this project to use the latest YOLOv10 models from the recently released Ultralytics package.

Files changed (2) hide show
  1. app.py +5 -8
  2. requirements.txt +3 -1
app.py CHANGED
@@ -1,6 +1,5 @@
1
-
2
  import gradio as gr
3
- from ultralytics import YOLOv10
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
- model_path = download_models(model_id)
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.pt",
105
  640,
106
  0.25,
107
  0.45,
108
  ],
109
  [
110
  "huggingface.jpg",
111
- "yolov10m.pt",
112
  640,
113
  0.25,
114
  0.45,
115
  ],
116
  [
117
  "zidane.jpg",
118
- "yolov10b.pt",
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
- git+https://github.com/THU-MIG/yolov10.git
 
 
 
1
  supervision
2
+ ultralytics
3
+ spaces
4
+ gradio