How shashanknalkande1/fire-detection works
1. System shape
This repo is a small, self-contained Flask web application for fire detection. The main runtime appears to live under fire webapp/, with a browser-based UI, server-side image handling, and YOLO-based inference.
2. Primary entry point
fire webapp/app.py is the core application boundary. It likely hosts the Flask routes, accepts uploads, calls the detection pipeline, and returns rendered results to the browser.
3. UI layer
templates/index.html is the only visible template, so the front end is probably a single-page server-rendered form/result view rather than a separate SPA. The browser submits an image and receives a results page back from Flask.
4. Upload and output flow
The app uses the local filesystem as its working store:
- uploads/ holds incoming images
- detected_outputs/ holds images after inference and annotation
This means the request flow is likely: browser upload → save to disk → run model → write annotated output → display/download result.
5. Detection pipeline
The repository is built around YOLO via Ultralytics, plus torch, torchvision, opencv-python, and Pillow. That implies the detection step is image-based object detection/annotation, with OpenCV/Pillow handling image I/O and Ultralytics/Torch handling model execution.
6. Configuration boundary
fire webapp/.env suggests the app is configured through environment variables rather than hardcoded paths. Based on the README, these likely include the YOLO model path and folder locations for uploads and outputs. That makes model selection and storage paths runtime-configurable.
7. Secondary execution path
fire webapp/detect_fire_terminal.py indicates a non-web/CLI detection path exists alongside the Flask app. Architecturally, this is likely a shared inference utility or alternate entry point for running detection from the terminal without the web UI.
8. Observability
fire webapp/debug.log shows the app writes runtime logs to a local file. This is the main observability artifact in the repo; there is no evidence of external logging, monitoring, or telemetry services.
9. Data assets
fire_dataset.zip appears to be an offline dataset artifact, probably used for training or testing the fire detector rather than live inference. It is not part of the request/response runtime path, but it matters for model development.
10. Dependency stack
requirements.txt and the README point to a Python stack centered on Flask + Ultralytics + PyTorch. There is no sign of a database, queue, cache, or separate backend service, so the architecture is mostly monolithic and local-process.
11. Key architectural boundary
The important boundary for a diagram is between:
- Browser/UI: uploads image and shows results
- Flask app / inference layer: receives request, stores files, runs YOLO, formats response
- Local filesystem: persists uploads, outputs, and logs
12. What is not present
There is no visible sign of:
- a relational database
- user authentication
- async job processing
- cloud storage
- external APIs
So the system is best represented as a single-server image inference web app with filesystem-backed intermediate storage.
Main entry points: app.py Flask App · detected_outputs Outputs · detect_fire_terminal.py Terminal Run · requirements.txt Deps
Components 15
Web App
Flask runtime, UI, and inference entry points.
- Env · Environment-based configuration for paths and model settings.
fire webapp/.env - Flask App · Main application boundary that handles requests and responses.
fire webapp/app.py - Index View · Browser-facing upload and results page.
fire webapp/templates/index.html - Terminal Run · Command-line detection path outside the web UI.
fire webapp/detect_fire_terminal.py
Local Storage
Filesystem-backed inputs, outputs, and logs used at runtime.
Data Assets
Project data and package metadata.
Other components
- Browser · User submits an image and views detection results.
- Filesystem · Host filesystem used for uploads, outputs, logs, and assets.
- YOLO Model · Fire detection model executed through Ultralytics and PyTorch.
- Image I/O · Image loading, saving, and annotation helpers.
- Torch Stack · PyTorch and related runtime used for model execution.
Connections 19
- Browser → Index View: open form · User loads the upload/result page.
- Browser → Flask App: submit image · Browser sends an uploaded image to Flask.
- Flask App → Env: read config · Flask reads runtime paths and model settings.
- Flask App → Uploads: save upload · Incoming image is persisted to the uploads folder.
- Flask App → YOLO Model: run detection · Application invokes the fire detector on the image.
- YOLO Model → Torch Stack: execute model · YOLO inference runs on the Torch runtime.
- YOLO Model → Image I/O: annotate image · Detection results are drawn onto the image.
- Image I/O → Outputs: write result · Annotated output image is written to disk.
- Flask App → Outputs: render result · Flask returns or links the generated detection output.
- Flask App → Debug Log: log events · Application writes debug information locally.
- Terminal Run → YOLO Model: run detection · Terminal entry point reuses the detection pipeline.
- Terminal Run → Outputs: write result · CLI path can persist annotated output images.
- Dataset → YOLO Model: train/eval source · Dataset supports model development rather than live requests.
- Deps → Flask App: install deps · Declared packages support the web app runtime.
- Deps → YOLO Model: model stack · Dependencies include the Ultralytics and Torch inference stack.
- Filesystem → Uploads: hosts · Uploads directory lives on the local filesystem.
- Filesystem → Outputs: hosts · Detected outputs are stored on the local filesystem.
- Filesystem → Debug Log: hosts · Debug log is written to the local filesystem.
- Filesystem → Dataset: stores · Dataset archive is a repository-local file artifact.