prithivMLmods commited on
Commit
ddd4469
·
verified ·
1 Parent(s): 90b6c75

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +108 -0
README.md CHANGED
@@ -15,3 +15,111 @@ tags:
15
  ---
16
 
17
  ![zdfbdzf.png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/rrxsJzH4HCNufCCb9duMQ.png)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  ---
16
 
17
  ![zdfbdzf.png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/rrxsJzH4HCNufCCb9duMQ.png)
18
+
19
+
20
+ # **Fire-Risk-Detection**
21
+
22
+ > **Fire-Risk-Detection** is a multi-class image classification model based on `google/siglip2-base-patch16-224`, trained to detect **fire risk levels** in geographical or environmental imagery. This model can be used for **wildfire monitoring**, **forest management**, and **environmental safety**.
23
+
24
+ ---
25
+
26
+ ```py
27
+ Classification Report:
28
+ precision recall f1-score support
29
+
30
+ high 0.4430 0.3382 0.3835 6296
31
+ low 0.3666 0.2296 0.2824 10705
32
+ moderate 0.3807 0.3757 0.3782 8617
33
+ non-burnable 0.8429 0.8385 0.8407 17959
34
+ very_high 0.3920 0.3400 0.3641 3268
35
+ very_low 0.6068 0.7856 0.6847 21757
36
+ water 0.9241 0.7744 0.8427 1729
37
+
38
+ accuracy 0.6032 70331
39
+ macro avg 0.5652 0.5260 0.5395 70331
40
+ weighted avg 0.5860 0.6032 0.5878 70331
41
+ ```
42
+
43
+ ![download.png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/ZFECguZt7jRW7mF5ZjlH1.png)
44
+
45
+ ## **Label Classes**
46
+
47
+ The model distinguishes between the following fire risk levels:
48
+
49
+ ```
50
+ 0: high
51
+ 1: low
52
+ 2: moderate
53
+ 3: non-burnable
54
+ 4: very_high
55
+ 5: very_low
56
+ 6: water
57
+ ```
58
+
59
+ ---
60
+
61
+ ## **Installation**
62
+
63
+ ```bash
64
+ pip install transformers torch pillow gradio
65
+ ```
66
+
67
+ ---
68
+
69
+ ## **Example Inference Code**
70
+
71
+ ```python
72
+ import gradio as gr
73
+ from transformers import AutoImageProcessor, SiglipForImageClassification
74
+ from PIL import Image
75
+ import torch
76
+
77
+ # Load model and processor
78
+ model_name = "prithivMLmods/Fire-Risk-Detection"
79
+ model = SiglipForImageClassification.from_pretrained(model_name)
80
+ processor = AutoImageProcessor.from_pretrained(model_name)
81
+
82
+ # ID to label mapping
83
+ id2label = {
84
+ "0": "high",
85
+ "1": "low",
86
+ "2": "moderate",
87
+ "3": "non-burnable",
88
+ "4": "very_high",
89
+ "5": "very_low",
90
+ "6": "water"
91
+ }
92
+
93
+ def detect_fire_risk(image):
94
+ image = Image.fromarray(image).convert("RGB")
95
+ inputs = processor(images=image, return_tensors="pt")
96
+
97
+ with torch.no_grad():
98
+ outputs = model(**inputs)
99
+ logits = outputs.logits
100
+ probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
101
+
102
+ prediction = {id2label[str(i)]: round(probs[i], 3) for i in range(len(probs))}
103
+ return prediction
104
+
105
+ # Gradio Interface
106
+ iface = gr.Interface(
107
+ fn=detect_fire_risk,
108
+ inputs=gr.Image(type="numpy"),
109
+ outputs=gr.Label(num_top_classes=7, label="Fire Risk Level"),
110
+ title="Fire-Risk-Detection",
111
+ description="Upload an image to classify the fire risk level: very_low, low, moderate, high, very_high, non-burnable, or water."
112
+ )
113
+
114
+ if __name__ == "__main__":
115
+ iface.launch()
116
+ ```
117
+
118
+ ---
119
+
120
+ ## **Applications**
121
+
122
+ * **Wildfire Early Warning Systems**
123
+ * **Environmental Monitoring**
124
+ * **Land Use Assessment**
125
+ * **Disaster Preparedness and Mitigation**