File size: 5,078 Bytes
3bad252
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
"""
Main run script for the Vibe-to-Attribute Clothing Recommendation System

This script:
1. Sets up the environment
2. Creates the sample product catalog
3. Downloads required models
4. Starts the Streamlit application
"""

import os
import sys
import subprocess
import platform
from pathlib import Path

def print_banner():
    """Print welcome banner."""
    banner = """
╔══════════════════════════════════════════════════════════════════════════════╗
β•‘                                                                              β•‘
β•‘           🌟 Vibe-to-Attribute Clothing Recommendation System 🌟             β•‘
β•‘                                                                              β•‘
β•‘  Transform your style ideas into perfect outfit recommendations using AI!    β•‘
β•‘                                                                              β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
    """
    print(banner)

def check_python_version():
    """Check if Python version is compatible."""
    min_version = (3, 8)
    current_version = sys.version_info[:2]
    
    if current_version < min_version:
        print(f"❌ Python {min_version[0]}.{min_version[1]}+ is required. Current version: {current_version[0]}.{current_version[1]}")
        return False
    
    print(f"βœ… Python version: {current_version[0]}.{current_version[1]}")
    return True

def install_requirements():
    """Install required Python packages."""
    print("\nπŸ“¦ Installing required packages...")
    
    try:
        subprocess.check_call([
            sys.executable, "-m", "pip", "install", "-r", "requirements.txt"
        ])
        print("βœ… Requirements installed successfully!")
        return True
    except subprocess.CalledProcessError as e:
        print(f"❌ Failed to install requirements: {e}")
        return False

def create_sample_catalog():
    """Create the sample product catalog."""
    print("\nπŸ“Š Creating sample product catalog...")
    
    try:
        # Run the catalog creation script
        exec(open('create_catalog.py').read())
        print("βœ… Sample catalog created successfully!")
        return True
    except Exception as e:
        print(f"❌ Failed to create sample catalog: {e}")
        return False

def check_environment():
    """Check if environment file exists and provide guidance."""
    print("\nπŸ”§ Checking environment configuration...")
    
    env_file = Path('.env')
    env_example = Path('env.example')
    
    if not env_file.exists():
        if env_example.exists():
            print("⚠️  No .env file found. Please:")
            print("   1. Copy env.example to .env")
            print("   2. Edit .env with your API keys")
            print("   3. Set your OpenAI API key for GPT features")
            print("\n   Example:")
            print("   cp env.example .env")
            print("   # Then edit .env with your actual API keys")
        else:
            print("⚠️  No environment configuration found.")
        
        print("\nπŸ’‘ The system will work with limited functionality without API keys.")
        print("   GPT inference will be disabled, but rule-based matching will work.")
        return False
    else:
        print("βœ… Environment file found!")
        return True

def start_streamlit():
    """Start the Streamlit application."""
    print("\nπŸš€ Starting Streamlit application...")
    print("πŸ“ The app will open in your default web browser")
    print("\n⏹️  Press Ctrl+C to stop the application")
    
    try:
        subprocess.run([
            sys.executable, "-m", "streamlit", "run", "streamlit_app.py",])
    except KeyboardInterrupt:
        print("\nπŸ‘‹ Application stopped by user")
    except Exception as e:
        print(f"❌ Failed to start Streamlit: {e}")

def main():
    """Main execution function."""
    print_banner()
    
    print("πŸ” System Check...")
    
    # Check Python version
    if not check_python_version():
        sys.exit(1)
    
    # Check if we're in the right directory
    if not Path("requirements.txt").exists():
        print("❌ Please run this script from the project root directory")
        sys.exit(1)
    
    print("βœ… In correct directory")
    
    # Install requirements
    if not install_requirements():
        print("⚠️  Continuing with existing packages...")
    
    # Create sample catalog
    create_sample_catalog()
    
    # Check environment
    check_environment()
    
    print("\n" + "="*80)
    print("πŸŽ‰ Setup complete! Starting the application...")
    print("="*80)
    
    # Start Streamlit
    start_streamlit()

if __name__ == "__main__":
    main()