Spaces:
Runtime error
Runtime error
up
Browse files- app.py +2 -19
- data/zidane.jpg +0 -0
app.py
CHANGED
|
@@ -4,24 +4,6 @@ import os
|
|
| 4 |
from huggingface_hub import hf_hub_download
|
| 5 |
|
| 6 |
|
| 7 |
-
def attempt_download_from_hub(repo_id, hf_token=None):
|
| 8 |
-
# https://github.com/fcakyon/yolov5-pip/blob/main/yolov5/utils/downloads.py
|
| 9 |
-
from huggingface_hub import hf_hub_download, list_repo_files
|
| 10 |
-
from huggingface_hub.utils._errors import RepositoryNotFoundError
|
| 11 |
-
from huggingface_hub.utils._validators import HFValidationError
|
| 12 |
-
try:
|
| 13 |
-
repo_files = list_repo_files(repo_id=repo_id, repo_type='model', token=hf_token)
|
| 14 |
-
model_file = [f for f in repo_files if f.endswith('.pt')][0]
|
| 15 |
-
file = hf_hub_download(
|
| 16 |
-
repo_id=repo_id,
|
| 17 |
-
filename=model_file,
|
| 18 |
-
repo_type='model',
|
| 19 |
-
token=hf_token,
|
| 20 |
-
)
|
| 21 |
-
return file
|
| 22 |
-
except (RepositoryNotFoundError, HFValidationError):
|
| 23 |
-
return None
|
| 24 |
-
|
| 25 |
def download_models(model_id):
|
| 26 |
hf_hub_download("merve/yolov9", filename=f"{model_id}", local_dir=f"./{model_id}")
|
| 27 |
return f"./{model_id}"
|
|
@@ -44,7 +26,7 @@ def yolov9_inference(img_path, model_id, image_size, conf_threshold, iou_thresho
|
|
| 44 |
import yolov9
|
| 45 |
|
| 46 |
# Load the model
|
| 47 |
-
model_path =
|
| 48 |
model = yolov9.load(model_path, device="cuda")
|
| 49 |
|
| 50 |
# Set model parameters
|
|
@@ -116,6 +98,7 @@ def app():
|
|
| 116 |
gr.Examples(
|
| 117 |
examples=[
|
| 118 |
[
|
|
|
|
| 119 |
"gelan-e.pt",
|
| 120 |
640,
|
| 121 |
0.4,
|
|
|
|
| 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"./{model_id}")
|
| 9 |
return f"./{model_id}"
|
|
|
|
| 26 |
import yolov9
|
| 27 |
|
| 28 |
# Load the model
|
| 29 |
+
model_path = download_models(model_id)
|
| 30 |
model = yolov9.load(model_path, device="cuda")
|
| 31 |
|
| 32 |
# Set model parameters
|
|
|
|
| 98 |
gr.Examples(
|
| 99 |
examples=[
|
| 100 |
[
|
| 101 |
+
"data/zidane.jpg",
|
| 102 |
"gelan-e.pt",
|
| 103 |
640,
|
| 104 |
0.4,
|
data/zidane.jpg
ADDED
|