File size: 3,036 Bytes
57964c2
 
ef58f60
 
a66f847
afbd374
a66f847
 
 
 
 
 
 
 
 
57964c2
 
ef58f60
 
998f30e
 
 
 
57964c2
 
 
 
 
 
 
 
 
 
 
 
998f30e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ef58f60
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
---
license: apache-2.0
language:
- en
base_model:
- google/siglip2-so400m-patch14-384
pipeline_tag: image-classification
library_name: transformers
tags:
- fashion
- product
- season
- siglip2
- image
- classification
---

![tregsd.png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/f-YpJJbkFilf4Q2gJA9SM.png)

# **Fashion-Product-Season**

> **Fashion-Product-Season** is a vision-language model fine-tuned from **google/siglip2-base-patch16-224** using the **SiglipForImageClassification** architecture. It classifies fashion product images based on their suitable **season of use**.

```py
Classification Report:
              precision    recall  f1-score   support

        Fall     0.6173    0.5655    0.5903     11414
      Spring     0.9738    0.7665    0.8578      2711
      Summer     0.7051    0.8107    0.7542     21438
      Winter     0.8007    0.6432    0.7134      8509

    accuracy                         0.7121     44072
   macro avg     0.7742    0.6965    0.7289     44072
weighted avg     0.7174    0.7121    0.7103     44072
```
The model predicts one of the following **season categories**:

- **0:** Fall  
- **1:** Spring  
- **2:** Summer  
- **3:** Winter

---

# **Run with Transformers 🤗**

```python
!pip install -q transformers torch pillow gradio
```

```python
import gradio as gr
from transformers import AutoImageProcessor, SiglipForImageClassification
from PIL import Image
import torch

# Load model and processor
model_name = "prithivMLmods/Fashion-Product-Season"  # Replace with your actual model path
model = SiglipForImageClassification.from_pretrained(model_name)
processor = AutoImageProcessor.from_pretrained(model_name)

# Label mapping
id2label = {
    0: "Fall",
    1: "Spring",
    2: "Summer",
    3: "Winter"
}

def classify_season(image):
    """Predicts the most suitable season for a fashion product."""
    image = Image.fromarray(image).convert("RGB")
    inputs = processor(images=image, return_tensors="pt")

    with torch.no_grad():
        outputs = model(**inputs)
        logits = outputs.logits
        probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()

    predictions = {id2label[i]: round(probs[i], 3) for i in range(len(probs))}
    predictions = dict(sorted(predictions.items(), key=lambda item: item[1], reverse=True))
    return predictions

# Gradio interface
iface = gr.Interface(
    fn=classify_season,
    inputs=gr.Image(type="numpy"),
    outputs=gr.Label(label="Season Prediction Scores"),
    title="Fashion-Product-Season",
    description="Upload a fashion product image to predict its most suitable season (Fall, Spring, Summer, Winter)."
)

# Launch the app
if __name__ == "__main__":
    iface.launch()
```

---

# **Intended Use**

This model can be used for:

- **Seasonal tagging in fashion e-commerce**  
- **Improved recommendations for seasonal shopping trends**  
- **Inventory planning based on product seasonality**  
- **Data labeling for fashion-specific recommendation engines**