Spaces:
Sleeping
Sleeping
""" | |
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() |