File size: 2,216 Bytes
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
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)

with gr.Blocks() as demo:
    header = gr.Markdown(
        """
        # Goku MovieGen Bench Video Explorer
        Use this interface to view videos generated by [Goku](https://saiyan-world.github.io/goku/). 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=range(num_videos),
        value=0
    )

    def set_video(new_id):
        return gr.Video(
            value=bench[new_id]["video"]["path"],
            loop=True,
            autoplay=True,
        )

    def decrement(current_id):
        return gr.Dropdown(
            label="Video",
            choices=range(num_videos),
            value=max(0, current_id-1)
        )

    def increment(current_id):
        return gr.Dropdown(
            label="Video",
            choices=range(num_videos),
            value=min(num_videos-1, current_id+1)
        )

    def random_video():
        return gr.Dropdown(
            label="Video",
            choices=range(num_videos),
            value=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)