CoolFace
Apppublic

syed-baqir-kazmi/fire_smoke

sourceHugging Facemitupdated 2mo agoView on Hugging Face
0likes
App README

๐Ÿ”ฅ 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 Stream
  • โ€”GET /status: Current system detection state, FPS, bounding box coordinates, and metrics
  • โ€”GET /video_feed: High-speed MJPEG stream with live detection overlays for web integration
  • โ€”GET /latest_frame.jpg: Latest annotated frame image snapshot
  • โ€”GET /incidents: Recent incident history log with cloud image URLs
  • โ€”POST /detect: Synchronous image upload endpoint for on-demand fire/smoke inspection
  • โ€”POST /config: Dynamic RTSP stream URL and threshold updates on the fly

๐Ÿ“ Project Structure

text
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:
html
<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