Spaces:
Running
Running
File size: 1,968 Bytes
80a1334 |
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 |
#!/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() |