chenemii commited on
Commit
c6988d2
·
1 Parent(s): 8ed350e
Files changed (3) hide show
  1. app/main.py +16 -0
  2. app/streamlit_app.py +14 -22
  3. requirements.txt +1 -1
app/main.py CHANGED
@@ -92,6 +92,22 @@ def main():
92
  sample_rate=sample_rate)
93
  print(f"Annotated video saved to: {output_path}")
94
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
  print("\nAnalysis complete!")
96
 
97
  except Exception as e:
 
92
  sample_rate=sample_rate)
93
  print(f"Annotated video saved to: {output_path}")
94
 
95
+ # Log swing analysis to Trackio
96
+ try:
97
+ import trackio
98
+ trackio.init(project="par-ity-golf-swing", config={
99
+ "input_method": "cli",
100
+ "sample_rate": sample_rate
101
+ })
102
+ trackio.log({
103
+ "swings_analyzed": 1,
104
+ "frames_processed": len(frames) if frames is not None else 0,
105
+ "num_detections": len(detections) if detections is not None else 0
106
+ })
107
+ trackio.finish()
108
+ except Exception as _trackio_err:
109
+ print(f"Trackio logging skipped: {_trackio_err}")
110
+
111
  print("\nAnalysis complete!")
112
 
113
  except Exception as e:
app/streamlit_app.py CHANGED
@@ -8,7 +8,6 @@ import tempfile
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,7 +27,6 @@ from models.swing_analyzer import segment_swing, analyze_trajectory
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,27 +763,21 @@ def main():
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
- print(f"Stats payload prepared: {stats_payload}")
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
 
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
  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
  'prompt': prompt
764
  }
765
 
766
+ # Track swing analysis with Trackio (one run per analysis)
767
  try:
768
+ import trackio
769
+ trackio.init(project="par-ity-golf-swing", config={
770
+ "input_method": input_option,
771
+ "sample_rate": sample_rate
772
+ })
773
+ trackio.log({
774
+ "swings_analyzed": 1,
775
+ "frames_processed": len(frames) if frames is not None else 0,
776
+ "num_detections": len(detections) if detections is not None else 0
777
+ })
778
+ trackio.finish()
779
+ except Exception as _trackio_err:
780
+ print(f"Trackio logging skipped: {_trackio_err}")
 
 
 
 
 
 
781
 
782
  # Keep the original video file for potential annotation
783
  # Video will be cleaned up when user uploads a new video or session ends
requirements.txt CHANGED
@@ -17,4 +17,4 @@ scikit-learn==1.3.2
17
  plotly==5.17.0
18
  tiktoken==0.5.2
19
  transformers>=4.20.0
20
- huggingface_hub>=0.23.0
 
17
  plotly==5.17.0
18
  tiktoken==0.5.2
19
  transformers>=4.20.0
20
+ trackio