import gradio as gr import tempfile from main import main # main.py는 분석된 영상을 output_videos/output_video.avi에 저장한다고 가정 def analyze_video(video_file): # 업로드된 파일을 임시 경로에 저장 with tempfile.NamedTemporaryFile(delete=False, suffix=".mp4") as tmp: tmp.write(video_file.read()) temp_path = tmp.name # main.py 실행 (업로드된 영상 경로를 넘겨서 분석) main(temp_path) # 분석된 영상 경로 반환 (Gradio가 출력으로 재생 가능) return "output_videos/output_video.avi" demo = gr.Interface( fn=analyze_video, inputs=gr.Video(label="경기 영상 업로드"), outputs=gr.Video(label="분석된 영상 결과"), title="Football Analysis System", description="경기 영상을 분석해 볼 점유율과 AI 해설 자막을 생성합니다." ) if __name__ == "__main__": demo.launch(server_name="0.0.0.0", server_port=7860)