chenemii commited on
Commit
cb404fd
·
1 Parent(s): 1718302
Files changed (1) hide show
  1. app/streamlit_app.py +24 -18
app/streamlit_app.py CHANGED
@@ -791,27 +791,33 @@ def main():
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:
 
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 (async, non-blocking)
795
  if not st.session_state.get("_trackio_logged_once"):
796
  try:
797
+ import threading
798
+ def _log_trackio_async():
799
+ try:
800
+ import trackio
801
+ data = st.session_state.analysis_data
802
+ frames = data.get('frames')
803
+ detections = data.get('detections')
804
+ trackio.init(project="par-ity-golf-swing", config={
805
+ "input_method": "YouTube URL" if isinstance(data.get('video_path'), str) and 'youtube' in data.get('video_path', '').lower() else "upload",
806
+ "sample_rate": data.get('sample_rate', 1)
807
+ })
808
+ trackio.log({
809
+ "swings_analyzed": 1,
810
+ "frames_processed": len(frames) if frames is not None else 0,
811
+ "num_detections": len(detections) if detections is not None else 0
812
+ })
813
+ trackio.finish()
814
+ except Exception:
815
+ pass
816
+ t = threading.Thread(target=_log_trackio_async, daemon=True)
817
+ t.start()
818
  st.session_state._trackio_logged_once = True
819
+ except Exception:
820
+ pass
 
821
 
822
  # Display the GPT prompt in an expander
823
  if 'prompt' in st.session_state.analysis_data: