prithivMLmods commited on
Commit
466dc41
·
verified ·
1 Parent(s): 6d1de8c

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +101 -0
README.md CHANGED
@@ -2,7 +2,28 @@
2
  license: apache-2.0
3
  datasets:
4
  - Shravanig/fire_detection_final
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  ---
 
 
 
 
 
 
 
 
6
 
7
  ```py
8
  Classification Report:
@@ -18,3 +39,83 @@ weighted avg 0.9952 0.9952 0.9952 6060
18
  ```
19
 
20
  ![download (1).png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/xbB-O5F_pT10R9rLah_R3.png)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  license: apache-2.0
3
  datasets:
4
  - Shravanig/fire_detection_final
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
+ - Forest-Fire-Detection
13
+ - SigLIP2
14
+ - climate
15
+ - Smoke
16
+ - Normal
17
+ - Fire
18
  ---
19
+ ![4.png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/E4Cd-Kbj9wUkI9t_UOqE8.png)
20
+
21
+ # Forest-Fire-Detection
22
+
23
+ > `Forest-Fire-Detection` is a vision-language encoder model fine-tuned from `google/siglip2-base-patch16-512` for **multi-class image classification**. It is trained to detect whether an image contains **fire**, **smoke**, or a **normal** (non-fire) scene. The model uses the `SiglipForImageClassification` architecture.
24
+
25
+ > [!note]
26
+ SigLIP 2: Multilingual Vision-Language Encoders with Improved Semantic Understanding, Localization, and Dense Features : https://arxiv.org/pdf/2502.14786
27
 
28
  ```py
29
  Classification Report:
 
39
  ```
40
 
41
  ![download (1).png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/xbB-O5F_pT10R9rLah_R3.png)
42
+
43
+ ---
44
+
45
+ ## Label Space: 3 Classes
46
+
47
+ ```
48
+ Class 0: Fire
49
+ Class 1: Normal
50
+ Class 2: Smoke
51
+ ```
52
+
53
+ ---
54
+
55
+ ## Install Dependencies
56
+
57
+ ```bash
58
+ pip install -q transformers torch pillow gradio hf_xet
59
+ ```
60
+
61
+ ---
62
+
63
+ ## Inference Code
64
+
65
+ ```python
66
+ import gradio as gr
67
+ from transformers import AutoImageProcessor, SiglipForImageClassification
68
+ from PIL import Image
69
+ import torch
70
+
71
+ # Load model and processor
72
+ model_name = "prithivMLmods/forest-fire-detection" # Update with actual model name on Hugging Face
73
+ model = SiglipForImageClassification.from_pretrained(model_name)
74
+ processor = AutoImageProcessor.from_pretrained(model_name)
75
+
76
+ # Updated label mapping
77
+ id2label = {
78
+ "0": "Fire",
79
+ "1": "Normal",
80
+ "2": "Smoke"
81
+ }
82
+
83
+ def classify_image(image):
84
+ image = Image.fromarray(image).convert("RGB")
85
+ inputs = processor(images=image, return_tensors="pt")
86
+
87
+ with torch.no_grad():
88
+ outputs = model(**inputs)
89
+ logits = outputs.logits
90
+ probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
91
+
92
+ prediction = {
93
+ id2label[str(i)]: round(probs[i], 3) for i in range(len(probs))
94
+ }
95
+
96
+ return prediction
97
+
98
+ # Gradio Interface
99
+ iface = gr.Interface(
100
+ fn=classify_image,
101
+ inputs=gr.Image(type="numpy"),
102
+ outputs=gr.Label(num_top_classes=3, label="Forest Fire Detection"),
103
+ title="Forest-Fire-Detection",
104
+ description="Upload an image to detect whether the scene contains fire, smoke, or is normal."
105
+ )
106
+
107
+ if __name__ == "__main__":
108
+ iface.launch()
109
+ ```
110
+
111
+ ---
112
+
113
+ ## Intended Use
114
+
115
+ `Forest-Fire-Detection` is designed for:
116
+
117
+ * **Wildfire Monitoring** – Rapid identification of forest fire and smoke zones.
118
+ * **Environmental Protection** – Surveillance of forest areas for early fire warning.
119
+ * **Disaster Management** – Support in emergency response and evacuation decisions.
120
+ * **Smart Surveillance** – Integrate with drones or camera feeds for automated fire detection.
121
+ * **Research and Analysis** – Analyze visual datasets for fire-prone region identification.