Spaces:
Running
on
Zero
Running
on
Zero
up
Browse files
app.py
CHANGED
@@ -4,23 +4,9 @@ import os
|
|
4 |
from huggingface_hub import hf_hub_download
|
5 |
|
6 |
|
7 |
-
def
|
8 |
-
|
9 |
-
|
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 |
|
26 |
@spaces.GPU
|
@@ -40,8 +26,8 @@ def yolov9_inference(img_path, model_id, image_size, conf_threshold, iou_thresho
|
|
40 |
import yolov9
|
41 |
|
42 |
# Load the model
|
43 |
-
model_path =
|
44 |
-
model = yolov9.load(model_path, device="
|
45 |
|
46 |
# Set model parameters
|
47 |
model.conf = conf_threshold
|
@@ -64,7 +50,10 @@ def app():
|
|
64 |
model_path = gr.Dropdown(
|
65 |
label="Model",
|
66 |
choices=[
|
67 |
-
"
|
|
|
|
|
|
|
68 |
],
|
69 |
value="gelan-e.pt",
|
70 |
)
|
@@ -109,8 +98,8 @@ def app():
|
|
109 |
gr.Examples(
|
110 |
examples=[
|
111 |
[
|
112 |
-
"
|
113 |
-
"
|
114 |
640,
|
115 |
0.4,
|
116 |
0.5,
|
|
|
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}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
|
12 |
@spaces.GPU
|
|
|
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
|
33 |
model.conf = conf_threshold
|
|
|
50 |
model_path = gr.Dropdown(
|
51 |
label="Model",
|
52 |
choices=[
|
53 |
+
"gelan-c.pt",
|
54 |
+
"gelan-e.pt",
|
55 |
+
"yolov9-c.pt",
|
56 |
+
"yolov9-e.pt",
|
57 |
],
|
58 |
value="gelan-e.pt",
|
59 |
)
|
|
|
98 |
gr.Examples(
|
99 |
examples=[
|
100 |
[
|
101 |
+
"zidane.jpg"
|
102 |
+
"gelan-e.pt",
|
103 |
640,
|
104 |
0.4,
|
105 |
0.5,
|