Update README.md
Browse files
README.md
CHANGED
|
@@ -1,7 +1,83 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 🌍 Disaster Prediction Model
|
| 2 |
+
|
| 3 |
+
This repository contains a deep learning model for **disaster classification** from images, capable of identifying six disaster-related categories including fire, water damage, infrastructure damage, and more. The model is built using **ResNet50** and trained for image classification tasks.
|
| 4 |
+
|
| 5 |
+
## 🧠 Model Details
|
| 6 |
+
|
| 7 |
+
- **Architecture**: ResNet50
|
| 8 |
+
- **Trained On**: Kaggle Disaster Dataset
|
| 9 |
+
- **Image Size**: 256x256
|
| 10 |
+
- **Input**: RGB image
|
| 11 |
+
- **Output**: Disaster category
|
| 12 |
+
- **License**: MIT
|
| 13 |
+
- **Pipeline Tag**: `image-classification`
|
| 14 |
+
- **Main Metric**: Accuracy
|
| 15 |
+
|
| 16 |
+
## 📦 Installation & Cloning
|
| 17 |
+
|
| 18 |
+
```bash
|
| 19 |
+
# Install Git LFS (if not already installed)
|
| 20 |
+
git lfs install
|
| 21 |
+
|
| 22 |
+
# Clone the repository
|
| 23 |
+
git clone https://huggingface.co/Luwayy/disaster-prediction
|
| 24 |
+
```
|
| 25 |
+
|
| 26 |
+
## 🔍 Classes
|
| 27 |
+
|
| 28 |
+
The model predicts one of the following disaster categories:
|
| 29 |
+
|
| 30 |
+
| ID | Class Name |
|
| 31 |
+
|----|-------------------------|
|
| 32 |
+
| 0 | Damaged_Infrastructure |
|
| 33 |
+
| 1 | Fire_Disaster |
|
| 34 |
+
| 2 | Human_Damage |
|
| 35 |
+
| 3 | Land_Disaster |
|
| 36 |
+
| 4 | Non_Damage |
|
| 37 |
+
| 5 | Water_Disaster |
|
| 38 |
+
|
| 39 |
+
## 📸 Example Usage (Python)
|
| 40 |
+
|
| 41 |
+
```python
|
| 42 |
+
import keras
|
| 43 |
+
import numpy as np
|
| 44 |
+
from PIL import Image
|
| 45 |
+
import requests
|
| 46 |
+
from io import BytesIO
|
| 47 |
+
|
| 48 |
+
# Load the model
|
| 49 |
+
model = keras.layers.TFSMLayer(
|
| 50 |
+
"disaster-prediction/kaggle/working/disaster_model",
|
| 51 |
+
call_endpoint="serving_default"
|
| 52 |
+
)
|
| 53 |
+
|
| 54 |
+
# Load and preprocess image
|
| 55 |
+
url = 'https://www.spml.co.in/Images/blog/wdt&c-152776632.jpg'
|
| 56 |
+
response = requests.get(url)
|
| 57 |
+
img = Image.open(BytesIO(response.content)).convert("RGB").resize((256, 256))
|
| 58 |
+
img_array = np.array(img) / 255.0
|
| 59 |
+
img_array = np.expand_dims(img_array, axis=0).astype(np.float32)
|
| 60 |
+
|
| 61 |
+
# Predict
|
| 62 |
+
output = model(img_array)
|
| 63 |
+
preds = list(output.values())[0].numpy()
|
| 64 |
+
pred_index = np.argmax(preds)
|
| 65 |
+
|
| 66 |
+
# Class labels
|
| 67 |
+
labels = [
|
| 68 |
+
"Damaged_Infrastructure",
|
| 69 |
+
"Fire_Disaster",
|
| 70 |
+
"Human_Damage",
|
| 71 |
+
"Land_Disaster",
|
| 72 |
+
"Non_Damage",
|
| 73 |
+
"Water_Disaster"
|
| 74 |
+
]
|
| 75 |
+
|
| 76 |
+
print("Predicted class:", labels[pred_index])
|
| 77 |
+
```
|
| 78 |
+
|
| 79 |
+
## ⚙️ Preprocessing
|
| 80 |
+
|
| 81 |
+
- **Resize**: (256, 256)
|
| 82 |
+
- **Scale**: Normalize pixel values by dividing by 255
|
| 83 |
+
|