Ellie Sleightholm
commited on
Commit
•
2a4d097
1
Parent(s):
8e62182
updating item list
Browse files
app.py
CHANGED
@@ -37,71 +37,60 @@ year = {2024}
|
|
37 |
|
38 |
# List of fashion items
|
39 |
items = [
|
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 |
-
"sports bra",
|
71 |
-
"base layer top",
|
72 |
-
"base layer bottom",
|
73 |
-
"swimsuit",
|
74 |
-
"rashguard",
|
75 |
-
"water shorts",
|
76 |
-
"cover up",
|
77 |
-
"goggle",
|
78 |
-
"hat",
|
79 |
-
"sun hat",
|
80 |
-
"glove",
|
81 |
-
"mitten",
|
82 |
-
"belt",
|
83 |
-
"leg gaiter",
|
84 |
]
|
85 |
|
|
|
86 |
# Initialize the model and tokenizer
|
87 |
model_name = 'hf-hub:Marqo/marqo-fashionSigLIP'
|
88 |
model, preprocess_train, preprocess_val = open_clip.create_model_and_transforms(model_name)
|
89 |
tokenizer = open_clip.get_tokenizer(model_name)
|
90 |
|
91 |
-
# Generate descriptions dynamically
|
92 |
def generate_description(item):
|
93 |
-
if "
|
94 |
-
return f"
|
95 |
-
elif item in ["
|
96 |
-
return f"
|
97 |
-
elif item in ["
|
98 |
-
return f"
|
99 |
-
elif item in ["
|
100 |
-
return f"
|
101 |
-
elif item in ["
|
102 |
-
return f"
|
|
|
|
|
103 |
else:
|
104 |
-
return f"
|
|
|
105 |
|
106 |
items_desc = [generate_description(item) for item in items]
|
107 |
text = tokenizer(items_desc)
|
|
|
37 |
|
38 |
# List of fashion items
|
39 |
items = [
|
40 |
+
"Leggings", "Jogger", "Palazzo", "Cargo", "Dresspants", "Chinos",
|
41 |
+
"Dress", "Blouse", "T-Shirt", "Jeans", "Skirt", "Shorts",
|
42 |
+
"Sweater", "Cardigan", "Tank Top", "Hoodie", "Coat",
|
43 |
+
"Jacket", "Polo Shirt", "Crop Top", "Romper",
|
44 |
+
"Overalls", "Blazer", "Sweatpants", "Vest",
|
45 |
+
"Dungarees", "Poncho", "Bodysuit", "Maxi Dress",
|
46 |
+
"Hat", "Sunglasses", "Glasses", "Shoes", "Sandals",
|
47 |
+
"Heels", "Trainers", "Belt", "Tie", "Dress Shirt",
|
48 |
+
"Boots", "Slippers", "Sneakers", "Insoles", "Socks",
|
49 |
+
"Insulated Jacket", "Fleece", "Rain Jacket", "Running Jacket",
|
50 |
+
"Windbreaker", "Shirt", "Graphic Top", "Sweatshirt",
|
51 |
+
"Pant", "Legging", "Short", "Skort", "Brief",
|
52 |
+
"Sports Bra", "Base Layer Top", "Base Layer Bottom",
|
53 |
+
"Swimsuit", "Rashguard", "Water Shorts", "Cover Up",
|
54 |
+
"Goggle", "Sun Hat", "Glove", "Mitten", "Leg Gaiter",
|
55 |
+
"Bandana", "Neck Gaiter", "Balaclava", "Sunglass",
|
56 |
+
"Watch", "Bag", "Boxer", "Swim Trunk", "Ring",
|
57 |
+
"Necklace", "Earing", "Pocket Watch", "Smock",
|
58 |
+
"Trouser", "Tuxedo", "Cufflinks", "Suspenders",
|
59 |
+
"Handkerchief", "Scarf", "Wristband", "Beanie",
|
60 |
+
"Fedora", "Beret", "Clutch Bag", "Crossbody Bag",
|
61 |
+
"Duffel Bag", "Backpack", "Umbrella", "Flip Flops",
|
62 |
+
"Espadrilles", "Loafers", "Moccasins", "Chelsea Boots",
|
63 |
+
"Ankle Boots", "Bow Tie", "Tie Clip", "Hair Clip",
|
64 |
+
"Headband", "Visor", "Baseball Cap", "Bucket Hat",
|
65 |
+
"Fingerless Gloves", "Touchscreen Gloves", "Trench Coat",
|
66 |
+
"Peacoat", "Parka", "Bomber Jacket", "Utility Vest",
|
67 |
+
"Puffer Jacket", "Cape", "Shrug", "Kimono", "Sarong",
|
68 |
+
"Apron", "Bikini", "Poncho", "Wristwatch", "Choker",
|
69 |
+
"Brooch", "Anklet", "Toe Ring", "Waist Belt"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
]
|
71 |
|
72 |
+
|
73 |
# Initialize the model and tokenizer
|
74 |
model_name = 'hf-hub:Marqo/marqo-fashionSigLIP'
|
75 |
model, preprocess_train, preprocess_val = open_clip.create_model_and_transforms(model_name)
|
76 |
tokenizer = open_clip.get_tokenizer(model_name)
|
77 |
|
|
|
78 |
def generate_description(item):
|
79 |
+
if "Pants" in item or item in ["Leggings", "Jogger", "Cargo", "Chinos", "Palazzo", "Dresspants", "Sweatpants", "Pant", "Legging", "Skort", "Trouser"]:
|
80 |
+
return f"A pair of {item} pants"
|
81 |
+
elif item in ["Dress", "Blouse", "T-Shirt", "Tank Top", "Sweater", "Cardigan", "Hoodie", "Coat", "Jacket", "Polo Shirt", "Crop Top", "Romper", "Blazer", "Vest", "Bodysuit", "Maxi Dress", "Graphic Top", "Shirt", "Base Layer Top", "Base Layer Bottom", "Swimsuit", "Rashguard", "Cover Up", "Smock", "Tuxedo"]:
|
82 |
+
return f"A {item}"
|
83 |
+
elif item in ["Hat", "Sunglasses", "Glasses", "Sun Hat", "Goggle", "Balaclava"]:
|
84 |
+
return f"A {item} worn on the head or face"
|
85 |
+
elif item in ["Shoes", "Sandals", "Heels", "Trainers", "Boots", "Slippers", "Sneakers", "Insoles", "Socks"]:
|
86 |
+
return f"A pair of {item} worn on the feet"
|
87 |
+
elif item in ["Jeans", "Skirt", "Shorts", "Dungarees", "Poncho", "Overalls", "Brief", "Boxer", "Swim Trunk", "Ring", "Necklace", "Earing", "Pocket Watch"]:
|
88 |
+
return f"A {item} piece of clothing"
|
89 |
+
elif item in ["Boxing Gloves", "Glove", "Mitten"]:
|
90 |
+
return f"An item of {item} worn on the hands"
|
91 |
else:
|
92 |
+
return f"A fashion item called {item}"
|
93 |
+
|
94 |
|
95 |
items_desc = [generate_description(item) for item in items]
|
96 |
text = tokenizer(items_desc)
|