Instructions to use Luwayy/disaster-prediction with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- TF-Keras
How to use Luwayy/disaster-prediction with TF-Keras:
# Note: 'keras<3.x' or 'tf_keras' must be installed (legacy), and from_pretrained_keras was removed in huggingface_hub 1.0. # See https://github.com/keras-team/tf-keras for more details. # !pip install "huggingface_hub<1.0" tf_keras from huggingface_hub import from_pretrained_keras model = from_pretrained_keras("Luwayy/disaster-prediction") - Notebooks
- Google Colab
- Kaggle
|
Download README.md from Luwayy/disaster-prediction: direct link, hf CLI and curl.
- Browser
- Download file 2.13 kB
-
https://huggingface.co/Luwayy/disaster-prediction/resolve/main/README.md
- Command line
-
hf download hf://Luwayy/disaster-prediction/README.md
-
curl -L -o README.md https://huggingface.co/Luwayy/disaster-prediction/resolve/main/README.md
2.13 kB
| # 🌍 Disaster Prediction Model | |
| 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. | |
| ## 🧠 Model Details | |
| - **Architecture**: ResNet50 | |
| - **Trained On**: Kaggle Disaster Dataset | |
| - **Image Size**: 256x256 | |
| - **Input**: RGB image | |
| - **Output**: Disaster category | |
| - **License**: MIT | |
| - **Pipeline Tag**: `image-classification` | |
| - **Main Metric**: Accuracy | |
| ## 📦 Installation & Cloning | |
| ```bash | |
| # Install Git LFS (if not already installed) | |
| git lfs install | |
| # Clone the repository | |
| git clone https://huggingface.co/Luwayy/disaster-prediction | |
| ``` | |
| ## 🔍 Classes | |
| 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 | | |
| ## 📸 Example Usage (Python) | |
| ```python | |
| 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]) | |
| ``` | |
| ## ⚙️ Preprocessing | |
| - **Resize**: (256, 256) | |
| - **Scale**: Normalize pixel values by dividing by 255 | |