import random from datetime import datetime from typing import List, Dict, Any, Optional class StyleRecommender: def __init__(self): self.occasion_keywords = { 'casual': ['t-shirt', 'jeans', 'sneakers', 'hoodie', 'shorts'], 'work': ['blouse', 'trousers', 'blazer', 'loafers', 'pencil skirt'], 'party': ['dress', 'heels', 'clutch', 'statement jewelry', 'sequins'], 'date': ['nice top', 'skinny jeans', 'boots', 'jacket', 'accessories'], 'sport': ['leggings', 'sports bra', 'running shoes', 'tank top', 'hoodie'], 'travel': ['comfortable pants', 'sweater', 'sneakers', 'jacket', 'backpack'], 'formal': ['suit', 'dress shoes', 'tie', 'dress shirt', 'watch'], 'beach': ['swimsuit', 'cover-up', 'sandals', 'hat', 'sunglasses'] } self.color_harmonies = { 'monochromatic': ['#1a1a1a', '#333333', '#4d4d4d', '#666666', '#808080'], 'complementary': ['#FF6B6B', '#4ECDC4', '#FFE66D', '#95E77E', '#C7B9FF'], 'analogous': ['#FF6B6B', '#FF8E8E', '#FFB5B5', '#FF6B6B', '#FF8E8E'], 'triadic': ['#FF6B6B', '#4ECDC4', '#FFE66D', '#FF6B6B', '#4ECDC4'] } self.seasonal_recommendations = { 'spring': ['Pastel colors', 'Light layers', 'Floral patterns', 'Light jackets'], 'summer': ['Bright colors', 'Breathable fabrics', 'Sundresses', 'Sandals'], 'fall': ['Earthy tones', 'Layering pieces', 'Boots', 'Cardigans'], 'winter': ['Dark colors', 'Heavy coats', 'Scarves', 'Warm fabrics'] } def recommend(self, wardrobe: List[Dict], occasion: str, weather: Optional[str] = None, temperature: Optional[float] = None, style_preferences: Optional[List[str]] = None) -> dict: occasion_items = self.occasion_keywords.get(occasion.lower(), self.occasion_keywords['casual']) matching_items = [] for item in wardrobe: item_type = item.get('type', '').lower() if any(keyword in item_type for keyword in occasion_items): matching_items.append(item) if not matching_items and wardrobe: matching_items = wardrobe[:5] primary_outfit = self._create_outfit(matching_items, occasion) alternatives = [] for i in range(2): alt_outfit = self._create_outfit(wardrobe, occasion, shuffle=True) alternatives.append(alt_outfit) reasoning = self._generate_reasoning(occasion, weather, temperature) return { "recommendations": [primary_outfit] + alternatives, "primary": primary_outfit, "alternatives": alternatives, "reasoning": reasoning } def _create_outfit(self, items: List[Dict], occasion: str, shuffle: bool = False) -> Dict: if shuffle: import random selected = random.sample(items, min(3, len(items))) else: selected = items[:min(3, len(items))] return { "name": f"{occasion.capitalize()} Look", "items": selected, "total_pieces": len(selected), "occasion": occasion } def _generate_reasoning(self, occasion: str, weather: Optional[str], temperature: Optional[float]) -> str: reasoning = f"For a {occasion} occasion, " if temperature: if temperature > 25: reasoning += "choose lightweight, breathable fabrics to stay cool. " elif temperature < 10: reasoning += "layer up with warm pieces to stay comfortable. " if weather: if weather == 'rainy': reasoning += "Bring a waterproof jacket and umbrella. " elif weather == 'sunny': reasoning += "Don't forget sunglasses and sun protection. " reasoning += f"This outfit balances style and practicality for your {occasion} event." return reasoning def weather_based_recommendation(self, temperature: float, condition: str) -> dict: if temperature > 25: outfit = "Light clothing: shorts, t-shirt, sandals" fabrics = ["Cotton", "Linen", "Rayon"] layering = "Minimal layering" accessories = ["Sunglasses", "Hat", "Light scarf"] elif temperature < 10: outfit = "Warm layers: coat, sweater, boots" fabrics = ["Wool", "Cashmere", "Fleece"] layering = "Base layer + mid layer + outer layer" accessories = ["Scarf", "Gloves", "Beanie"] else: outfit = "Comfortable layers: jeans, long sleeve, jacket" fabrics = ["Cotton", "Denim", "Light wool"] layering = "Top + light jacket" accessories = ["Scarf", "Light gloves"] return { "outfit": outfit, "fabrics": fabrics, "layering": layering, "accessories": accessories, "warning": "Check local forecast" if condition == 'rainy' else None } def celebrity_style_analysis(self, celebrity_name: str) -> dict: celebrity_styles = { 'zendaya': { 'signature_style': 'Bold, experimental, confident', 'key_pieces': ['Statement suits', 'Dramatic gowns', 'Tailored pieces'], 'colors': ['Red', 'Black', 'Metallic', 'Neon'], 'how_to': ['Take risks', 'Play with proportions', 'Invest in tailoring'] }, 'timothee chalamet': { 'signature_style': 'Eclectic, youthful, artistic', 'key_pieces': ['Bold suits', 'Statement accessories', 'Converse shoes'], 'colors': ['Pastels', 'Bright colors', 'Black'], 'how_to': ['Mix high and low fashion', 'Add unexpected accessories', 'Keep hair styled'] } } result = celebrity_styles.get(celebrity_name.lower(), { 'signature_style': 'Unique and personalized', 'key_pieces': ['Statement pieces', 'Tailored fits', 'Signature accessories'], 'colors': ['Neutral', 'Bold accent colors'], 'how_to': ['Find what works for you', 'Invest in quality basics', 'Add personal touches'] }) return result