File size: 5,532 Bytes
59228b6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
---

title: ZeroFire - AI Fire Detection System
emoji: πŸ”₯
colorFrom: red
colorTo: yellow
sdk: streamlit
sdk_version: 1.28.1
app_file: app.py
pinned: false
license: mit
python_version: 3.9
---


# πŸ”₯ zeroFire - AI-Powered Fire Detection System

Advanced fire detection system for data centers using ConvNeXt deep learning architecture with transfer learning.

## πŸš€ Features

- **Real-time Fire Detection**: Instant fire and smoke detection in data center environments
- **Advanced AI Model**: ConvNeXt Large architecture with transfer learning
- **Safety-Focused**: Weighted loss function prioritizing fire detection (minimizing false negatives)
- **Interactive Web Interface**: Beautiful Streamlit GUI for easy operation
- **Comprehensive Analysis**: Detailed risk assessment and safety recommendations
- **Emergency Response**: Built-in emergency protocols and contact information

## πŸ“Š Model Performance

- **Architecture**: ConvNeXt Large + Custom Classification Head
- **Training**: Safety-focused with class weighting (Fire: 2.0, No-Fire: 1.0)
- **Data**: 80/20 train/validation split with data augmentation
- **Optimization**: AdamW optimizer with cosine annealing scheduler

## πŸ› οΈ Installation

1. **Clone the repository**:
```bash

git clone <repository-url>

cd zeroFire

```

2. **Install dependencies**:
```bash

pip install -r requirements.txt

```

3. **Prepare your data**: Ensure your data is organized in the following structure:
```

data/

β”œβ”€β”€ train/

β”‚   β”œβ”€β”€ fire/        # Fire images

β”‚   └── no_fire/     # No-fire images

└── val/

    β”œβ”€β”€ fire/        # Validation fire images

    └── no_fire/     # Validation no-fire images

```

## πŸ”₯ Usage

### Training the Model

Train the fire detection model:
```bash

python train_fire_detection.py --epochs 50 --batch_size 16 --freeze_backbone

```

### Running the Web Interface

Start the Streamlit application:
```bash

streamlit run app.py

```

### Command Line Training Options

```bash

python train_fire_detection.py --help

```

Options:
- `--data_dir`: Path to data directory (default: 'data')
- `--batch_size`: Batch size for training (default: 16)
- `--epochs`: Number of training epochs (default: 50)
- `--learning_rate`: Learning rate (default: 1e-4)
- `--freeze_backbone`: Freeze backbone for transfer learning

## πŸ“ Project Structure

```

zeroFire/

β”œβ”€β”€ app.py                     # Streamlit web interface

β”œβ”€β”€ train_fire_detection.py    # Training script

β”œβ”€β”€ requirements.txt           # Dependencies

β”œβ”€β”€ README.md                 # This file

β”œβ”€β”€ utils/

β”‚   β”œβ”€β”€ model_utils.py        # Model utilities

β”‚   └── data_utils.py         # Data handling utilities

β”œβ”€β”€ data/                     # Dataset directory

β”‚   β”œβ”€β”€ train/

β”‚   β”‚   β”œβ”€β”€ fire/

β”‚   β”‚   └── no_fire/

β”‚   └── val/

β”‚       β”œβ”€β”€ fire/

β”‚       └── no_fire/

└── models/                   # Trained models directory

    └── fire_detection_classifier.pth

```

## 🎯 Safety Features

- **Class Weighting**: Fire class weighted 2x to minimize false negatives
- **Risk Assessment**: Multi-level risk analysis (Safe, Caution, Moderate, High, Critical)
- **Emergency Protocols**: Built-in emergency response recommendations
- **Real-time Monitoring**: Continuous confidence scoring and safety metrics

## πŸ“Š Data Requirements

- **Minimum**: 500+ images per class
- **Recommended**: 1000+ images per class
- **Formats**: JPG, PNG, BMP, TIFF
- **Size**: Images automatically resized to 224x224
- **Quality**: Clear, well-lit images with proper labeling

## πŸ”§ Technical Details

- **Framework**: PyTorch with timm library
- **Architecture**: ConvNeXt Large (Facebook AI)
- **Input Size**: 224x224 RGB images
- **Preprocessing**: ImageNet normalization with data augmentation
- **Training**: Mixed precision training with gradient clipping

## 🚨 Emergency Response

The system provides automatic emergency response recommendations:

- **Critical (90%+)**: Immediate evacuation and fire suppression
- **High (75-90%)**: Rapid investigation and system preparation
- **Moderate (50-75%)**: Enhanced monitoring and verification
- **Caution (<50%)**: Increased vigilance and sensor checks

## πŸ“ž Support

For technical support or questions:
- Check the web interface for real-time system status
- Review training logs for model performance
- Monitor confidence scores for prediction reliability

## πŸ† Performance Metrics

The system tracks:
- **Accuracy**: Overall classification accuracy
- **Precision**: Fire detection precision (minimize false positives)
- **Recall**: Fire detection recall (minimize false negatives)
- **F1-Score**: Balanced performance metric
- **Confusion Matrix**: Detailed classification results

## πŸ”’ Safety Considerations

- This system is designed as a supplementary fire detection tool
- Always maintain primary fire detection systems
- Regularly validate model performance with new data
- Update emergency contact information in the application
- Test system response procedures regularly

---

**⚠️ Important**: This AI system is designed to assist with fire detection but should not replace professional fire safety equipment and procedures. Always follow local fire safety regulations and maintain proper fire suppression systems.