prithivMLmods commited on
Commit
a88c8fe
·
verified ·
1 Parent(s): 12454e5

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +91 -0
README.md CHANGED
@@ -2,7 +2,11 @@
2
  license: apache-2.0
3
  datasets:
4
  - prithivMLmods/WeatherNet-05
 
5
  ---
 
 
 
6
 
7
  ```py
8
  Classification Report:
@@ -20,3 +24,90 @@ cloudy/overcast 0.8493 0.8762 0.8625 6702
20
  ```
21
 
22
  ![download (1).png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/T3MuycHMZDoAhjp3V5Z0p.png)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  license: apache-2.0
3
  datasets:
4
  - prithivMLmods/WeatherNet-05
5
+ library_name: transformers
6
  ---
7
+ # Weather-Image-Classification
8
+
9
+ > Weather-Image-Classification is a vision-language model fine-tuned from google/siglip2-base-patch16-224 for multi-class image classification. It is trained to recognize weather conditions from images using the SiglipForImageClassification architecture.
10
 
11
  ```py
12
  Classification Report:
 
24
  ```
25
 
26
  ![download (1).png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/T3MuycHMZDoAhjp3V5Z0p.png)
27
+
28
+ ---
29
+
30
+ ## Label Space: 5 Classes
31
+
32
+ The model classifies an image into one of the following weather categories:
33
+
34
+ ```json
35
+ "id2label": {
36
+ "0": "cloudy/overcast",
37
+ "1": "foggy/hazy",
38
+ "2": "rain/storm",
39
+ "3": "snow/frosty",
40
+ "4": "sun/clear"
41
+ }
42
+ ```
43
+
44
+ ---
45
+
46
+ ## Install Dependencies
47
+
48
+ ```bash
49
+ pip install -q transformers torch pillow gradio
50
+ ```
51
+
52
+ ---
53
+
54
+ ## Inference Code
55
+
56
+ ```python
57
+ import gradio as gr
58
+ from transformers import AutoImageProcessor, SiglipForImageClassification
59
+ from PIL import Image
60
+ import torch
61
+
62
+ # Load model and processor
63
+ model_name = "prithivMLmods/Weather-Image-Classification" # Replace with actual path
64
+ model = SiglipForImageClassification.from_pretrained(model_name)
65
+ processor = AutoImageProcessor.from_pretrained(model_name)
66
+
67
+ # Label mapping
68
+ id2label = {
69
+ "0": "cloudy/overcast",
70
+ "1": "foggy/hazy",
71
+ "2": "rain/storm",
72
+ "3": "snow/frosty",
73
+ "4": "sun/clear"
74
+ }
75
+
76
+ def classify_weather(image):
77
+ image = Image.fromarray(image).convert("RGB")
78
+ inputs = processor(images=image, return_tensors="pt")
79
+
80
+ with torch.no_grad():
81
+ outputs = model(**inputs)
82
+ logits = outputs.logits
83
+ probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
84
+
85
+ prediction = {
86
+ id2label[str(i)]: round(probs[i], 3) for i in range(len(probs))
87
+ }
88
+
89
+ return prediction
90
+
91
+ # Gradio Interface
92
+ iface = gr.Interface(
93
+ fn=classify_weather,
94
+ inputs=gr.Image(type="numpy"),
95
+ outputs=gr.Label(num_top_classes=5, label="Weather Condition"),
96
+ title="Weather-Image-Classification",
97
+ description="Upload an image to identify the weather condition (sun, rain, snow, fog, or clouds)."
98
+ )
99
+
100
+ if __name__ == "__main__":
101
+ iface.launch()
102
+ ```
103
+
104
+ ---
105
+
106
+ ## Intended Use
107
+
108
+ Weather-Image-Classification is useful for:
109
+
110
+ * Automated weather tagging for photography and media.
111
+ * Enhancing dataset labeling in weather-related research.
112
+ * Supporting smart surveillance and traffic systems.
113
+ * Improving scene understanding in autonomous vehicles.