File size: 6,138 Bytes
bb71884
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#!/usr/bin/env python3
"""
Demo script showing the enhanced fashion analysis capabilities
"""

import requests
import json
from pathlib import Path

def demo_enhanced_analysis():
    """Demonstrate the enhanced analysis features"""
    
    server_url = "http://localhost:7861"
    
    print("🎽 Enhanced Fashion Analysis Demo")
    print("=" * 60)
    
    # First, show the refined prompt
    print("\nπŸ“ 1. Refined Prompt Structure")
    print("-" * 40)
    
    try:
        response = requests.get(f"{server_url}/refined-prompt")
        if response.status_code == 200:
            prompt = response.text
            # Show just the key sections
            lines = prompt.split('\n')
            for i, line in enumerate(lines):
                if i < 50:  # Show first 50 lines
                    print(line)
            print("... (truncated for demo)")
        else:
            print(f"❌ Error getting prompt: {response.status_code}")
    except Exception as e:
        print(f"❌ Error: {e}")
    
    print("\nπŸ” 2. Analysis Capabilities")
    print("-" * 40)
    
    # Show the different endpoints available
    endpoints = [
        ("/analyze-enhanced", "Enhanced Prompt Analysis", "Advanced fashion analysis with detailed insights"),
        ("/analyze-structured", "Structured Analysis", "JSON format with structured data"),
        ("/analyze", "Basic Analysis", "Standard fashion analysis"),
        ("/detect-objects", "Object Detection", "Fashion item detection only"),
        ("/extract-features", "Feature Extraction", "Fashion feature vectors")
    ]
    
    for endpoint, name, description in endpoints:
        print(f"β€’ {name}: {endpoint}")
        print(f"  {description}")
    
    print("\n🎨 3. Enhanced Features")
    print("-" * 40)
    
    features = [
        "Fashion-specific vocabulary (oversized, tailored, cropped, monochromatic)",
        "Color theory analysis (warm/cool tones, seasonal suitability)",
        "Formality level inference (smart casual, athleisure, streetwear)",
        "Fit and silhouette analysis (slim-fit, relaxed, boxy, flowy)",
        "Material intelligence (texture, care, quality insights)",
        "Comprehensive feature extraction with styling context",
        "Professional outfit summaries with fashion expertise"
    ]
    
    for feature in features:
        print(f"βœ“ {feature}")
    
    print("\nπŸ“Š 4. Sample Analysis Structure")
    print("-" * 40)
    
    sample_analysis = """
**UPPER GARMENT**

**Type**: Button-down chambray shirt
**Color**: Light denim blue (cool tone) with faded areas on collar and seams
**Material**: Chambray (lightweight woven cotton)
**Features**: Long sleeves rolled to elbows, pointed collar, front patch pockets, relaxed fit, visible stitching

---

**LOWER GARMENT**

**Type**: Black slim-fit chinos
**Color**: Solid black (neutral tone)
**Material**: Stretch cotton twill
**Features**: Flat front, minimal pockets, cropped ankle length, clean silhouette

---

**FOOTWEAR**

**Type**: White minimalist sneakers
**Color**: White with subtle grey accents on heel tab
**Material**: Leather upper with rubber sole
**Features**: Lace-up closure, low-profile design, round toe

---

**OUTFIT SUMMARY**

This outfit channels effortless smart-casual style with its blend of soft textures and minimal structure. The chambray shirt introduces a laid-back, workwear-inspired vibe, complemented by the refined edge of slim black chinos. The white sneakers tie the look together with understated coolness, ensuring comfort without sacrificing polish. The color palette of light blue, black, and white reflects balance and neutrality, making the outfit adaptable for casual office settings, social outings, or relaxed dates. The overall silhouette is clean and streamlined, making it modern, versatile, and easy to accessorize.
"""
    
    print(sample_analysis)
    
    print("\nπŸš€ 5. Usage Instructions")
    print("-" * 40)
    
    usage_instructions = [
        "1. Start the server: python fast.py",
        "2. Test with image: python test_enhanced_analysis.py your_image.jpg",
        "3. Use API endpoint: POST /analyze-enhanced with image file",
        "4. Compare methods: python test_enhanced_analysis.py image.jpg",
        "5. Get refined prompt: GET /refined-prompt"
    ]
    
    for instruction in usage_instructions:
        print(instruction)
    
    print("\nπŸ’‘ 6. Benefits for Outfit Recommendation")
    print("-" * 40)
    
    benefits = [
        "Better feature extraction for recommendation algorithms",
        "Style context understanding for occasion-based suggestions",
        "Color harmony analysis for coordinated outfit building",
        "Material awareness for fabric-appropriate styling",
        "Professional-level fashion insights for quality recommendations"
    ]
    
    for benefit in benefits:
        print(f"β€’ {benefit}")
    
    print("\n" + "=" * 60)
    print("🎯 Ready to test! Use the test script with your fashion images.")
    print("=" * 60)

def check_server_status():
    """Check if the server is running"""
    
    server_url = "http://localhost:7861"
    
    try:
        response = requests.get(f"{server_url}/health")
        if response.status_code == 200:
            data = response.json()
            print(f"βœ… Server is running: {data}")
            return True
        else:
            print(f"❌ Server health check failed: {response.status_code}")
            return False
    except requests.exceptions.ConnectionError:
        print("❌ Server is not running. Start it with: python fast.py")
        return False
    except Exception as e:
        print(f"❌ Error checking server: {e}")
        return False

def main():
    """Main demo function"""
    
    print("πŸ” Checking server status...")
    if check_server_status():
        print("\n")
        demo_enhanced_analysis()
    else:
        print("\nπŸ“‹ To start the demo:")
        print("1. Run: python fast.py")
        print("2. Wait for server to start")
        print("3. Run: python demo_enhanced_analysis.py")

if __name__ == "__main__":
    main()