Spaces:
Sleeping
Sleeping
File size: 3,009 Bytes
1f4e4ae | 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 | #!/usr/bin/env python3
"""
Startup script for AI Sign Language Interpreter
This script starts both the landing page (Flask) and the main app (Streamlit)
"""
import subprocess
import threading
import time
import webbrowser
import sys
import os
def start_streamlit():
"""Start Streamlit app"""
print("π Starting Streamlit app...")
try:
subprocess.run([
sys.executable, '-m', 'streamlit', 'run', 'app_enhanced.py',
'--server.port=8502',
'--server.headless=true',
'--server.runOnSave=true'
])
except KeyboardInterrupt:
print("Streamlit app stopped.")
except Exception as e:
print(f"Error starting Streamlit: {e}")
def start_flask():
"""Start Flask server for landing page"""
print("π Starting Flask server...")
try:
subprocess.run([sys.executable, 'server.py'])
except KeyboardInterrupt:
print("Flask server stopped.")
except Exception as e:
print(f"Error starting Flask: {e}")
def main():
print("=" * 60)
print("π€ AI Sign Language Interpreter")
print("=" * 60)
print("Starting application servers...")
print()
# Check if required files exist
required_files = ['app_enhanced.py', 'server.py', 'models/model.tflite', 'models/labels.txt']
missing_files = [f for f in required_files if not os.path.exists(f)]
if missing_files:
print("β Missing required files:")
for file in missing_files:
print(f" - {file}")
print("\nPlease ensure all required files are present.")
return
print("β
All required files found.")
print()
try:
# Start Streamlit in a separate thread
streamlit_thread = threading.Thread(target=start_streamlit, daemon=True)
streamlit_thread.start()
# Give Streamlit time to start
print("β³ Waiting for Streamlit to initialize...")
time.sleep(5)
# Start Flask (this will block)
print("π Flask server starting on http://localhost:5000")
print("π€ Streamlit app available on http://localhost:8501")
print()
print("π Instructions:")
print(" 1. Visit http://localhost:5000 for the landing page")
print(" 2. Click 'Try it Out' to access the AI interpreter")
print(" 3. Allow camera access when prompted")
print(" 4. Start making sign language gestures!")
print()
print("Press Ctrl+C to stop all servers")
print("=" * 60)
# Open browser automatically
time.sleep(2)
webbrowser.open('http://localhost:5000')
# Start Flask server
start_flask()
except KeyboardInterrupt:
print("\nπ Shutting down servers...")
print("π Thank you for using AI Sign Language Interpreter!")
except Exception as e:
print(f"β Error: {e}")
if __name__ == "__main__":
main()
|