kadirnar commited on
Commit
12f2905
·
1 Parent(s): b726765
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -1,14 +1,13 @@
1
  import gradio as gr
2
  import os
3
- import spaces
4
  from huggingface_hub import hf_hub_download
5
 
6
 
7
  def download_models(model_id):
8
- hf_hub_download("merve/yolov9", filename=f"{model_id}", local_dir=f"./")
9
  return f"./{model_id}"
10
 
11
- @spaces.GPU
12
  def yolov9_inference(img_path, model_id, image_size, conf_threshold, iou_threshold):
13
  """
14
  Load a YOLOv9 model, configure it, perform inference on an image, and optionally adjust
@@ -26,7 +25,7 @@ def yolov9_inference(img_path, model_id, image_size, conf_threshold, iou_thresho
26
 
27
  # Load the model
28
  model_path = download_models(model_id)
29
- model = yolov9.load(model_path, device="cpu")
30
 
31
  # Set model parameters
32
  model.conf = conf_threshold
@@ -103,6 +102,13 @@ def app():
103
  0.4,
104
  0.5,
105
  ],
 
 
 
 
 
 
 
106
  ],
107
  fn=yolov9_inference,
108
  inputs=[
 
1
  import gradio as gr
2
  import os
 
3
  from huggingface_hub import hf_hub_download
4
 
5
 
6
  def download_models(model_id):
7
+ hf_hub_download("merve/yolov9", filename=f"{model_id}", local_dir=f"./{model_id}")
8
  return f"./{model_id}"
9
 
10
+
11
  def yolov9_inference(img_path, model_id, image_size, conf_threshold, iou_threshold):
12
  """
13
  Load a YOLOv9 model, configure it, perform inference on an image, and optionally adjust
 
25
 
26
  # Load the model
27
  model_path = download_models(model_id)
28
+ model = yolov9.load(model_path, device="cuda")
29
 
30
  # Set model parameters
31
  model.conf = conf_threshold
 
102
  0.4,
103
  0.5,
104
  ],
105
+ [
106
+ "data/huggingface.jpg",
107
+ "yolov9-c.pt",
108
+ 640,
109
+ 0.4,
110
+ 0.5,
111
+ ],
112
  ],
113
  fn=yolov9_inference,
114
  inputs=[