nagasurendra commited on
Commit
b094487
·
verified ·
1 Parent(s): a43667a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -90
app.py CHANGED
@@ -405,93 +405,4 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="orange")) as iface:
405
 
406
  if __name__ == "__main__":
407
  iface.launch()
408
- ```
409
-
410
- ### Key Changes
411
- 1. **Performance**:
412
- - Removed `shutil.rmtree` to reduce I/O overhead; directories are recreated if needed.
413
- - Added per-frame timing logs (`Frame {frame_count}: Processed in {frame_time:.2f} ms`) to diagnose bottlenecks.
414
- - Introduced a 600-second timeout to prevent runaway processing, logging if exceeded.
415
- - Fixed `frame_skip=5` as default, with slider range of 1–5 to prevent accidental full-frame processing.
416
-
417
- 2. **Download**:
418
- - Kept `gr.File` components for downloading `processed_output.mp4`, `data_lake_submission.json`, `captured_frames.zip`, `flight_logs.zip`, `chart_temp.png`, `map_temp.png`.
419
- - ZIP creation runs post-processing to avoid runtime overhead.
420
-
421
- 3. **Codec**:
422
- - Uses only `mp4v` for MP4 output, logging errors to ensure compatibility.
423
-
424
- 4. **Logging**:
425
- - Added frame-level timing and input video details for debugging.
426
- - Fixed minor logging errors (e.g., removed duplicate `Output video` print).
427
-
428
- 5. **NHAI Compliance**:
429
- - Imagery: Geotagged JPEGs in `captured_frames.zip`. Compliant at 4000x3000; non-compliant at 768x432.
430
- - Flight Logs: CSVs in `flight_logs.zip`. Compliant.
431
- - Data Submission: `data_lake_submission.json`. Compliant.
432
- - Analytics: Limited to 3 classes. Partially compliant.
433
- - Video/Charts/Maps: Optional, compliant.
434
-
435
- ### Why the Slowdown?
436
- The most likely cause is a higher-resolution or longer input video (e.g., 12 MP or >633 frames). To confirm:
437
- - Check the input video’s properties in the logs (`Input video: ...`).
438
- - If it’s 768x432 with 633 frames, processing should take ~146 seconds.
439
- - If it’s 12 MP (e.g., 4000x3000), expect ~5250 seconds on CPU for 633 frames.
440
- - Verify `frame_skip` in the Gradio interface (should be 5).
441
-
442
- ### How to Test
443
- 1. **Setup**:
444
- - Update your Space with the new `app.py` (above).
445
- - Ensure `./data/best.pt` is uploaded.
446
- - Use `requirements.txt`:
447
- ```text
448
- torch
449
- ultralytics
450
- gradio==5.33.2
451
- numpy
452
- opencv-python
453
- matplotlib
454
- piexif
455
- ```
456
- - Confirm ~10 GB storage.
457
-
458
- 2. **Test with 768x432 Video**:
459
- - Upload your 768x432 video (633 frames).
460
- - Set sliders to 768x432 (faster) or 4000x3000 (default, slower).
461
- - Ensure `frame_skip=5`.
462
- - Click “Process Video” (~146 seconds expected).
463
- - Verify:
464
- - No errors in logs.
465
- - Processing completes in ~146–200 seconds.
466
- - Video, metrics, logs, gallery, chart, map display.
467
- - Download buttons for:
468
- - `data_lake_submission.json`
469
- - `captured_frames.zip` (~35 images)
470
- - `flight_logs.zip` (CSVs)
471
- - `processed_output.mp4`
472
- - Logs show frame timings, non-12 MP warnings.
473
- - Check `app.log` for frame-level timings if issues persist.
474
-
475
- 3. **Test with 12 MP Video**:
476
- - Upload a 12 MP video (e.g., 4000x3000).
477
- - Set sliders to 4000x3000, `frame_skip=5`.
478
- - Expect longer processing (~5000 seconds on CPU).
479
- - Confirm downloads and no warnings.
480
-
481
- ### Notes
482
- - **Input Video**:
483
- - Please confirm the current video’s resolution, frame count, and duration. If it’s not 768x432 with 633 frames, the slowdown is expected.
484
- - Use `ffmpeg -i input_video.mp4` or check logs for details.
485
-
486
- - **Performance**:
487
- - CPU is slow for 12 MP videos. Enable GPU in Space settings.
488
- - If `frame_skip=1`, set it back to 5 for faster processing.
489
-
490
- - **NHAI Compliance**:
491
- - 768x432 is non-compliant (12 MP required). Use 12 MP for production.
492
- - Retrain model for Annexure-III’s 18 classes.
493
-
494
- - **Codec**:
495
- - If codec warnings persist, install `opencv-python-headless` with FFmpeg support.
496
-
497
- If processing is still slow (>200 seconds for 768x432), share the latest logs or video details (resolution, frames), and I’ll debug further!
 
405
 
406
  if __name__ == "__main__":
407
  iface.launch()
408
+