Spaces:
Runtime error
Runtime error
File size: 4,034 Bytes
ab7e923 | 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 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | #!/usr/bin/env python3
"""
Test script to verify all dependencies are working before deployment
"""
def test_imports():
"""Test all required imports."""
print("π§ͺ Testing imports...")
try:
import gradio as gr
print(f"β
Gradio {gr.__version__}")
except ImportError as e:
print(f"β Gradio import failed: {e}")
return False
try:
import cv2
print(f"β
OpenCV {cv2.__version__}")
except ImportError as e:
print(f"β OpenCV import failed: {e}")
return False
try:
import numpy as np
print(f"β
NumPy {np.__version__}")
except ImportError as e:
print(f"β NumPy import failed: {e}")
return False
try:
import mediapipe as mp
print(f"β
MediaPipe {mp.__version__}")
except ImportError as e:
print(f"β MediaPipe import failed: {e}")
return False
try:
import yt_dlp
print(f"β
yt-dlp {yt_dlp.version.__version__}")
except ImportError as e:
print(f"β yt-dlp import failed: {e}")
return False
try:
import pandas as pd
print(f"β
Pandas {pd.__version__}")
except ImportError as e:
print(f"β Pandas import failed: {e}")
return False
return True
def test_app_creation():
"""Test that the app can be created without errors."""
print("\nποΈ Testing app creation...")
try:
from app import create_interface
app = create_interface()
print("β
App created successfully")
print("β
Gradio interface compatible")
return True
except TypeError as e:
if "unexpected keyword argument" in str(e):
print(f"β Gradio compatibility issue: {e}")
print("π‘ This usually means a Gradio component parameter is not supported")
else:
print(f"β Type error in app creation: {e}")
return False
except Exception as e:
print(f"β App creation failed: {e}")
return False
def test_mediapipe_initialization():
"""Test MediaPipe pose initialization."""
print("\nπ€ Testing MediaPipe pose initialization...")
try:
import mediapipe as mp
mp_pose = mp.solutions.pose
pose = mp_pose.Pose(
static_image_mode=False,
model_complexity=1,
enable_segmentation=False
)
pose.close()
print("β
MediaPipe pose initialized successfully")
return True
except Exception as e:
print(f"β MediaPipe pose initialization failed: {e}")
return False
def main():
print("πββοΈ Athletic Ability Analysis - Deployment Test")
print("=" * 50)
all_tests_passed = True
# Test imports
if not test_imports():
all_tests_passed = False
# Test MediaPipe initialization
if not test_mediapipe_initialization():
all_tests_passed = False
# Test app creation
if not test_app_creation():
all_tests_passed = False
print("\n" + "=" * 50)
if all_tests_passed:
print("π All tests passed! Ready for deployment.")
print("\nπ Deployment files verified:")
import os
files = ["app.py", "requirements.txt", "README.md"]
for file in files:
if os.path.exists(file):
print(f"β
{file}")
else:
print(f"β {file} missing")
print("\nπ You can now deploy to Hugging Face Spaces:")
print("1. Go to https://huggingface.co/spaces")
print("2. Create a new Space with SDK: Gradio")
print("3. Upload app.py, requirements.txt, and README.md")
print("4. Wait for automatic deployment")
else:
print("β Some tests failed. Please fix the issues before deployment.")
print("\nπ§ Try running: pip install -r requirements.txt")
if __name__ == "__main__":
main()
|