Upload app.py
Browse files
app.py
CHANGED
|
@@ -12,6 +12,7 @@ import cv2
|
|
| 12 |
import numpy as np
|
| 13 |
import sys
|
| 14 |
from pathlib import Path
|
|
|
|
| 15 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 16 |
|
| 17 |
# ------------------------------------------------------------------
|
|
@@ -92,7 +93,7 @@ load_all_models()
|
|
| 92 |
# ------------------------------------------------------------------
|
| 93 |
# Feedback Generation
|
| 94 |
# ------------------------------------------------------------------
|
| 95 |
-
def generate_feedback(persona_name, input_report):
|
| 96 |
"""Generates feedback using the selected model and prompt structure."""
|
| 97 |
|
| 98 |
model = MODELS_CACHE.get(persona_name)
|
|
@@ -136,7 +137,8 @@ def generate_feedback(persona_name, input_report):
|
|
| 136 |
# ------------------------------------------------------------------
|
| 137 |
# Main Analysis Function
|
| 138 |
# ------------------------------------------------------------------
|
| 139 |
-
def analyze_video(video_file, persona_choice, reference_exercise):
|
|
|
|
| 140 |
if video_file is None:
|
| 141 |
return "Please upload a video first.", "", "{}"
|
| 142 |
|
|
@@ -205,11 +207,12 @@ with gr.Blocks(title="AI Fitness Coach", theme=gr.themes.Soft()) as demo:
|
|
| 205 |
visible=False
|
| 206 |
)
|
| 207 |
|
| 208 |
-
# Connect button
|
| 209 |
analyze_btn.click(
|
| 210 |
fn=analyze_video,
|
| 211 |
inputs=[video_input, persona_select, reference_select],
|
| 212 |
-
outputs=[report_output, feedback_output, json_output]
|
|
|
|
| 213 |
)
|
| 214 |
|
| 215 |
gr.Markdown("""
|
|
@@ -221,5 +224,5 @@ with gr.Blocks(title="AI Fitness Coach", theme=gr.themes.Soft()) as demo:
|
|
| 221 |
|
| 222 |
# Launch
|
| 223 |
if __name__ == "__main__":
|
| 224 |
-
#
|
| 225 |
-
demo.launch(share=
|
|
|
|
| 12 |
import numpy as np
|
| 13 |
import sys
|
| 14 |
from pathlib import Path
|
| 15 |
+
from typing import Tuple
|
| 16 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 17 |
|
| 18 |
# ------------------------------------------------------------------
|
|
|
|
| 93 |
# ------------------------------------------------------------------
|
| 94 |
# Feedback Generation
|
| 95 |
# ------------------------------------------------------------------
|
| 96 |
+
def generate_feedback(persona_name: str, input_report: str) -> str:
|
| 97 |
"""Generates feedback using the selected model and prompt structure."""
|
| 98 |
|
| 99 |
model = MODELS_CACHE.get(persona_name)
|
|
|
|
| 137 |
# ------------------------------------------------------------------
|
| 138 |
# Main Analysis Function
|
| 139 |
# ------------------------------------------------------------------
|
| 140 |
+
def analyze_video(video_file, persona_choice: str, reference_exercise: str) -> Tuple[str, str, str]:
|
| 141 |
+
"""Analyze video and return technical report, coach feedback, and JSON results."""
|
| 142 |
if video_file is None:
|
| 143 |
return "Please upload a video first.", "", "{}"
|
| 144 |
|
|
|
|
| 207 |
visible=False
|
| 208 |
)
|
| 209 |
|
| 210 |
+
# Connect button (api_name=False disables API schema generation which has bugs in Gradio 5.x)
|
| 211 |
analyze_btn.click(
|
| 212 |
fn=analyze_video,
|
| 213 |
inputs=[video_input, persona_select, reference_select],
|
| 214 |
+
outputs=[report_output, feedback_output, json_output],
|
| 215 |
+
api_name=False
|
| 216 |
)
|
| 217 |
|
| 218 |
gr.Markdown("""
|
|
|
|
| 224 |
|
| 225 |
# Launch
|
| 226 |
if __name__ == "__main__":
|
| 227 |
+
# Disable SSR (experimental) and share (not needed for HF Spaces)
|
| 228 |
+
demo.launch(ssr_mode=False, share=False)
|