zeroFire / README.md
Neylton's picture
Upload README.md
59228b6 verified
---
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.