Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2248,35 +2248,39 @@ def main():
|
|
2248 |
if not (os.path.exists(weights_path) and os.path.exists(config_path)):
|
2249 |
st.sidebar.warning("⚠️ YOLO models not found. Using basic people detector.")
|
2250 |
|
|
|
2251 |
if st.sidebar.button("Download YOLO Models"):
|
2252 |
-
|
2253 |
-
|
2254 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2255 |
|
2256 |
-
# Download
|
2257 |
-
|
2258 |
-
|
2259 |
-
|
2260 |
-
|
2261 |
-
|
2262 |
-
|
2263 |
-
|
2264 |
-
|
2265 |
-
|
2266 |
-
|
2267 |
-
|
2268 |
-
|
2269 |
-
|
2270 |
-
|
2271 |
-
|
2272 |
-
|
2273 |
-
|
2274 |
-
|
2275 |
-
|
2276 |
-
st.sidebar.success("YOLO models downloaded successfully! Please refresh the page.")
|
2277 |
-
except Exception as e:
|
2278 |
-
st.sidebar.error(f"Error downloading YOLO models: {str(e)}")
|
2279 |
-
st.sidebar.info("You can manually download the models from: https://pjreddie.com/darknet/yolo/")
|
2280 |
else:
|
2281 |
st.sidebar.success("✅ YOLO models found. Using advanced object detection.")
|
2282 |
|
|
|
2248 |
if not (os.path.exists(weights_path) and os.path.exists(config_path)):
|
2249 |
st.sidebar.warning("⚠️ YOLO models not found. Using basic people detector.")
|
2250 |
|
2251 |
+
# Create a download button
|
2252 |
if st.sidebar.button("Download YOLO Models"):
|
2253 |
+
# Use a placeholder in the sidebar to show status
|
2254 |
+
download_status = st.sidebar.empty()
|
2255 |
+
download_status.info("Downloading YOLO models... Please wait.")
|
2256 |
+
|
2257 |
+
# Ensure models directory exists
|
2258 |
+
os.makedirs(models_dir, exist_ok=True)
|
2259 |
+
|
2260 |
+
# Download YOLOv3 config
|
2261 |
+
try:
|
2262 |
+
import urllib.request
|
2263 |
|
2264 |
+
# Download config file
|
2265 |
+
if not os.path.exists(config_path):
|
2266 |
+
download_status.info("Downloading configuration file...")
|
2267 |
+
urllib.request.urlretrieve(
|
2268 |
+
"https://raw.githubusercontent.com/pjreddie/darknet/master/cfg/yolov3.cfg",
|
2269 |
+
config_path
|
2270 |
+
)
|
2271 |
+
|
2272 |
+
# Download weights file (this is large - about 240MB)
|
2273 |
+
if not os.path.exists(weights_path):
|
2274 |
+
download_status.info("Downloading weights file (large, ~240MB)...")
|
2275 |
+
urllib.request.urlretrieve(
|
2276 |
+
"https://pjreddie.com/media/files/yolov3.weights",
|
2277 |
+
weights_path
|
2278 |
+
)
|
2279 |
+
|
2280 |
+
download_status.success("✅ YOLO models downloaded successfully! Please refresh the page.")
|
2281 |
+
except Exception as e:
|
2282 |
+
download_status.error(f"Error downloading YOLO models: {str(e)}")
|
2283 |
+
download_status.info("You can manually download the models from: https://pjreddie.com/darknet/yolo/")
|
|
|
|
|
|
|
|
|
2284 |
else:
|
2285 |
st.sidebar.success("✅ YOLO models found. Using advanced object detection.")
|
2286 |
|