Spaces:
Paused
Paused
trackio
Browse files- app/main.py +16 -0
- app/streamlit_app.py +14 -22
- 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 |
-
#
|
| 769 |
try:
|
| 770 |
-
|
| 771 |
-
|
| 772 |
-
|
| 773 |
-
|
| 774 |
-
|
| 775 |
-
|
| 776 |
-
|
| 777 |
-
|
| 778 |
-
|
| 779 |
-
|
| 780 |
-
|
| 781 |
-
|
| 782 |
-
|
| 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 |
-
|
|
|
|
| 17 |
plotly==5.17.0
|
| 18 |
tiktoken==0.5.2
|
| 19 |
transformers>=4.20.0
|
| 20 |
+
trackio
|