Downloads · 30 days
108
7% of all-time downloads
Luwayy/disaster_images_model
disaster_images_model is a image classification model from Luwayy. Use it when you need a label for an image. It is set up for transformers.
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.
Downloads · 30 days
108
7% of all-time downloads
All-time downloads
1.6K
Public
Parameters
85.8M
3.1 GB on disk
Likes
0
Public
Click a slice to open those files.
.pt2.1 GB · 60%
From the Hugging Face model README
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.
Install the required Python packages:
pip install transformers torch torchvision pillow requests
Use the pipeline to classify an image directly from a URL:
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:
[
{"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}
]
google/vit-base-patch16-224-in21kViTForImageClassification)Damaged_InfrastructureFire_DisasterHuman_DamageLand_DisasterNon_DamageWater_Disaster[0.5, 0.5, 0.5], Std [0.5, 0.5, 0.5]224x2243e-50.01