prithivMLmods commited on
Commit
7ef9e0e
·
verified ·
1 Parent(s): a2bc7c2

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +84 -1
README.md CHANGED
@@ -1,6 +1,9 @@
1
  ---
2
  license: apache-2.0
3
  ---
 
 
 
4
 
5
  ```py
6
  Classification Report:
@@ -18,4 +21,84 @@ Smart Casual 0.0000 0.0000 0.0000 67
18
  accuracy 0.8458 44072
19
  macro avg 0.3912 0.2762 0.3024 44072
20
  weighted avg 0.8300 0.8458 0.8159 44072
21
- ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
  ---
4
+ # **Fashion-Product-Usage**
5
+
6
+ > **Fashion-Product-Usage** 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 intended usage context.
7
 
8
  ```py
9
  Classification Report:
 
21
  accuracy 0.8458 44072
22
  macro avg 0.3912 0.2762 0.3024 44072
23
  weighted avg 0.8300 0.8458 0.8159 44072
24
+ ```
25
+
26
+ The model predicts one of the following usage categories:
27
+
28
+ - **0:** Casual
29
+ - **1:** Ethnic
30
+ - **2:** Formal
31
+ - **3:** Home
32
+ - **4:** Party
33
+ - **5:** Smart Casual
34
+ - **6:** Sports
35
+ - **7:** Travel
36
+
37
+ ---
38
+
39
+ # **Run with Transformers 🤗**
40
+
41
+ ```python
42
+ !pip install -q transformers torch pillow gradio
43
+ ```
44
+
45
+ ```python
46
+ import gradio as gr
47
+ from transformers import AutoImageProcessor, SiglipForImageClassification
48
+ from PIL import Image
49
+ import torch
50
+
51
+ # Load model and processor
52
+ model_name = "prithivMLmods/Fashion-Product-Usage" # Replace with your actual model path
53
+ model = SiglipForImageClassification.from_pretrained(model_name)
54
+ processor = AutoImageProcessor.from_pretrained(model_name)
55
+
56
+ # Label mapping
57
+ id2label = {
58
+ 0: "Casual",
59
+ 1: "Ethnic",
60
+ 2: "Formal",
61
+ 3: "Home",
62
+ 4: "Party",
63
+ 5: "Smart Casual",
64
+ 6: "Sports",
65
+ 7: "Travel"
66
+ }
67
+
68
+ def classify_usage(image):
69
+ """Predicts the usage type of a fashion product."""
70
+ image = Image.fromarray(image).convert("RGB")
71
+ inputs = processor(images=image, return_tensors="pt")
72
+
73
+ with torch.no_grad():
74
+ outputs = model(**inputs)
75
+ logits = outputs.logits
76
+ probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
77
+
78
+ predictions = {id2label[i]: round(probs[i], 3) for i in range(len(probs))}
79
+ return predictions
80
+
81
+ # Gradio interface
82
+ iface = gr.Interface(
83
+ fn=classify_usage,
84
+ inputs=gr.Image(type="numpy"),
85
+ outputs=gr.Label(label="Usage Prediction Scores"),
86
+ title="Fashion-Product-Usage",
87
+ description="Upload a fashion product image to predict its intended usage (Casual, Formal, Party, etc.)."
88
+ )
89
+
90
+ # Launch the app
91
+ if __name__ == "__main__":
92
+ iface.launch()
93
+ ```
94
+
95
+ ---
96
+
97
+ # **Intended Use**
98
+
99
+ This model can be used for:
100
+
101
+ - **Product tagging in e-commerce catalogs**
102
+ - **Context-aware product recommendations**
103
+ - **Fashion search optimization**
104
+ - **Data annotation for training recommendation engines**