syed-baqir-kazmi/fire_smoke
0
๐ฅ RTSP CCTV Fire & Smoke Detection System
An enterprise-grade Fire & Smoke Detection web service for live CCTV RTSP streams, featuring automatic cloud snapshot uploads and browser-native web streaming for overall surveillance system integration.
Designed for seamless deployment to Hugging Face Spaces (Docker SDK) or local dockerized surveillance environments.
๐ Features
- Live RTSP Stream Transcoding for Web Browsers: Decodes RTSP feeds and transcodes them into high-speed browser-compatible MJPEG streams (
GET /video_feed) viewable in any modern web browser or mobile client! - YOLO Deep Learning Inference: Pre-trained on fire and smoke object detection.
- Temporal Hysteresis Confirmation:
- Fire: 5 enter frames, 15 exit frames.
- Smoke: 5 enter frames, 15 exit frames.
- Automated Cloud Snapshot Upload: Automatically uploads hazard snapshots to cloud storage when incidents are detected.
- Surveillance System REST & Streaming API:
GET /: Interactive Live Browser Surveillance Dashboard & Web Video StreamGET /status: Current system detection state, FPS, bounding box coordinates, and metricsGET /video_feed: High-speed MJPEG stream with live detection overlays for web integrationGET /latest_frame.jpg: Latest annotated frame image snapshotGET /incidents: Recent incident history log with cloud image URLsPOST /detect: Synchronous image upload endpoint for on-demand fire/smoke inspectionPOST /config: Dynamic RTSP stream URL and threshold updates on the fly
๐ Project Structure
rtsp_huggingface/
โโโ app.py # FastAPI web server & browser dashboard
โโโ rtsp_detector.py # Threaded RTSP stream engine & YOLO detector
โโโ config.py # System configuration reader
โโโ requirements.txt # Hugging Face deployment dependencies
โโโ Dockerfile # Production Docker container setup for HF Spaces (Port 7860)
โโโ .env # Environment configuration file
โโโ .env.example # Environment template for HF Space Secrets
โโโ README.md # HF Space metadata & documentation
โโโ models/ # Model weights directory
โโโ fire.pt # PyTorch YOLO model weights
โโโ fire_openvino_model/๐ก Overall Surveillance System API Endpoints
1. Fetch System Status
- Endpoint:
GET /status
2. Live Web Video Feed (Browser Native MJPEG)
- Endpoint:
GET /video_feed - Usage: Embed directly in standard HTML
<img>elements:
<img src="https://syed-baqir-kazmi-fire-smoke.hf.space/video_feed" width="100%">3. Get Latest Snapshot Image
- Endpoint:
GET /latest_frame.jpg
4. Fetch Incident History
- Endpoint:
GET /incidents
5. Instant Image Inspection (REST Inference)
- Endpoint:
POST /detect
