qbcode commited on
Commit
2bb731f
·
verified ·
1 Parent(s): e8f4f63

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -3,7 +3,7 @@ import spaces
3
  from huggingface_hub import hf_hub_download
4
 
5
  def download_models(model_id):
6
- hf_hub_download("merve/yolov9", filename=f"{model_id}", local_dir=f"./")
7
  return f"./{model_id}"
8
 
9
  @spaces.GPU
@@ -20,11 +20,12 @@ def yolov9_inference(img_path, model_id, image_size, conf_threshold, iou_thresho
20
  :return: Annotated image with the number of objects detected.
21
  """
22
  # Import YOLOv9
23
- import yolov9
 
24
 
25
  # Load the model
26
  model_path = download_models(model_id)
27
- model = yolov9.load(model_path, device="cuda:0")
28
 
29
  # Set model parameters
30
  model.conf = conf_threshold
@@ -83,8 +84,8 @@ def app():
83
  output_image = gr.Image(type="numpy",label="Output")
84
  num_objects_detected = gr.Textbox(label="Number of Objects Detected", readonly=True)
85
 
86
- yolov9_infer.click(
87
- fn=yolov9_inference,
88
  inputs=[
89
  img_path,
90
  model_path,
@@ -112,7 +113,7 @@ def app():
112
  0.5,
113
  ],
114
  ],
115
- fn=yolov9_inference,
116
  inputs=[
117
  img_path,
118
  model_path,
 
3
  from huggingface_hub import hf_hub_download
4
 
5
  def download_models(model_id):
6
+ hf_hub_download("qbcode/chicken_detection", filename=f"{model_id}", local_dir=f"./")
7
  return f"./{model_id}"
8
 
9
  @spaces.GPU
 
20
  :return: Annotated image with the number of objects detected.
21
  """
22
  # Import YOLOv9
23
+ import yolov8
24
+
25
 
26
  # Load the model
27
  model_path = download_models(model_id)
28
+ model = yolov8.load(model_path, device="cuda:0")
29
 
30
  # Set model parameters
31
  model.conf = conf_threshold
 
84
  output_image = gr.Image(type="numpy",label="Output")
85
  num_objects_detected = gr.Textbox(label="Number of Objects Detected", readonly=True)
86
 
87
+ yolov8_infer.click(
88
+ fn=yolov8_inference,
89
  inputs=[
90
  img_path,
91
  model_path,
 
113
  0.5,
114
  ],
115
  ],
116
+ fn=yolov8_inference,
117
  inputs=[
118
  img_path,
119
  model_path,