Vibe-Fusion / run.py
kjgpta's picture
Upload 18 files
3bad252 verified
#!/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()