Spaces:
Runtime error
Runtime error
Update app.py
#2
by
merve
HF Staff
- opened
app.py
CHANGED
|
@@ -1,9 +1,13 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import spaces
|
| 3 |
import os
|
|
|
|
| 4 |
|
|
|
|
|
|
|
|
|
|
| 5 |
@spaces.GPU
|
| 6 |
-
def yolov9_inference(img_path,
|
| 7 |
"""
|
| 8 |
Load a YOLOv9 model, configure it, perform inference on an image, and optionally adjust
|
| 9 |
the input size and apply test time augmentation.
|
|
@@ -19,7 +23,8 @@ def yolov9_inference(img_path, model_path,image_size, conf_threshold, iou_thresh
|
|
| 19 |
import yolov9
|
| 20 |
|
| 21 |
# Load the model
|
| 22 |
-
|
|
|
|
| 23 |
|
| 24 |
# Set model parameters
|
| 25 |
model.conf = conf_threshold
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import spaces
|
| 3 |
import os
|
| 4 |
+
from huggingface_hub import hf_hub_download
|
| 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 |
@spaces.GPU
|
| 10 |
+
def yolov9_inference(img_path, model_id, image_size, conf_threshold, iou_threshold):
|
| 11 |
"""
|
| 12 |
Load a YOLOv9 model, configure it, perform inference on an image, and optionally adjust
|
| 13 |
the input size and apply test time augmentation.
|
|
|
|
| 23 |
import yolov9
|
| 24 |
|
| 25 |
# Load the model
|
| 26 |
+
model_path = download_models(model_id)
|
| 27 |
+
model = yolov9.load(model_path, device="cuda")
|
| 28 |
|
| 29 |
# Set model parameters
|
| 30 |
model.conf = conf_threshold
|