Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from datasets import load_dataset
|
3 |
+
|
4 |
+
# 加载数据集
|
5 |
+
ds = load_dataset("OpenVideo/sample-200")
|
6 |
+
|
7 |
+
def show_sample(index):
|
8 |
+
# 从数据集中获取样本
|
9 |
+
sample = ds['train'][index]
|
10 |
+
# 假设样本包含视频的URL和描述
|
11 |
+
video_url = sample.get('video_url', 'No URL available')
|
12 |
+
description = sample.get('description', 'No description available')
|
13 |
+
return video_url, description
|
14 |
+
|
15 |
+
# 使用Gradio创建界面
|
16 |
+
iface = gr.Interface(
|
17 |
+
fn=show_sample,
|
18 |
+
inputs=gr.inputs.Slider(0, len(ds['train']) - 1, step=1, default=0, label="Sample Index"),
|
19 |
+
outputs=[gr.outputs.Textbox(label="Video URL"), gr.outputs.Textbox(label="Description")]
|
20 |
+
)
|
21 |
+
|
22 |
+
# 运行界面
|
23 |
+
iface.launch()
|