|
|
---
|
|
|
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. |