Spaces:
Build error
Build error
| #!/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() |