File size: 1,085 Bytes
07f9a69
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import chainlit as cl
from pilates_evaluator import PilatesVideoEvaluator

@cl.on_chat_start
async def start():
    await cl.Message(content="Welcome! Upload a video to analyze your Pilates exercise.").send()

@cl.on_message
async def main(message: cl.Message):
    if not message.elements:
        await cl.Message(content="Please upload a video file.").send()
        return

    video_file = message.elements[0]
    if not video_file.name.endswith(('.mp4', '.avi', '.mov')):
        await cl.Message(content="Please upload a valid video file (mp4, avi, mov).").send()
        return

    await cl.Message(content=f"Analyzing video: {video_file.name}...").send()

    evaluator = PilatesVideoEvaluator()
    try:
        evaluator.process_video(video_file.path)
        report_path = "pilates_evaluation_report.json"
        evaluator.generate_report(report_path)
        await cl.Message(content=f"Analysis complete! Report saved to {report_path}.").send()
    except Exception as e:
        await cl.Message(content=f"Error analyzing video: {e}").send()