StevenChen16 commited on
Commit
fb76a25
·
verified ·
1 Parent(s): 4cc6206

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -14
app.py CHANGED
@@ -4,12 +4,11 @@ import tempfile
4
  from ultralytics import YOLOv10
5
  import supervision as sv
6
  import spaces
7
- from huggingface_hub import hf_hub_download
8
 
9
 
10
  def download_models(model_id):
11
- hf_hub_download("kadirnar/Yolov10", filename=f"{model_id}", local_dir=f"./")
12
- return f"./{model_id}"
13
 
14
  box_annotator = sv.BoxAnnotator()
15
  category_dict = {
@@ -32,10 +31,9 @@ category_dict = {
32
  }
33
 
34
 
35
- @spaces.GPU
36
  def yolov10_inference(image, video, model_id, image_size, conf_threshold, iou_threshold):
37
  model_path = download_models(model_id)
38
- model = YOLOv10(model_path)
39
 
40
  if image:
41
  results = model(source=image, imgsz=image_size, iou=iou_threshold, conf=conf_threshold, verbose=False)[0]
@@ -101,14 +99,14 @@ def app():
101
  model_id = gr.Dropdown(
102
  label="Model",
103
  choices=[
104
- "yolov10n.pt",
105
- "yolov10s.pt",
106
- "yolov10m.pt",
107
- "yolov10b.pt",
108
- "yolov10l.pt",
109
- "yolov10x.pt",
110
  ],
111
- value="yolov10m.pt",
112
  )
113
  image_size = gr.Slider(
114
  label="Image Size",
@@ -168,14 +166,14 @@ def app():
168
  examples=[
169
  [
170
  "ultralytics/assets/bus.jpg",
171
- "yolov10s.pt",
172
  640,
173
  0.25,
174
  0.45,
175
  ],
176
  [
177
  "ultralytics/assets/zidane.jpg",
178
- "yolov10s.pt",
179
  640,
180
  0.25,
181
  0.45,
 
4
  from ultralytics import YOLOv10
5
  import supervision as sv
6
  import spaces
 
7
 
8
 
9
  def download_models(model_id):
10
+ model_path = f'jameslahm/{model_id}'
11
+ return model_path
12
 
13
  box_annotator = sv.BoxAnnotator()
14
  category_dict = {
 
31
  }
32
 
33
 
 
34
  def yolov10_inference(image, video, model_id, image_size, conf_threshold, iou_threshold):
35
  model_path = download_models(model_id)
36
+ model = YOLOv10.from_pretrained(model_path)
37
 
38
  if image:
39
  results = model(source=image, imgsz=image_size, iou=iou_threshold, conf=conf_threshold, verbose=False)[0]
 
99
  model_id = gr.Dropdown(
100
  label="Model",
101
  choices=[
102
+ "yolov10n",
103
+ "yolov10s",
104
+ "yolov10m",
105
+ "yolov10b",
106
+ "yolov10l",
107
+ "yolov10x",
108
  ],
109
+ value="yolov10m",
110
  )
111
  image_size = gr.Slider(
112
  label="Image Size",
 
166
  examples=[
167
  [
168
  "ultralytics/assets/bus.jpg",
169
+ "yolov10s",
170
  640,
171
  0.25,
172
  0.45,
173
  ],
174
  [
175
  "ultralytics/assets/zidane.jpg",
176
+ "yolov10s",
177
  640,
178
  0.25,
179
  0.45,