Update README.md
Browse files
README.md
CHANGED
@@ -2,8 +2,28 @@
|
|
2 |
license: apache-2.0
|
3 |
datasets:
|
4 |
- TheNetherWatcher/DisasterClassification
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
---
|
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
```py
|
8 |
Classification Report:
|
9 |
precision recall f1-score support
|
@@ -17,3 +37,82 @@ Flooded Scene 0.9172 0.9458 0.9313 609
|
|
17 |
```
|
18 |
|
19 |

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
license: apache-2.0
|
3 |
datasets:
|
4 |
- TheNetherWatcher/DisasterClassification
|
5 |
+
language:
|
6 |
+
- en
|
7 |
+
base_model:
|
8 |
+
- google/siglip2-base-patch16-512
|
9 |
+
pipeline_tag: image-classification
|
10 |
+
library_name: transformers
|
11 |
+
tags:
|
12 |
+
- SigLIP2
|
13 |
+
- Flood-Detection
|
14 |
+
- Disaster-Detection
|
15 |
+
- climate
|
16 |
---
|
17 |
|
18 |
+

|
19 |
+
|
20 |
+
# Flood-Image-Detection
|
21 |
+
|
22 |
+
> Flood-Image-Detection is a vision-language encoder model fine-tuned from `google/siglip2-base-patch16-512` for **binary image classification**. It is trained to detect whether an image contains a **flooded scene** or **non-flooded** environment. The model uses the `SiglipForImageClassification` architecture.
|
23 |
+
|
24 |
+
> [!note]
|
25 |
+
SigLIP 2: Multilingual Vision-Language Encoders with Improved Semantic Understanding, Localization, and Dense Features : https://arxiv.org/pdf/2502.14786
|
26 |
+
|
27 |
```py
|
28 |
Classification Report:
|
29 |
precision recall f1-score support
|
|
|
37 |
```
|
38 |
|
39 |

|
40 |
+
|
41 |
+
|
42 |
+
---
|
43 |
+
|
44 |
+
## Label Space: 2 Classes
|
45 |
+
|
46 |
+
```
|
47 |
+
Class 0: Flooded Scene
|
48 |
+
Class 1: Non Flooded
|
49 |
+
```
|
50 |
+
|
51 |
+
---
|
52 |
+
|
53 |
+
## Install Dependencies
|
54 |
+
|
55 |
+
```bash
|
56 |
+
pip install -q transformers torch pillow gradio hf_xet
|
57 |
+
```
|
58 |
+
|
59 |
+
---
|
60 |
+
|
61 |
+
## Inference Code
|
62 |
+
|
63 |
+
```python
|
64 |
+
import gradio as gr
|
65 |
+
from transformers import AutoImageProcessor, SiglipForImageClassification
|
66 |
+
from PIL import Image
|
67 |
+
import torch
|
68 |
+
|
69 |
+
# Load model and processor
|
70 |
+
model_name = "prithivMLmods/flood-image-detection" # Update with actual model name on Hugging Face
|
71 |
+
model = SiglipForImageClassification.from_pretrained(model_name)
|
72 |
+
processor = AutoImageProcessor.from_pretrained(model_name)
|
73 |
+
|
74 |
+
# Updated label mapping
|
75 |
+
id2label = {
|
76 |
+
"0": "Flooded Scene",
|
77 |
+
"1": "Non Flooded"
|
78 |
+
}
|
79 |
+
|
80 |
+
def classify_image(image):
|
81 |
+
image = Image.fromarray(image).convert("RGB")
|
82 |
+
inputs = processor(images=image, return_tensors="pt")
|
83 |
+
|
84 |
+
with torch.no_grad():
|
85 |
+
outputs = model(**inputs)
|
86 |
+
logits = outputs.logits
|
87 |
+
probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
|
88 |
+
|
89 |
+
prediction = {
|
90 |
+
id2label[str(i)]: round(probs[i], 3) for i in range(len(probs))
|
91 |
+
}
|
92 |
+
|
93 |
+
return prediction
|
94 |
+
|
95 |
+
# Gradio Interface
|
96 |
+
iface = gr.Interface(
|
97 |
+
fn=classify_image,
|
98 |
+
inputs=gr.Image(type="numpy"),
|
99 |
+
outputs=gr.Label(num_top_classes=2, label="Flood Detection"),
|
100 |
+
title="Flood-Image-Detection",
|
101 |
+
description="Upload an image to detect whether the scene is flooded or not."
|
102 |
+
)
|
103 |
+
|
104 |
+
if __name__ == "__main__":
|
105 |
+
iface.launch()
|
106 |
+
```
|
107 |
+
|
108 |
+
---
|
109 |
+
|
110 |
+
## Intended Use
|
111 |
+
|
112 |
+
`Flood-Image-Detection` is designed for:
|
113 |
+
|
114 |
+
* **Disaster Monitoring** – Rapid detection of flood-affected areas from imagery.
|
115 |
+
* **Environmental Analysis** – Track flooding patterns across regions using image datasets.
|
116 |
+
* **Crisis Response** – Assist emergency services in identifying critical zones.
|
117 |
+
* **Surveillance and Safety** – Monitor infrastructure or locations for flood exposure.
|
118 |
+
* **Smart Alert Systems** – Integrate with IoT or camera feeds for automated flood alerts.
|