# 🌍 Disaster Image Classification using Vision Transformer

This project uses a fine-tuned Vision Transformer (ViT) model to classify disaster-related images into various categories such as **Water Disaster**, **Fire Disaster**, **Human Damage**, etc.

---

## 🚀 Installation

Install the required Python packages:

```bash
pip install transformers torch torchvision pillow requests
```

---

## 🔍 Quick Start

Use the pipeline to classify an image directly from a URL:

```python
from transformers import pipeline
from PIL import Image
import requests
from io import BytesIO

# Load the image classification pipeline
pipe = pipeline("image-classification", model="Luwayy/disaster_images_model")

# Load an image from a URL
url = 'https://www.spml.co.in/Images/blog/wdt&c-152776632.jpg'
response = requests.get(url)
image = Image.open(BytesIO(response.content))

# Classify the image
results = pipe(image)

# Print results
print(results)
```

**Example Output:**
```json
[
  {"label": "Water_Disaster", "score": 0.9184},
  {"label": "Land_Disaster", "score": 0.0200},
  {"label": "Non_Damage", "score": 0.0169},
  {"label": "Human_Damage", "score": 0.0164},
  {"label": "Fire_Disaster", "score": 0.0143}
]
```

---

## 🧠 Model Details

- **Base Model:** `google/vit-base-patch16-224-in21k`
- **Architecture:** Vision Transformer (`ViTForImageClassification`)
- **Image Size:** 224x224
- **Classes:**
  - `Damaged_Infrastructure`
  - `Fire_Disaster`
  - `Human_Damage`
  - `Land_Disaster`
  - `Non_Damage`
  - `Water_Disaster`

---

## ⚙️ Training Configuration

- **Image Normalization:** Mean `[0.5, 0.5, 0.5]`, Std `[0.5, 0.5, 0.5]`
- **Resize Method:** Bilinear to `224x224`
- **Augmentations:** Resize, Normalize, Convert to Tensor
- **Batch Size:** 16
- **Epochs:** 3
- **Learning Rate:** `3e-5`
- **Weight Decay:** `0.01`
- **Evaluation Strategy:** Per epoch


damaged_infrastructure fire_disaster human_damage land_disaster non_damage water_disaster