# deepankarvarma/fire-detection--opencv-keras-tensorflow architecture

> Architecture diagram of the GitHub repository deepankarvarma/fire-detection--opencv-keras-tensorflow, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/deepankarvarma/fire-detection--opencv-keras-tensorflow
- Repository: https://github.com/deepankarvarma/fire-detection--opencv-keras-tensorflow

## Overview

This repository trains a binary fire classifier and uses the saved model in two inference paths: a Streamlit image-upload app and a local video-frame detector. Training reads labeled image folders, prepares and splits the data, defines and fits a CNN, then saves the model artifact. The README documents image classification; the sampled code also implements video inference. The training, display, and thresholding behavior is visible in the excerpts; no additional application services are indicated.

Main entry points: [`app.py`](https://github.com/deepankarvarma/fire-detection--opencv-keras-tensorflow/blob/master/app.py) (Streamlit app), [`predictlocally.py`](https://github.com/deepankarvarma/fire-detection--opencv-keras-tensorflow/blob/master/predictlocally.py) (Video frame detector), [`fire_detection_model.h5`](https://github.com/deepankarvarma/fire-detection--opencv-keras-tensorflow/blob/master/fire_detection_model.h5) (Trained model), [`model.py`](https://github.com/deepankarvarma/fire-detection--opencv-keras-tensorflow/blob/master/model.py) (Load and split data)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_training["Model training"]
  node_prepare["Load and split data<br/>[model.py]"]
  node_architecture["CNN architecture<br/>[model.py]"]
  node_fit["Train classifier<br/>[model.py]"]
end

subgraph group_image["Image inference"]
  node_image_app["Streamlit app<br/>[app.py]"]
  node_image_prep["Image preprocessing<br/>[app.py]"]
  node_image_result["Image prediction result<br/>[app.py]"]
end

subgraph group_video["Video inference"]
  node_video_runner["Video frame detector<br/>[predictlocally.py]"]
end

node_dataset["Fire dataset"]
node_model_file["Trained model"]
node_user(("Image uploader"))
node_video_file["Sample video<br/>[fire.mp4]"]
node_display["Video display"]

node_dataset -->|"provides images"| node_prepare
node_prepare -->|"feeds training"| node_architecture
node_architecture -->|"defines network"| node_fit
node_fit -->|"saves model"| node_model_file
node_user -->|"uploads image"| node_image_app
node_image_app -->|"loads model"| node_model_file
node_image_app -->|"preprocesses image"| node_image_prep
node_image_app -->|"predicts and displays"| node_image_result
node_video_file -->|"provides frames"| node_video_runner
node_video_runner -->|"loads model"| node_model_file
node_video_runner -->|"shows annotated frames"| node_display

click node_prepare "https://github.com/deepankarvarma/fire-detection--opencv-keras-tensorflow/blob/master/model.py"
click node_architecture "https://github.com/deepankarvarma/fire-detection--opencv-keras-tensorflow/blob/master/model.py"
click node_fit "https://github.com/deepankarvarma/fire-detection--opencv-keras-tensorflow/blob/master/model.py"
click node_model_file "https://github.com/deepankarvarma/fire-detection--opencv-keras-tensorflow/blob/master/fire_detection_model.h5"
click node_image_app "https://github.com/deepankarvarma/fire-detection--opencv-keras-tensorflow/blob/master/app.py"
click node_image_prep "https://github.com/deepankarvarma/fire-detection--opencv-keras-tensorflow/blob/master/app.py"
click node_image_result "https://github.com/deepankarvarma/fire-detection--opencv-keras-tensorflow/blob/master/app.py"
click node_video_file "https://github.com/deepankarvarma/fire-detection--opencv-keras-tensorflow/blob/master/fire.mp4"
click node_video_runner "https://github.com/deepankarvarma/fire-detection--opencv-keras-tensorflow/blob/master/predictlocally.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_prepare,node_architecture,node_fit toneBlue
class node_image_app,node_image_prep,node_image_result toneAmber
class node_video_runner toneMint
class node_dataset,node_model_file,node_user,node_display toneIndigo
class node_video_file toneTeal
```

## Components

### Model training

- [Load and split data](https://github.com/deepankarvarma/fire-detection--opencv-keras-tensorflow/blob/master/model.py): `model.py`
- [CNN architecture](https://github.com/deepankarvarma/fire-detection--opencv-keras-tensorflow/blob/master/model.py): `model.py`
- [Train classifier](https://github.com/deepankarvarma/fire-detection--opencv-keras-tensorflow/blob/master/model.py): `model.py`

### Image inference

- [Streamlit app](https://github.com/deepankarvarma/fire-detection--opencv-keras-tensorflow/blob/master/app.py): `app.py`
- [Image preprocessing](https://github.com/deepankarvarma/fire-detection--opencv-keras-tensorflow/blob/master/app.py): `app.py`
- [Image prediction result](https://github.com/deepankarvarma/fire-detection--opencv-keras-tensorflow/blob/master/app.py): `app.py`

### Video inference

- [Video frame detector](https://github.com/deepankarvarma/fire-detection--opencv-keras-tensorflow/blob/master/predictlocally.py): `predictlocally.py`

### Other components

- **Fire dataset**
- [Trained model](https://github.com/deepankarvarma/fire-detection--opencv-keras-tensorflow/blob/master/fire_detection_model.h5): `fire_detection_model.h5`
- **Image uploader**
- [Sample video](https://github.com/deepankarvarma/fire-detection--opencv-keras-tensorflow/blob/master/fire.mp4): `fire.mp4`
- **Video display**

## Connections

- Fire dataset → Load and split data: provides images (evidence: `model.py`)
- Load and split data → CNN architecture: feeds training (evidence: `model.py`)
- CNN architecture → Train classifier: defines network (evidence: `model.py`)
- Train classifier → Trained model: saves model (evidence: `model.py`)
- Image uploader → Streamlit app: uploads image (evidence: `app.py`)
- Streamlit app → Trained model: loads model (evidence: `app.py`)
- Streamlit app → Image preprocessing: preprocesses image (evidence: `app.py`)
- Streamlit app → Image prediction result: predicts and displays (evidence: `app.py`)
- Sample video → Video frame detector: provides frames (evidence: `predictlocally.py`)
- Video frame detector → Trained model: loads model (evidence: `predictlocally.py`)
- Video frame detector → Video display: shows annotated frames (evidence: `predictlocally.py`)
