|
|
--- |
|
|
tags: |
|
|
- image-classification |
|
|
- forest-fire |
|
|
- keras |
|
|
- tensorflow |
|
|
datasets: |
|
|
- elmadafri/the-wildfire-dataset |
|
|
--- |
|
|
|
|
|
|
|
|
# 🔥 Forest Fire Detection Model |
|
|
|
|
|
This model detects forest fires in images using a deep learning CNN trained on the [Wildfire Dataset](https://www.kaggle.com/datasets/elmadafri/the-wildfire-dataset). |
|
|
|
|
|
## Model Details |
|
|
|
|
|
- **Architecture:** Sequential CNN with Conv2D, MaxPooling2D, Dense, Dropout layers. |
|
|
- **Input Size:** 150x150 RGB images |
|
|
- **Output:** Binary classification (`fire` or `nofire`) |
|
|
- **Framework:** TensorFlow / Keras |
|
|
|
|
|
## Training Data |
|
|
|
|
|
- **Dataset:** [The Wildfire Dataset](https://www.kaggle.com/datasets/elmadafri/the-wildfire-dataset) |
|
|
- **Classes:** `fire`, `nofire` |
|
|
- **Preprocessing:** Images resized to 150x150, normalized to [0, 1] |
|
|
|
|
|
## Training Script |
|
|
|
|
|
The model was trained using the following script (see attached notebook for full details): |
|
|
|
|
|
```python |
|
|
model = Sequential([ |
|
|
Input(shape=(150, 150, 3)), |
|
|
Conv2D(32, (3,3), activation='relu'), |
|
|
MaxPooling2D(pool_size=(2,2)), |
|
|
Conv2D(64, (3, 3), activation='relu'), |
|
|
MaxPooling2D(pool_size=(2, 2)), |
|
|
Conv2D(128, (3, 3), activation='relu'), |
|
|
MaxPooling2D(pool_size=(2, 2)), |
|
|
Flatten(), |
|
|
Dense(512, activation='relu'), |
|
|
Dropout(0.5), |
|
|
Dense(1, activation='sigmoid') |
|
|
]) |
|
|
model.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy']) |
|
|
model.fit(...) |
|
|
``` |
|
|
|
|
|
## Intended Use |
|
|
- **Use Case:** Automated detection of forest fires in aerial or ground images. |
|
|
- **Limitations:** Not suitable for video, may not generalize to all forest types or lighting conditions. |
|
|
|
|
|
## How to Use |
|
|
```python |
|
|
import requests |
|
|
|
|
|
API_URL = "https://api-inference.huggingface.co/models/YOUR_USERNAME/YOUR_MODEL_NAME" |
|
|
headers = {"Authorization": "Bearer YOUR_HF_API_TOKEN"} |
|
|
|
|
|
with open("your_image.jpg", "rb") as f: |
|
|
data = f.read() |
|
|
response = requests.post(API_URL, headers=headers, files={"file": data}) |
|
|
print(response.json()) |
|
|
``` |
|
|
|
|
|
## Evaluation |
|
|
- **Test Accuracy:** 70% |
|
|
- **Metrics:** Not suitable for video, may not generalize to all forest types or lighting conditions. |
|
|
|
|
|
## Citation |
|
|
If you use this model, please cite the dataset and this repository. |