File size: 2,689 Bytes
1231097 599e2ee ee393d2 599e2ee 1231097 599e2ee 1231097 599e2ee 1231097 599e2ee ee393d2 1231097 599e2ee ee393d2 1231097 599e2ee 1231097 599e2ee ee393d2 1231097 599e2ee 1231097 599e2ee 1231097 ae3bbdf 33a834e |
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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
import os
import random
import gradio as gr
import datasets as ds
bench = ds.load_dataset(
"saiyan-world/Goku-MovieGenBench",
split="train"
)
bench = bench.cast_column("video", ds.Video(decode=False))
num_videos = len(bench)
prompts = ds.load_dataset(
"meta-ai-for-media-research/movie_gen_video_bench",
split="test",
streaming=True
)
prompts = [p["prompt"] for p in prompts][:num_videos]
with gr.Blocks() as demo:
header = gr.Markdown(
"""
# Goku MovieGen Video Bench Video Explorer
Use this interface to view videos generated by [Goku](https://saiyan-world.github.io/goku/) using the promps from [Meta AI's MovieGen Video Bench](https://huggingface.co/datasets/meta-ai-for-media-research/movie_gen_video_bench). For more information, see [Goku: Flow Based Video Generate Models on arXiv](https://arxiv.org/abs/2502.04896). """.strip()
)
video = gr.Video(
value=bench[0]["video"]["path"],
loop=True,
autoplay=True,
)
dropdown = gr.Dropdown(
label="Video",
choices=prompts,
value=prompts[0]
)
def set_video(new_prompt):
new_id = prompts.index(new_prompt)
return gr.Video(
value=bench[new_id]["video"]["path"],
loop=True,
autoplay=True,
)
def decrement(current_prompt):
current_id = prompts.index(current_prompt)
return gr.Dropdown(
label="Video",
choices=prompts,
value=prompts[max(0, current_id-1)]
)
def increment(current_prompt):
current_id = prompts.index(current_prompt)
return gr.Dropdown(
label="Video",
choices=prompts,
value=prompts[min(num_videos-1, current_id+1)]
)
def random_video():
return gr.Dropdown(
label="Video",
choices=prompts,
value=prompts[random.randint(0, num_videos-1)]
)
with gr.Row():
go_previous = gr.Button("Previous")
go_previous.click(
fn=decrement,
inputs=dropdown,
outputs=dropdown,
)
go_next = gr.Button("Next")
go_next.click(
fn=increment,
inputs=dropdown,
outputs=dropdown
)
go_random = gr.Button("Random")
go_random.click(
fn=random_video,
outputs=dropdown,
)
dropdown.change(fn=set_video, inputs=dropdown, outputs=video)
paths = [
os.path.dirname(bench[0]["video"]["path"]),
os.path.expanduser("~/.cache/huggingface")
]
demo.launch(allowed_paths=paths) |