fashion-tag-generator / examples_metadata.py
lele-cecere's picture
switched to non quantized mistral instruct
809d04b
dress_metadata = {
"customFields": {
"brand_cod": "268",
"nano_category": "maxidresses",
"div_cod": "001",
"micro_category": "dresses",
"macro_category": "clothing"
},
"descriptions": [
{
"language": "en",
"text": "Belina one shoulder evening dress",
"type": "short"
},
{
"language": "it",
"text": "Abito da sera monospalla Belina",
"type": "short"
}
],
"tagsData": {
"defaultLanguage": "it",
"tags": [
{
"metadataId": "pattern#pattern_plain_colour",
"withConflict": False,
"confidence": 0.217,
"tagPattern": {
"languages": {
"en": "Plain colour",
"it": "Tinta unita"
}
},
"source": "enrichment",
"tag": {
"languages": {
"en": "Plain colour",
"it": "Tinta unita"
}
}
},
{
"metadataId": "collar_and_neckline#collarneckline_boat",
"tagPattern": {
"languages": {
"en": "Boat neck",
"it": "Collo a barca"
}
},
"tag": {
"languages": {
"en": "Boat neck",
"it": "Collo a barca"
}
}
},
{
"metadataId": "sleeve_length#sleeve_length_oneshoulder",
"tagPattern": {
"languages": {
"en": "One Shoulder",
"it": "Monospalla"
}
},
"tag": {
"languages": {
"en": "One Shoulder",
"it": "Monospalla"
}
}
},
{
"metadataId": "length_type#length_type_mai",
"withConflict": False,
"confidence": 0.896,
"tagPattern": {
"languages": {
"en": "Maxi",
"it": "Maxi"
}
},
"source": "enrichment",
"tag": {
"languages": {
"en": "Maxi",
"it": "Maxi"
}
}
}
]
},
}
bomber_metadata = {
"customFields": {
"brand_cod": "BU7",
"nano_category": "null",
"div_cod": "001",
"micro_category": "downjackets",
"macro_category": "clothing"
},
"descriptions": [
{
"language": "en",
"text": "Straight bomber jacket",
"type": "short"
},
{
"language": "it",
"text": "Giacca bomber dritto",
"type": "short"
}
],
"tagsData": {
"defaultLanguage": "it",
"tags": [
{
"metadataId": "pattern#pattern_plain_colour",
"withConflict": False,
"confidence": 0.882,
"tagPattern": {
"languages": {
"en": "Plain colour",
"it": "Tinta unita"
}
},
"source": "enrichment",
"tag": {
"languages": {
"en": "Plain colour",
"it": "Tinta unita"
}
}
},
{
"metadataId": "pattern#pattern_logo",
"tagPattern": {
"languages": {
"en": "Logo",
"it": "Logo"
}
},
"tag": {
"languages": {
"en": "Logo",
"it": "Logo"
}
}
},
{
"metadataId": "closure#closure_zip",
"withConflict": False,
"confidence": 0.579,
"tagPattern": {
"languages": {
"en": "Zip",
"it": "Cerniera"
}
},
"source": "enrichment",
"tag": {
"languages": {
"en": "Zip",
"it": "Cerniera"
}
}
}
]
},
}
bag_metadata = {
"customFields": {
"brand_cod": "175",
"nano_category": "null",
"div_cod": "001",
"micro_category": "satchelscrossbody",
"macro_category": "bags"
},
"descriptions": [
{
"language": "en",
"text": "Noos swivel flap shoulder bag",
"type": "short"
},
{
"language": "it",
"text": "Tracolla patta girello Noos",
"type": "short"
}
],
"tagsData": {
"defaultLanguage": "it",
"tags": [
{
"metadataId": "shoulder_strap_included#shoulder_strap_yes",
"withConflict": False,
"confidence": 0.803,
"tagPattern": {
"languages": {
"en": "Shoulder strap included",
"it": "Tracolla inclusa"
}
},
"source": "enrichment",
"tag": {
"languages": {
"en": "Shoulder strap included",
"it": "Tracolla inclusa"
}
}
},
{
"metadataId": "pattern#pattern_printed",
"tagPattern": {
"languages": {
"en": "Printed",
"it": "Stampe"
}
},
"tag": {
"languages": {
"en": "Printed",
"it": "Stampe"
}
}
},
{
"metadataId": "dimension#dimension_mini",
"withConflict": False,
"confidence": 0.78,
"tagPattern": {
"languages": {
"en": "Mini",
"it": "Mini"
}
},
"source": "enrichment",
"tag": {
"languages": {
"en": "Mini",
"it": "Mini"
}
}
},
{
"metadataId": "dimension#dimension_medium",
"withConflict": True,
"confidence": 0.216,
"tagPattern": {
"languages": {
"en": "Medium",
"it": "Medie"
}
},
"source": "enrichment",
"tag": {
"languages": {
"en": "Medium",
"it": "Medie"
}
}
}
]
},
}
def clean_json(json_data):
"""
Extracts the English description and English tags from the given JSON data.
:param json_data: A dictionary representing the JSON data of a fashion item.
:return: A dictionary containing the English description and a list of English tags.
"""
important_data = {}
# Extracting the English description
description_en = next((desc['text'] for desc in json_data['descriptions'] if desc['language'] == 'en'), None)
important_data['description_en'] = description_en
# Extracting the English tags
tags_en = [tag['tag']['languages']['en'] for tag in json_data['tagsData']['tags'] if 'en' in tag['tag']['languages']]
important_data['tags_en'] = tags_en
return list(important_data.values())
dress_metadata = clean_json(dress_metadata)
bomber_metadata = clean_json(bomber_metadata)
bag_metadata = clean_json(bag_metadata)
dress_example = f'''
#### Input
Metadata: {dress_metadata};
#### Output
- short
- double shoulder
- long sleeve
- different fabric
- low-cut
'''
bomber_example = f'''
#### Input
Metadata: {bomber_metadata};
#### Output
- different zipper
- buttons
- fur
- hood
- sleeveless
'''
bag_example = f'''
#### Input
Metadata: {bag_metadata};
#### Output
- Medium
- Belt bag
- Quilted
- Embossed
- Fringed
'''
bomber_shorten_example = '''
Input:
Here are five possible variations for the given fashion item metadata:
- Fitted: A tailored version of the down jacket that hugs the body in all areas, creating a more form-fitting silhouette.
- Padded: An alternative version of the down jacket with added padding throughout, creating a bulkier and more insulated look.
- Hooded: A down jacket with an attached hood, providing additional warmth and protection from the elements.
- Waterproof: A down jacket with a waterproof and breathable membrane, allowing it to be worn during rainy or snowy weather without getting wet.
- Vest: A shorter, sleeveless version of the down jacket, featuring only the front panel and offering a more streamlined fit.
Output:
-Tailored Fit
-Extra Padded
-With Hood
-Rainproof
-Sleeveless Vest
'''
bomber_format_example = '''
Input:
Here are five possible variations for the given down jacket metadata:
- Padded shoulders
- Long sleeves
- Leather exterior
- Front ventilation zippers
- Hooded design
These variations are based on the existing tag patterns and can be easily incorporated into the product design without significantly altering its overall look or function.
Output:
[Padded shoulders, Long sleeves, Leather exterior, Front ventilation zippers, Hooded design]
'''
# made with gpt-4
shirt_format_example = '''
Input:
- Mandarin collar
- Short sleeves
- Linen fabric
- Chest pocket
- Button-up design
Output:
[Mandarin Collar, Short Sleeves, Linen fabric, Chest Pocket, Button-Up design]
'''
pants_format_example = '''
Input
- Pleated front
- Cuffed hems
- Wool blend fabric
- Side pockets
- Relaxed fit
Output:
[Pleated front, Cuffed hems, Wool blend fabric, Side Pockets, Relaxed fit]
'''