Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -19,33 +19,41 @@ model_path1 = hf_hub_download(
|
|
| 19 |
)
|
| 20 |
model1 = YOLO(model_path1)
|
| 21 |
|
| 22 |
-
model_path_2 = hf_hub_download(
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
)
|
| 27 |
-
model2 = YOLO(model_path_2)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
-
|
| 30 |
repo_id="limitedonly41/safety_best",
|
| 31 |
-
filename="
|
| 32 |
token=os.environ.get("HF_TOKEN") # Set in HF Secrets
|
| 33 |
)
|
| 34 |
-
|
| 35 |
|
| 36 |
-
|
| 37 |
repo_id="limitedonly41/safety_best",
|
| 38 |
-
filename="
|
| 39 |
token=os.environ.get("HF_TOKEN") # Set in HF Secrets
|
| 40 |
)
|
| 41 |
-
|
| 42 |
|
| 43 |
# Move models to GPU if available
|
| 44 |
if torch.cuda.is_available():
|
| 45 |
model1.to('cuda')
|
| 46 |
-
model2.to('cuda')
|
| 47 |
-
model3.to('cuda')
|
| 48 |
model4.to('cuda')
|
|
|
|
| 49 |
|
| 50 |
|
| 51 |
def get_gpu_info():
|
|
@@ -61,12 +69,14 @@ def get_gpu_info():
|
|
| 61 |
def select_model(model_name):
|
| 62 |
if model_name == "Model 1":
|
| 63 |
return model1
|
| 64 |
-
elif model_name == "Model 2":
|
| 65 |
-
|
| 66 |
-
elif model_name == "Model 3":
|
| 67 |
-
|
| 68 |
elif model_name == "Model 4":
|
| 69 |
return model4
|
|
|
|
|
|
|
| 70 |
else:
|
| 71 |
return model1
|
| 72 |
|
|
@@ -238,7 +248,7 @@ with gr.Blocks(
|
|
| 238 |
with gr.Tabs():
|
| 239 |
# Model selector common for image and video
|
| 240 |
model_selector = gr.Dropdown(
|
| 241 |
-
choices=["Model 1", "Model
|
| 242 |
value="Model 1",
|
| 243 |
label="Choose model"
|
| 244 |
)
|
|
|
|
| 19 |
)
|
| 20 |
model1 = YOLO(model_path1)
|
| 21 |
|
| 22 |
+
# model_path_2 = hf_hub_download(
|
| 23 |
+
# repo_id="limitedonly41/safety_best",
|
| 24 |
+
# filename="best_ppe.pt",
|
| 25 |
+
# token=os.environ.get("HF_TOKEN") # Set in HF Secrets
|
| 26 |
+
# )
|
| 27 |
+
# model2 = YOLO(model_path_2)
|
| 28 |
+
|
| 29 |
+
# model_path_3 = hf_hub_download(
|
| 30 |
+
# repo_id="limitedonly41/safety_best",
|
| 31 |
+
# filename="best_ppe2.pt",
|
| 32 |
+
# token=os.environ.get("HF_TOKEN") # Set in HF Secrets
|
| 33 |
+
# )
|
| 34 |
+
# model3 = YOLO(model_path_3)
|
| 35 |
|
| 36 |
+
model_path_4 = hf_hub_download(
|
| 37 |
repo_id="limitedonly41/safety_best",
|
| 38 |
+
filename="best_6_cls.pt",
|
| 39 |
token=os.environ.get("HF_TOKEN") # Set in HF Secrets
|
| 40 |
)
|
| 41 |
+
model4 = YOLO(model_path_4)
|
| 42 |
|
| 43 |
+
model_path_5 = hf_hub_download(
|
| 44 |
repo_id="limitedonly41/safety_best",
|
| 45 |
+
filename="best_ppe_big.pt",
|
| 46 |
token=os.environ.get("HF_TOKEN") # Set in HF Secrets
|
| 47 |
)
|
| 48 |
+
model5 = YOLO(model_path_5)
|
| 49 |
|
| 50 |
# Move models to GPU if available
|
| 51 |
if torch.cuda.is_available():
|
| 52 |
model1.to('cuda')
|
| 53 |
+
# model2.to('cuda')
|
| 54 |
+
# model3.to('cuda')
|
| 55 |
model4.to('cuda')
|
| 56 |
+
model5.to('cuda')
|
| 57 |
|
| 58 |
|
| 59 |
def get_gpu_info():
|
|
|
|
| 69 |
def select_model(model_name):
|
| 70 |
if model_name == "Model 1":
|
| 71 |
return model1
|
| 72 |
+
# elif model_name == "Model 2":
|
| 73 |
+
# return model2
|
| 74 |
+
# elif model_name == "Model 3":
|
| 75 |
+
# return model3
|
| 76 |
elif model_name == "Model 4":
|
| 77 |
return model4
|
| 78 |
+
elif model_name == "Model 5":
|
| 79 |
+
return model5
|
| 80 |
else:
|
| 81 |
return model1
|
| 82 |
|
|
|
|
| 248 |
with gr.Tabs():
|
| 249 |
# Model selector common for image and video
|
| 250 |
model_selector = gr.Dropdown(
|
| 251 |
+
choices=["Model 1", "Model 4", "Model 5"],
|
| 252 |
value="Model 1",
|
| 253 |
label="Choose model"
|
| 254 |
)
|