Spaces:
Sleeping
Sleeping
File size: 2,543 Bytes
ef4a6ad |
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 |
"""
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() |