File size: 908 Bytes
1dfa4f0
 
 
7fc7ae9
 
1dfa4f0
 
0c8b641
1dfa4f0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
import random
from datasets import load_dataset
import os
hf_token = os.environ['hf_token']

# 加载数据集
dataset = load_dataset("Vchitect/VBench_sampled_video")
# 随机选择一个视频
def get_random_video():
    # 随机选择一个索引
    random_index = random.randint(0, len(dataset['train']) - 1)
    # 获取视频路径
    video_path = dataset['train'][random_index]['video_path']
    return video_path

# Gradio 接口
def display_video():
    video_path = get_random_video()
    return video_path

interface = gr.Interface(fn=display_video, 
                         outputs=gr.Video(label="随机视频展示"),
                         inputs=[], 
                         title="随机视频展示",
                         description="从 Vchitect/VBench_sampled_video 数据集中随机展示一个视频。")

if __name__ == "__main__":
    interface.launch()