chenemii commited on
Commit
1718302
·
1 Parent(s): c6988d2
Files changed (1) hide show
  1. app/streamlit_app.py +23 -15
app/streamlit_app.py CHANGED
@@ -763,21 +763,7 @@ def main():
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
@@ -805,6 +791,28 @@ def main():
805
 
806
  # Show action buttons and their results (only if analysis is complete)
807
  if st.session_state.video_analyzed:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
808
  # Display the GPT prompt in an expander
809
  if 'prompt' in st.session_state.analysis_data:
810
  with st.expander("View LLM Prompt", expanded=False):
 
763
  'prompt': prompt
764
  }
765
 
766
+ # Trackio logging moved out of try block to avoid impacting UI
 
 
 
 
 
 
 
 
 
 
 
 
 
 
767
 
768
  # Keep the original video file for potential annotation
769
  # Video will be cleaned up when user uploads a new video or session ends
 
791
 
792
  # Show action buttons and their results (only if analysis is complete)
793
  if st.session_state.video_analyzed:
794
+ # Best-effort Trackio logging once per analyzed video
795
+ if not st.session_state.get("_trackio_logged_once"):
796
+ try:
797
+ import trackio
798
+ data = st.session_state.analysis_data
799
+ frames = data.get('frames')
800
+ detections = data.get('detections')
801
+ trackio.init(project="par-ity-golf-swing", config={
802
+ "input_method": "YouTube URL" if isinstance(data.get('video_path'), str) and 'youtube' in data.get('video_path', '').lower() else "upload",
803
+ "sample_rate": data.get('sample_rate', 1)
804
+ })
805
+ trackio.log({
806
+ "swings_analyzed": 1,
807
+ "frames_processed": len(frames) if frames is not None else 0,
808
+ "num_detections": len(detections) if detections is not None else 0
809
+ })
810
+ trackio.finish()
811
+ st.session_state._trackio_logged_once = True
812
+ except Exception as _trackio_err:
813
+ # Never block UI due to telemetry
814
+ print(f"Trackio logging skipped: {_trackio_err}")
815
+
816
  # Display the GPT prompt in an expander
817
  if 'prompt' in st.session_state.analysis_data:
818
  with st.expander("View LLM Prompt", expanded=False):