chenemii commited on
Commit
29db350
·
1 Parent(s): e4147b7
Files changed (2) hide show
  1. app/streamlit_app.py +25 -1
  2. requirements.txt +2 -1
app/streamlit_app.py CHANGED
@@ -8,6 +8,7 @@ import tempfile
8
  import streamlit as st
9
  from dotenv import load_dotenv
10
  import base64
 
11
  from pathlib import Path
12
  import shutil
13
  import cv2
@@ -27,6 +28,7 @@ from models.swing_analyzer import segment_swing, analyze_trajectory
27
  from models.llm_analyzer import generate_swing_analysis, create_llm_prompt, prepare_data_for_llm, check_llm_services, parse_and_format_analysis, display_formatted_analysis
28
  from utils.visualizer import create_annotated_video
29
  from utils.comparison import create_key_frame_comparison, extract_key_swing_frames
 
30
 
31
  # Import RAG functionality
32
  print("=== RAG Import Debug Information ===")
@@ -763,6 +765,28 @@ def main():
763
  'prompt': prompt
764
  }
765
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
766
  # Keep the original video file for potential annotation
767
  # Video will be cleaned up when user uploads a new video or session ends
768
 
@@ -772,7 +796,7 @@ def main():
772
 
773
  with options_col1:
774
  st.info(
775
- "**Option 1: Generate Improvement Recommendations**\n\nGet AI-powered analysis of your swing with specific tips for improvement."
776
  )
777
 
778
  with options_col2:
 
8
  import streamlit as st
9
  from dotenv import load_dotenv
10
  import base64
11
+ import threading
12
  from pathlib import Path
13
  import shutil
14
  import cv2
 
28
  from models.llm_analyzer import generate_swing_analysis, create_llm_prompt, prepare_data_for_llm, check_llm_services, parse_and_format_analysis, display_formatted_analysis
29
  from utils.visualizer import create_annotated_video
30
  from utils.comparison import create_key_frame_comparison, extract_key_swing_frames
31
+ from utils.stats_publisher import record_swing_event
32
 
33
  # Import RAG functionality
34
  print("=== RAG Import Debug Information ===")
 
765
  'prompt': prompt
766
  }
767
 
768
+ # Fire-and-forget stats publish to Hugging Face Space branch
769
+ try:
770
+ llm_status = {
771
+ 'ollama_available': llm_services.get('ollama', {}).get('available', False),
772
+ 'openai_available': llm_services.get('openai', {}).get('available', False),
773
+ }
774
+ stats_payload = {
775
+ 'event_type': 'swing_analyzed',
776
+ 'source': 'youtube' if input_option == 'YouTube URL' else 'upload',
777
+ 'video_name': os.path.basename(video_path) if video_path else None,
778
+ 'sample_rate': sample_rate,
779
+ 'frame_count': len(frames) if frames is not None else None,
780
+ 'llm_status': llm_status,
781
+ 'pro_comparison_enabled': False,
782
+ 'app_version': os.getenv('APP_VERSION', 'unknown'),
783
+ 'space_id': os.getenv('SPACE_ID'),
784
+ }
785
+
786
+ threading.Thread(target=record_swing_event, args=(stats_payload,), daemon=True).start()
787
+ except Exception as stats_err:
788
+ print(f"Stats publish error: {stats_err}")
789
+
790
  # Keep the original video file for potential annotation
791
  # Video will be cleaned up when user uploads a new video or session ends
792
 
 
796
 
797
  with options_col1:
798
  st.info(
799
+ "**Option 1: Generate Recommendations**\n\nGet AI-powered analysis of your swing with specific tips for improvement."
800
  )
801
 
802
  with options_col2:
requirements.txt CHANGED
@@ -9,7 +9,7 @@ torchvision==0.17.0
9
  openai>=1.0.0
10
  python-dotenv==1.0.0
11
  tqdm==4.66.1
12
- streamlit==1.29.0
13
  pandas==2.1.4
14
  sentence-transformers>=2.2.0
15
  faiss-cpu>=1.7.0
@@ -17,3 +17,4 @@ scikit-learn==1.3.2
17
  plotly==5.17.0
18
  tiktoken==0.5.2
19
  transformers>=4.20.0
 
 
9
  openai>=1.0.0
10
  python-dotenv==1.0.0
11
  tqdm==4.66.1
12
+ streamlit>=1.32.0
13
  pandas==2.1.4
14
  sentence-transformers>=2.2.0
15
  faiss-cpu>=1.7.0
 
17
  plotly==5.17.0
18
  tiktoken==0.5.2
19
  transformers>=4.20.0
20
+ huggingface_hub>=0.23.0