#!/usr/bin/env python3 """ Simple launcher script for the Gradio app with better error handling. """ import os import sys from dotenv import load_dotenv # Load environment variables load_dotenv() def check_requirements(): """Check if all required packages are installed.""" required_packages = [ 'gradio', 'google.generativeai', 'torch', 'psutil' ] missing = [] for package in required_packages: try: __import__(package.replace('-', '_')) except ImportError: missing.append(package) if missing: print(f"Missing packages: {', '.join(missing)}") print("Please run: pip install -r requirements.txt") return False return True def check_api_key(): """Check if API key is configured.""" api_key = os.getenv('GOOGLE_API_KEY') if not api_key: print("ERROR: GOOGLE_API_KEY not found in .env file") print("Please add your Gemini API key to the .env file:") print("GOOGLE_API_KEY=your_api_key_here") return False return True def main(): print("🚀 Starting Auto-Diffusers Gradio App...") # Check requirements if not check_requirements(): sys.exit(1) if not check_api_key(): sys.exit(1) try: from gradio_app import create_gradio_interface print("✅ All requirements satisfied") print("🌐 Launching Gradio interface...") interface = create_gradio_interface() interface.launch( server_name="0.0.0.0", server_port=7860, share=True, show_error=True, inbrowser=True ) except ImportError as e: print(f"Import error: {e}") print("Make sure all dependencies are installed: pip install -r requirements.txt") except Exception as e: print(f"Error launching app: {e}") if __name__ == "__main__": main()