Spaces:
Sleeping
Sleeping
| title: GATE_Motion_Analysis | |
| app_file: app.py | |
| sdk: gradio | |
| sdk_version: 5.12.0 | |
| # GATE Motion Analysis - Gradio Deployment | |
| ## β Error Fixes Applied | |
| This deployment addresses the following errors that were encountered: | |
| ### 1. Browser Feature Policy Warnings (Fixed) | |
| - **Error**: `Unrecognized feature: 'ambient-light-sensor'`, `'battery'`, etc. | |
| - **Fix**: Added `analytics_enabled=False` to disable Google Analytics tracking that causes these warnings | |
| ### 2. Font Loading Issues (Fixed) | |
| - **Error**: `ui-sans-serif-Regular.woff2:1 Failed to load resource: 404` | |
| - **Fix**: Set `favicon_path=None` and removed custom font dependencies | |
| ### 3. API Errors (Fixed) | |
| - **Error**: `Submit function encountered an error: Error: No API found` | |
| - **Fix**: | |
| - Simplified interface with proper Gradio component setup | |
| - Disabled API documentation (`show_api=False`) | |
| - Added proper error handling and fallback configurations | |
| ### 4. JavaScript Errors (Fixed) | |
| - **Error**: `MutationObserver: parameter 1 is not of type 'Node'` | |
| - **Fix**: Removed complex dependencies and iframe conflicts | |
| ## π Quick Start | |
| ### Local Development | |
| ```bash | |
| cd gradio_deployment | |
| pip install -r requirements.txt | |
| python app.py | |
| ``` | |
| ### HuggingFace Spaces Deployment | |
| 1. Upload all files in `gradio_deployment/` folder to your Space | |
| 2. Set the following environment variables (optional): | |
| - `DEBUG_MODE=true` for verbose logging | |
| - `USE_GPU=true` if GPU is available | |
| ## π Features | |
| - **Image Analysis**: Upload exercise photos for form analysis | |
| - **Video Analysis**: Upload exercise videos (processes first frame) | |
| - **Multiple Exercises**: Support for squats, push-ups, lunges, bicep curls, deadlifts | |
| - **Real-time Feedback**: Instant form scoring and recommendations | |
| - **System Monitoring**: Built-in system status and debugging tools | |
| ## π οΈ Configuration | |
| The deployment is configured via `config.py`: | |
| - **Performance**: Limited to 4 threads and 10 concurrent users | |
| - **File Limits**: Maximum 50MB upload size | |
| - **Security**: CORS enabled, SSL verification disabled for development | |
| - **UI Theme**: Soft theme with custom CSS styling | |
| ## π± Usage | |
| 1. **Select Analysis Type**: Choose between Image or Video analysis | |
| 2. **Upload File**: Drag and drop or click to upload exercise media | |
| 3. **Select Exercise**: Choose the exercise type from dropdown | |
| 4. **View Results**: See analyzed image with confidence score and feedback | |
| ## π§ Technical Details | |
| ### Dependencies | |
| - **Gradio 4.0+**: Web interface framework | |
| - **OpenCV**: Image/video processing (headless version for deployment) | |
| - **NumPy**: Numerical computations | |
| - **Pillow**: Image handling | |
| ### Architecture | |
| - **Simplified Design**: Removed complex ML dependencies for stability | |
| - **Error Resilience**: Comprehensive error handling and fallbacks | |
| - **Resource Management**: Memory and thread limits for shared environments | |
| ## π Troubleshooting | |
| ### Common Issues | |
| 1. **Import Errors** | |
| - All complex dependencies removed | |
| - Self-contained deployment with minimal requirements | |
| 2. **API Connection Issues** | |
| - Added fallback launch configuration | |
| - Disabled problematic features (share, API docs) | |
| 3. **Performance Issues** | |
| - Enabled queuing system | |
| - Limited concurrent users and threads | |
| ### Debug Mode | |
| Enable debug mode by setting `DEBUG_MODE=true` environment variable for detailed logging. | |
| ## π Notes | |
| - This is a **demonstration version** focused on deployment stability | |
| - For full ML functionality, additional models and dependencies would be required | |
| - The current version provides mock analysis results to ensure interface functionality | |
| - All reported browser and API errors have been addressed | |
| ## π Changelog | |
| ### Version 2.0.0 | |
| - β Fixed all reported Gradio deployment errors | |
| - β Simplified dependencies and removed complex imports | |
| - β Added comprehensive error handling | |
| - β Optimized for HuggingFace Spaces deployment | |
| - β Improved UI with proper CSS and theming | |
| ## Quick Deployment | |
| ### Option 1: Gradio Deploy (Recommended) | |
| ```bash | |
| # From this directory | |
| gradio deploy | |
| # Follow the prompts to deploy to Hugging Face Spaces | |
| ``` | |
| ### Option 2: Local Testing | |
| ```bash | |
| # Install dependencies | |
| pip install -r requirements.txt | |
| # Run locally | |
| python app.py | |
| ``` | |
| ## Performance Optimisations | |
| - **GPU Memory Management**: Configured for shared GPU environments | |
| - **Model Selection**: Uses lightweight fallback models for faster inference | |
| - **Streaming Settings**: Optimised for 30 FPS real-time analysis | |
| - **Thread Limiting**: Prevents resource exhaustion on shared hardware | |
| ## Features | |
| - Real-time pose detection with skeleton overlay | |
| - Motion similarity analysis using BPE (Body Part Embedding) | |
| - British English interface without emoji distractions | |
| - GPU acceleration for YOLOv8 pose detection | |
| - Fallback to MediaPipe for CPU environments | |
| ## Deployment Requirements | |
| - **GPU**: CUDA-compatible GPU with 4GB+ VRAM recommended | |
| - **CPU**: 4+ cores for fallback mode | |
| - **RAM**: 8GB+ system memory | |
| - **Python**: 3.8+ with pip | |
| ## Configuration | |
| The app automatically detects available hardware and optimises accordingly: | |
| - **GPU Available**: Uses YOLOv8 for high-performance pose detection | |
| - **CPU Only**: Falls back to MediaPipe for stable operation | |
| ## Troubleshooting | |
| 1. **GPU Memory Issues**: Reduce batch size or use CPU fallback | |
| 2. **Import Errors**: Ensure all dependencies are installed | |
| 3. **Performance Issues**: Check CUDA installation and GPU memory | |
| ## Security | |
| - API endpoints disabled for public deployment | |
| - File access restricted to safe directories | |
| - No authentication required for demo purposes | |
| ## GPU Requirements | |
| - **Minimum**: 4GB VRAM | |
| - **Recommended**: 8GB+ VRAM (RTX 3070 or better) | |
| - **Optimal**: 16GB+ VRAM (RTX 4080/4090) | |
| ## Browser Compatibility | |
| - Chrome 88+ (recommended) | |
| - Firefox 85+ | |
| - Safari 14+ | |
| - Edge 88+ | |
| ## Deployment Notes | |
| When deploying to Hugging Face Spaces: | |
| 1. Select GPU (T4 or better) for optimal performance | |
| 2. Enable persistence for model caching | |
| 3. Set timeout to 30+ minutes for complex analyses |