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()