CoolFace
Apppublic

neha12312/atheletic-performance-analysis

sourceHugging Facemitupdated 1y agoView on Hugging Face
0likes
App README

๐Ÿƒโ€โ™‚๏ธ Athletic Ability Analysis

A powerful web application that analyzes athletic jump performance from videos using computer vision and pose estimation. Upload a video file or provide a YouTube URL to get detailed metrics about your jump height, flight time, and overall athletic performance.

โœจ Features

  • โ€”๐ŸŽฅ YouTube Integration: Analyze videos directly from YouTube URLs
  • โ€”๐Ÿ“ File Upload: Support for MP4, AVI, MOV, and other video formats
  • โ€”๐Ÿ“Š Comprehensive Biomechanical Analysis: Jump height, flight time, peak power, force development, and more
  • โ€”๐Ÿค– AI Sports Coach: Get personalized sport recommendations and technique improvements
  • โ€”๐ŸŽฏ Real-time Processing: Fast analysis using Google's MediaPipe pose estimation
  • โ€”๐Ÿ“ฑ Modern Interface: Beautiful, responsive Gradio interface with multiple analysis modes
  • โ€”๐Ÿ”ฌ Scientific Accuracy: Professional-grade biomechanical analysis
  • โ€”โšก Advanced Metrics: Peak power output, rate of force development, impulse, and ground contact time

๐Ÿš€ Live Demo

Try the live demo on Hugging Face Spaces: Athletic Ability Analysis

๐Ÿ“Š How It Works

  1. 1.Pose Detection: Uses Google's MediaPipe to detect human pose landmarks in each video frame
  2. 2.Hip Tracking: Tracks the midpoint between left and right hip joints throughout the video
  3. 3.Jump Analysis: Calculates jump metrics based on hip trajectory:
  4. 4.Jump Height: Vertical distance from crouch to apex (in cm)
  5. 5.Flight Time: Duration of airborne phase (in seconds)
  6. 6.Normalized Rise: Jump height relative to body position (0-1 scale)
  7. 7.Performance Insights: Contextual feedback based on performance level

๐Ÿ› ๏ธ Technology Stack

  • โ€”Backend: Python with OpenCV, NumPy, and MediaPipe
  • โ€”Frontend: Gradio for beautiful, interactive web interface
  • โ€”Video Processing: yt-dlp for YouTube downloads, OpenCV for video analysis
  • โ€”Deployment: Hugging Face Spaces

๐Ÿš€ Deploy to Hugging Face Spaces

Quick Deployment

  1. 1.Fork this repository on GitHub
  2. 2.Create a new Space on Hugging Face Spaces
  3. 3.Connect your GitHub repo to the Space
  4. 4.Set the Space type to "Gradio"
  5. 5.โš ๏ธ IMPORTANT: Set up API Key Environment Variable:
  6. 6.Go to your Space's "Settings" tab
  7. 7.Add a new "Secret" with name: GEMINI_API_KEY
  8. 8.Add your Gemini API key as the value
  9. 9.This keeps your API key secure and private
  10. 10.Wait for automatic deployment

Manual Deployment

  1. 1.Clone the repository:
bash
   git clone https://github.com/YOUR_USERNAME/athletic-ability-analysis
   cd athletic-ability-analysis
  1. 1.Create a new Space on Hugging Face Spaces
  1. 1.Upload files to your Space:
  2. 2.app.py (main application)
  3. 3.athletic_performance.py (analysis module)
  4. 4.requirements.txt (dependencies)
  5. 5.README.md (this file)
  1. 1.๐Ÿ” Set up Secure API Key:
  2. 2.In your Space settings, add environment variable: GEMINI_API_KEY
  3. 3.Get your free API key from Google AI Studio
  4. 4.NEVER commit API keys to your repository!
  1. 1.Space will automatically deploy using Gradio

๐Ÿ” API Key Security

For the AI Sports Coach feature, you need a Google Gemini API key:

  • โ€”๐Ÿ†“ Free: Get your key at Google AI Studio
  • โ€”๐Ÿ”’ Secure: Set as environment variable GEMINI_API_KEY in HF Spaces
  • โ€”๐Ÿšซ Never: Commit API keys to code repositories
  • โ€”โœ… Best Practice: Use HF Spaces secrets for deployment

๐Ÿ“ Project Structure

athletic-ability-analysis/
โ”œโ”€โ”€ app.py                    # Main Gradio application & UI
โ”œโ”€โ”€ athletic_performance.py   # Core analysis & AI integration
โ”œโ”€โ”€ requirements.txt          # Python dependencies
โ”œโ”€โ”€ README.md                # This file (with HF Spaces header)
โ”œโ”€โ”€ deploy_hf.py             # Deployment helper script
โ”œโ”€โ”€ test_deployment.py       # Dependency testing
โ””โ”€โ”€ .gitignore              # Git ignore file

