Views
No views yet

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.
1Classification Report:
2 precision recall f1-score support
3
4 Casual 0.8529 0.9716 0.9084 34392
5 Ethnic 0.8365 0.7528 0.7925 3208
6 Formal 0.7246 0.3006 0.4250 2345
7 Home 0.0000 0.0000 0.0000 1
8 Party 0.0000 0.0000 0.0000 29
9Smart Casual 0.0000 0.0000 0.0000 67
10 Sports 0.7157 0.1848 0.2938 4004
11 Travel 0.0000 0.0000 0.0000 26
12
13 accuracy 0.8458 44072
14 macro avg 0.3912 0.2762 0.3024 44072
15weighted avg 0.8300 0.8458 0.8159 44072!pip install -q transformers torch pillow gradio1import gradio as gr
2from transformers import AutoImageProcessor, SiglipForImageClassification
3from PIL import Image
4import torch
5
6# Load model and processor
7model_name = "prithivMLmods/Fashion-Product-Usage" # Replace with your actual model path
8model = SiglipForImageClassification.from_pretrained(model_name)
9processor = AutoImageProcessor.from_pretrained(model_name)
10
11# Label mapping
12id2label = {
13 0: "Casual",
14 1: "Ethnic",
15 2: "Formal",
16 3: "Home",
17 4: "Party",
18 5: "Smart Casual",
19 6: "Sports",
20 7: "Travel"
21}
22
23def classify_usage(image):
24 """Predicts the usage type of a fashion product."""
25 image = Image.fromarray(image).convert("RGB")
26 inputs = processor(images=image, return_tensors="pt")
27
28 with torch.no_grad():
29 outputs = model(**inputs)
30 logits = outputs.logits
31 probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
32
33 predictions = {id2label[i]: round(probs[i], 3) for i in range(len(probs))}
34 return predictions
35
36# Gradio interface
37iface = gr.Interface(
38 fn=classify_usage,
39 inputs=gr.Image(type="numpy"),
40 outputs=gr.Label(label="Usage Prediction Scores"),
41 title="Fashion-Product-Usage",
42 description="Upload a fashion product image to predict its intended usage (Casual, Formal, Party, etc.)."
43)
44
45# Launch the app
46if __name__ == "__main__":
47 iface.launch()