Downloads · 30 days
0
Luwayy/disaster-prediction
disaster-prediction is a machine learning model from Luwayy. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for tf-keras.
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 i…
Downloads · 30 days
0
Access
Public
Updated Mar 26, 2025
Repo size
222 MB
Likes
0
Public
Click a slice to open those files.
.png491 MB · 80%
From the Hugging Face model README
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.
image-classification# Install Git LFS (if not already installed)
git lfs install
# Clone the repository
git clone https://huggingface.co/Luwayy/disaster-prediction
The model predicts one of the following disaster categories:
| ID | Class Name |
|---|---|
| 0 | Damaged_Infrastructure |
| 1 | Fire_Disaster |
| 2 | Human_Damage |
| 3 | Land_Disaster |
| 4 | Non_Damage |
| 5 | Water_Disaster |
import keras
import numpy as np
from PIL import Image
import requests
from io import BytesIO
# Load the model
model = keras.layers.TFSMLayer(
"disaster-prediction/kaggle/working/disaster_model",
call_endpoint="serving_default"
)
# Load and preprocess image
url = 'https://www.spml.co.in/Images/blog/wdt&c-152776632.jpg'
response = requests.get(url)
img = Image.open(BytesIO(response.content)).convert("RGB").resize((256, 256))
img_array = np.array(img) / 255.0
img_array = np.expand_dims(img_array, axis=0).astype(np.float32)
# Predict
output = model(img_array)
preds = list(output.values())[0].numpy()
pred_index = np.argmax(preds)
# Class labels
labels = [
"Damaged_Infrastructure",
"Fire_Disaster",
"Human_Damage",
"Land_Disaster",
"Non_Damage",
"Water_Disaster"
]
print("Predicted class:", labels[pred_index])