๐ŸŽฏ Usage

Web Interface

  1. 1.Visit your Hugging Face Space URL
  2. 2.Enter your height and weight for accurate biomechanical calculations
  3. 3.Choose your analysis type:

๐Ÿ“Š Standard Analysis:

  • โ€”YouTube or File Upload tabs
  • โ€”Get comprehensive biomechanical metrics

๐Ÿค– AI Sports Coach:

  • โ€”Select your gender
  • โ€”Provide video (YouTube URL or upload)
  • โ€”Get personalized sport recommendations
  • โ€”Receive jump technique improvement suggestions
  1. 1.Click analyze and wait for processing
  2. 2.View comprehensive results with detailed insights

Supported Video Formats

  • โ€”YouTube: Any public YouTube video URL
  • โ€”Upload: MP4, AVI, MOV, MKV, WebM

๐Ÿ“ Video Requirements

For optimal results, ensure your videos meet these criteria:

  • โ€”๐ŸŽฏ Full Body Visible: Person should be completely visible throughout the jump
  • โ€”๐Ÿ’ก Good Lighting: Clear visibility with minimal shadows
  • โ€”๐ŸŽฌ Clean Background: Minimal clutter for better pose detection
  • โ€”โฑ๏ธ Optimal Duration: 3-30 seconds works best
  • โ€”๐Ÿ“ Vertical Jumps: Straight vertical jumps produce most accurate results
  • โ€”๐Ÿ”“ Public Access: For YouTube videos, ensure they're not private

๐Ÿ“Š Performance Metrics

The app analyzes and provides:

  • โ€”Jump Height (cm): Absolute vertical distance based on your body height
  • โ€”Flight Time (s): Duration of airborne phase
  • โ€”Normalized Rise: Jump efficiency relative to body size
  • โ€”Performance Level: Contextual feedback (Excellent/Good/Moderate/Starting)
  • โ€”Training Insights: Personalized recommendations

๐Ÿ”ฌ Technical Details

  • โ€”Pose Estimation: MediaPipe Pose with 33 body landmarks
  • โ€”Processing: Real-time frame-by-frame analysis
  • โ€”Smoothing: Moving average filtering for noise reduction
  • โ€”Calculations: Biomechanically accurate jump metrics
  • โ€”Performance: Optimized for cloud deployment

โš ๏ธ Limitations

  • โ€”Processing Time: Large videos may take 2-5 minutes to process
  • โ€”File Size: Recommended maximum 100MB for uploads
  • โ€”Pose Visibility: Person must be clearly visible throughout the jump
  • โ€”Jump Type: Optimized for vertical jumps (not broad jumps)

๐Ÿ”ง Local Development

To run locally:

  1. 1.Install dependencies:
bash
   pip install -r requirements.txt
  1. 1.Run the application:
bash
   python app.py
  1. 1.Open in browser: Gradio will provide a local URL

๐Ÿค Contributing

Contributions are welcome! Please feel free to:

  • โ€”Submit bug reports and feature requests
  • โ€”Improve documentation
  • โ€”Add new analysis features
  • โ€”Optimize performance

๐Ÿ“„ License

This project is open source and available under the MIT License.

๐Ÿ†˜ Support & Troubleshooting

If you encounter issues:

  1. 1.Video Quality: Ensure good lighting and clear visibility
  2. 2.YouTube URLs: Make sure the video is public and accessible
  3. 3.File Formats: Use supported video formats (MP4, AVI, MOV, etc.)
  4. 4.Processing Time: Be patient with large or high-resolution videos
  5. 5.Pose Detection: Person should be fully visible during the jump

๐Ÿ™ Acknowledgments

  • โ€”Google MediaPipe for state-of-the-art pose estimation
  • โ€”OpenCV for computer vision processing
  • โ€”yt-dlp for YouTube video downloading
  • โ€”Gradio for the beautiful web interface
  • โ€”Hugging Face for hosting and deployment platform

๐Ÿ“ˆ Example Results

๐ŸŽ‰ Jump Analysis Results

๐Ÿ“Š Performance Metrics
- Jump Height: 52.34 cm
- Flight Time: 0.623 seconds  
- Normalized Rise: 0.387 (38.7%)

๐Ÿ”ฅ Excellent jump height! This is above average performance.
โฑ๏ธ Great flight time! Shows good explosive power.