CoolFace
Apppublic

Riccchmond/AI-Javelin-Coach

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

๐Ÿš€ AI Javelin Coach

This is an AI-powered application to analyze javelin throw biomechanics.

How to Use:

  1. 1.Upload a video of a javelin throw.
  2. 2.Enter the athlete's height (in meters) and weight (in kilograms).
  3. 3.Click "Analyze Throw" and wait for the analysis to complete.
  4. 4.A personalized AI video coach will appear with feedback.

AI Javelin Coach

A comprehensive javelin throw analysis application that uses computer vision and AI to provide personalized coaching feedback.

Architecture

The application is built as a single Flask application that serves both the frontend interface and handles biomechanical analysis using OpenCV and MediaPipe, with AI-powered video coaching via Tavus.io.

Setup Instructions

Prerequisites

  • โ€”Python 3.8+
  • โ€”pip (Python package manager)

Installation

  1. 1.Install Python dependencies:
bash
   pip install -r requirements.txt
  1. 1.Configure environment variables: Set the following environment variables:
  2. 2.TAVUS_API_KEY - Your Tavus.io API key
  3. 3.REPLICA_ID - Your Tavus replica ID
  4. 4.GEMINI_API_KEY - Your Google Gemini API key (optional, for enhanced LLM feedback)

Running the Application

bash
python app.py

Access the Application

  • โ€”Open your browser and navigate to http://localhost:7860 (or the port specified in your environment)

Features

  • โ€”Video Upload: Support for MP4, AVI, MOV, MKV, WEBM formats (up to 100MB)
  • โ€”Biomechanical Analysis: Real-time pose estimation and angle calculation
  • โ€”AI Coaching: Personalized video feedback using Tavus.io
  • โ€”Single Application: Consolidated Flask backend serving both frontend and analysis

API Endpoints

Flask Application (Port 7860)

  • โ€”GET / - Main application interface
  • โ€”POST /analyze_video - Complete analysis and video generation endpoint
  • โ€”GET /health - Health check endpoint
  • โ€”GET /test_analysis - Test endpoint with sample data

Environment Variables

VariableDescriptionDefault
TAVUS_API_KEYYour Tavus.io API keyyour_tavus_api_key_here
REPLICA_IDYour Tavus replica IDYOUR_REPLICA_ID_HERE
GEMINI_API_KEYGoogle Gemini API key (optional)None
PORTFlask server port7860

Docker Deployment

The application includes a Dockerfile for containerized deployment:

bash
docker build -t javelin-coach .
docker run -p 7860:7860 javelin-coach

Hugging Face Spaces Deployment

This application is optimized for deployment on Hugging Face Spaces:

  1. 1.Create a new Space on Hugging Face
  2. 2.Choose "Docker" as the SDK
  3. 3.Upload all files including the Dockerfile
  4. 4.Set your environment variables in the Space settings
  5. 5.The application will automatically build and deploy

Troubleshooting

Video Analysis Issues

  • โ€”Ensure video files are in supported formats
  • โ€”Check file size limits (100MB max)
  • โ€”Verify MediaPipe and OpenCV are properly installed
  • โ€”For optimal results, use videos 10 seconds or less

API Configuration

  • โ€”Ensure TAVUS_API_KEY and REPLICA_ID are properly set
  • โ€”Check that your Tavus.io account has sufficient credits
  • โ€”Verify API keys are valid and not expired

Development Notes

  • โ€”The application includes fallback analysis when computer vision processing fails
  • โ€”Tavus video generation requires valid API credentials
  • โ€”The system gracefully handles errors and provides meaningful feedback to users