""" GATE Motion Analysis - Deployment Script Simplified deployment for Gradio Spaces """ import subprocess import sys import os from pathlib import Path def check_requirements(): """Check if required packages are installed.""" try: import gradio print(f"โœ“ Gradio {gradio.__version__} found") return True except ImportError: print("โœ— Gradio not found. Install with: pip install gradio") return False def deploy_to_spaces(): """Deploy to Hugging Face Spaces using gradio deploy.""" print("๐Ÿš€ Deploying GATE Motion Analysis to Hugging Face Spaces...") print("๐Ÿ“‹ This will:") print(" 1. Create a new Space on Hugging Face") print(" 2. Upload your code and requirements") print(" 3. Enable GPU acceleration if available") print() # Change to deployment directory os.chdir(Path(__file__).parent) try: # Run gradio deploy command result = subprocess.run([ sys.executable, "-m", "gradio", "deploy", "--title", "GATE Motion Analysis", "--app-file", "app.py" ], capture_output=False, text=True) if result.returncode == 0: print("โœ… Deployment successful!") else: print("โŒ Deployment failed. Check your Hugging Face credentials.") except Exception as e: print(f"โŒ Error during deployment: {e}") def test_locally(): """Test the app locally before deployment.""" print("๐Ÿงช Testing GATE Motion Analysis locally...") try: # Import and run the app from app import main main() except ImportError as e: print(f"โŒ Import error: {e}") print("Make sure all dependencies are installed:") print("pip install -r requirements.txt") except Exception as e: print(f"โŒ Error running app: {e}") def main(): """Main deployment script.""" if not check_requirements(): sys.exit(1) print("\nGATE Motion Analysis Deployment") print("=" * 40) print("1. Test locally") print("2. Deploy to Hugging Face Spaces") print("3. Exit") choice = input("\nSelect option (1-3): ").strip() if choice == "1": test_locally() elif choice == "2": deploy_to_spaces() else: print("Goodbye!") if __name__ == "__main__": main()