Luwayy commited on
Commit
8389ac9
·
verified ·
1 Parent(s): 1615e64

create Readme.md

Browse files
Files changed (1) hide show
  1. README.md +80 -0
README.md ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 🌍 Disaster Image Classification using Vision Transformer
2
+
3
+ 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.
4
+
5
+ ---
6
+
7
+ ## 🚀 Installation
8
+
9
+ Install the required Python packages:
10
+
11
+ ```bash
12
+ pip install transformers torch torchvision pillow requests
13
+ ```
14
+
15
+ ---
16
+
17
+ ## 🔍 Quick Start
18
+
19
+ Use the pipeline to classify an image directly from a URL:
20
+
21
+ ```python
22
+ from transformers import pipeline
23
+ from PIL import Image
24
+ import requests
25
+ from io import BytesIO
26
+
27
+ # Load the image classification pipeline
28
+ pipe = pipeline("image-classification", model="Luwayy/disaster_images_model")
29
+
30
+ # Load an image from a URL
31
+ url = 'https://www.spml.co.in/Images/blog/wdt&c-152776632.jpg'
32
+ response = requests.get(url)
33
+ image = Image.open(BytesIO(response.content))
34
+
35
+ # Classify the image
36
+ results = pipe(image)
37
+
38
+ # Print results
39
+ print(results)
40
+ ```
41
+
42
+ **Example Output:**
43
+ ```json
44
+ [
45
+ {"label": "Water_Disaster", "score": 0.9184},
46
+ {"label": "Land_Disaster", "score": 0.0200},
47
+ {"label": "Non_Damage", "score": 0.0169},
48
+ {"label": "Human_Damage", "score": 0.0164},
49
+ {"label": "Fire_Disaster", "score": 0.0143}
50
+ ]
51
+ ```
52
+
53
+ ---
54
+
55
+ ## 🧠 Model Details
56
+
57
+ - **Base Model:** `google/vit-base-patch16-224-in21k`
58
+ - **Architecture:** Vision Transformer (`ViTForImageClassification`)
59
+ - **Image Size:** 224x224
60
+ - **Classes:**
61
+ - `Damaged_Infrastructure`
62
+ - `Fire_Disaster`
63
+ - `Human_Damage`
64
+ - `Land_Disaster`
65
+ - `Non_Damage`
66
+ - `Water_Disaster`
67
+
68
+ ---
69
+
70
+ ## ⚙️ Training Configuration
71
+
72
+ - **Image Normalization:** Mean `[0.5, 0.5, 0.5]`, Std `[0.5, 0.5, 0.5]`
73
+ - **Resize Method:** Bilinear to `224x224`
74
+ - **Augmentations:** Resize, Normalize, Convert to Tensor
75
+ - **Batch Size:** 16
76
+ - **Epochs:** 3
77
+ - **Learning Rate:** `3e-5`
78
+ - **Weight Decay:** `0.01`
79
+ - **Evaluation Strategy:** Per epoch
80
+