Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from gully_drs_core import pose_analysis | |
| def analyze_video(uploaded_practice_video, video_type): | |
| try: | |
| feedback = pose_analysis.analyze_practice_video(uploaded_practice_video, video_type) | |
| return feedback["recommendations"] | |
| except Exception as e: | |
| return [f"Error during video analysis: {e}"] | |
| def create_analysis_ui(): | |
| with gr.Blocks() as demo: | |
| gr.Markdown("### 📤 Upload Batting/Bowling Video for AI Analysis") | |
| # Video upload component (fixed type parameter) | |
| uploaded_practice_video = gr.File(label="Upload your practice video", type="filepath", interactive=True) | |
| # Video type selection | |
| video_type = gr.Dropdown(choices=["Batting", "Bowling"], label="Select Video Type", interactive=True) | |
| # Output display for analysis results | |
| result_output = gr.Textbox(label="AI Feedback", interactive=False) | |
| # Process button and results | |
| analyze_btn = gr.Button("🎯 Analyze Performance") | |
| # Link button click to analysis function | |
| analyze_btn.click( | |
| fn=analyze_video, | |
| inputs=[uploaded_practice_video, video_type], | |
| outputs=[result_output] | |
| ) | |
| return demo | |
| if __name__ == "__main__": | |
| create_analysis_ui() |