CosmickVisions commited on
Commit
abe1d16
·
verified ·
1 Parent(s): a0e52e5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -27
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
- with st.sidebar.spinner("Downloading YOLO models..."):
2253
- # Ensure models directory exists
2254
- os.makedirs(models_dir, exist_ok=True)
 
 
 
 
 
 
 
2255
 
2256
- # Download YOLOv3 config
2257
- try:
2258
- import urllib.request
2259
-
2260
- # Download config file
2261
- if not os.path.exists(config_path):
2262
- urllib.request.urlretrieve(
2263
- "https://raw.githubusercontent.com/pjreddie/darknet/master/cfg/yolov3.cfg",
2264
- config_path
2265
- )
2266
- st.sidebar.success("Downloaded YOLOv3 config file")
2267
-
2268
- # Download weights file (this is large - about 240MB)
2269
- if not os.path.exists(weights_path):
2270
- urllib.request.urlretrieve(
2271
- "https://pjreddie.com/media/files/yolov3.weights",
2272
- weights_path
2273
- )
2274
- st.sidebar.success("Downloaded YOLOv3 weights file")
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