astraybirdss's picture
Upload folder using huggingface_hub
3a15d92 verified
raw
history blame
2.54 kB
"""
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()