File size: 982 Bytes
58ac08a 87f3303 a4b5ea0 87f3303 58ac08a a4b5ea0 58ac08a |
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 29 30 31 32 |
import gradio as gr
import json
from src.pipeline import run_pipeline, search_highlights
from dotenv import load_dotenv
import shutil
load_dotenv()
def extract(video_file, game_card_str):
shutil.copy(video_file.name, "uploaded.mp4")
result = run_pipeline("uploaded.mp4", game_card_str)
return json.dumps(result, indent=2)
def search(query):
return "\n".join(search_highlights(query))
with gr.Blocks() as demo:
gr.Markdown("# Soccer Highlight Extractor")
with gr.Tab("Extract Highlights"):
video = gr.File(label="Upload Video")
game_card = gr.Textbox(label="Paste Game Card (JSON)", lines=10)
result = gr.Textbox(label="Pipeline Output")
gr.Button("Run Extraction").click(extract, [video, game_card], result)
with gr.Tab("Search Highlights"):
query = gr.Textbox(label="Search Query")
output = gr.Textbox(label="Search Results")
gr.Button("Search").click(search, query, output)
demo.launch()
|