Spaces:
Build error
Build error
File size: 1,586 Bytes
075d78c | 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 | import requests
from PIL import Image
import io
import json
import os
import uuid
SAMPLE_CLOTHES_URLS = {
"shirt": [
"https://images.unsplash.com/photo-1521572163474-6864f9cf17ab?w=300&h=400&fit=crop",
"https://images.unsplash.com/photo-1581655353564-df123a1eb820?w=300&h=400&fit=crop",
# Add 48 more...
],
"pants": [
"https://images.unsplash.com/photo-1542272604-787c3835535d?w=300&h=400&fit=crop",
# Add 24 more...
],
"dress": [
"https://images.unsplash.com/photo-1572635196237-14b3f281503f?w=300&h=400&fit=crop",
# Add 24 more...
]
}
def generate_sample_catalog():
os.makedirs("static/sample_clothes", exist_ok=True)
catalog = []
for cloth_type, urls in SAMPLE_CLOTHES_URLS.items():
for i, url in enumerate(urls):
try:
resp = requests.get(url)
img = Image.open(io.BytesIO(resp.content))
img = img.resize((256, 384))
img.save(f"static/sample_clothes/{cloth_type}_{i}.png")
catalog.append({
"image_path": f"static/sample_clothes/{cloth_type}_{i}.png",
"clothing_type": cloth_type,
"name": f"{cloth_type.title()} {i+1}"
})
except:
continue
with open("static/sample_clothes_catalog.json", "w") as f:
json.dump(catalog, f)
print(f"✅ Generated {len(catalog)} sample clothes for HF!")
if __name__ == "__main__":
generate_sample_catalog() |