Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +2 -23
src/streamlit_app.py
CHANGED
|
@@ -1,16 +1,3 @@
|
|
| 1 |
-
# -------------------------------------------------
|
| 2 |
-
# Disable signal handling (Streamlit-safe)
|
| 3 |
-
# -------------------------------------------------
|
| 4 |
-
import signal
|
| 5 |
-
|
| 6 |
-
def _no_signal(*args, **kwargs):
|
| 7 |
-
return None
|
| 8 |
-
|
| 9 |
-
signal.signal = _no_signal
|
| 10 |
-
|
| 11 |
-
# -------------------------------------------------
|
| 12 |
-
# Normal imports AFTER stubbing
|
| 13 |
-
# -------------------------------------------------
|
| 14 |
import streamlit as st
|
| 15 |
import torch
|
| 16 |
from torchvision import models, transforms
|
|
@@ -21,6 +8,7 @@ import numpy as np
|
|
| 21 |
import time
|
| 22 |
|
| 23 |
from huggingface_hub import hf_hub_download
|
|
|
|
| 24 |
|
| 25 |
|
| 26 |
# ===================== DEVICE =====================
|
|
@@ -86,16 +74,7 @@ def get_yolo_checkpoint_path():
|
|
| 86 |
def load_yolo_model_hf():
|
| 87 |
path = get_yolo_checkpoint_path()
|
| 88 |
|
| 89 |
-
model =
|
| 90 |
-
"ultralytics/yolov5", # YOLOv5 repo
|
| 91 |
-
"custom", # custom-trained model
|
| 92 |
-
path=path,
|
| 93 |
-
source="github",
|
| 94 |
-
force_reload=False,
|
| 95 |
-
)
|
| 96 |
-
|
| 97 |
-
model.to(device)
|
| 98 |
-
model.eval()
|
| 99 |
return model
|
| 100 |
|
| 101 |
@st.cache_resource
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import torch
|
| 3 |
from torchvision import models, transforms
|
|
|
|
| 8 |
import time
|
| 9 |
|
| 10 |
from huggingface_hub import hf_hub_download
|
| 11 |
+
from ultralytics import YOLO
|
| 12 |
|
| 13 |
|
| 14 |
# ===================== DEVICE =====================
|
|
|
|
| 74 |
def load_yolo_model_hf():
|
| 75 |
path = get_yolo_checkpoint_path()
|
| 76 |
|
| 77 |
+
model = YOLO(path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
return model
|
| 79 |
|
| 80 |
@st.cache_resource
|