Spaces:
Runtime error
Runtime error
Henry Qu
commited on
Commit
·
d48ad83
1
Parent(s):
117d8c9
modified: app.py
Browse files
app.py
CHANGED
|
@@ -8,12 +8,11 @@ config_class, model_class, tokenizer_class = GPT2Config, GPT2LMHeadModel, GPT2To
|
|
| 8 |
model = model_class.from_pretrained('gpt2')
|
| 9 |
tokenizer = GPT2Tokenizer.from_pretrained("gpt2")
|
| 10 |
|
|
|
|
| 11 |
def search_index(query):
|
| 12 |
-
# 示例返回,实际中应根据查询来搜索索引
|
| 13 |
return "example_uuid"
|
| 14 |
|
| 15 |
|
| 16 |
-
# 下载视频并返回路径的函数
|
| 17 |
def download_video(uuid):
|
| 18 |
dataset_name = "quchenyuan/360x_dataset"
|
| 19 |
dataset_path = "360_dataset/binocular/"
|
|
@@ -23,7 +22,7 @@ def download_video(uuid):
|
|
| 23 |
storage_dir = Path("videos")
|
| 24 |
storage_dir.mkdir(exist_ok=True)
|
| 25 |
|
| 26 |
-
storage_limit = 40*1024 * 1024 * 1024
|
| 27 |
current_storage = sum(f.stat().st_size for f in storage_dir.glob('*') if f.is_file())
|
| 28 |
if current_storage + os.path.getsize(video_filename) > storage_limit:
|
| 29 |
oldest_file = min(storage_dir.glob('*'), key=os.path.getmtime)
|
|
@@ -41,23 +40,22 @@ def search_and_show_video(query):
|
|
| 41 |
return video_path
|
| 42 |
|
| 43 |
|
| 44 |
-
|
| 45 |
if __name__ == "__main__":
|
| 46 |
with gr.Blocks() as demo:
|
| 47 |
with gr.Column():
|
| 48 |
with gr.Row():
|
| 49 |
-
search_input = gr.Textbox(label="
|
| 50 |
with gr.Row():
|
| 51 |
with gr.Column():
|
| 52 |
-
video_output_1 = gr.Video(
|
| 53 |
with gr.Column():
|
| 54 |
-
video_output_2 = gr.Video(
|
| 55 |
with gr.Column():
|
| 56 |
-
video_output_3 = gr.Video(
|
| 57 |
with gr.Row():
|
| 58 |
-
submit_button = gr.Button(
|
| 59 |
|
| 60 |
-
submit_button.click(search_and_show_video, search_input,
|
|
|
|
| 61 |
|
| 62 |
-
# 运行 Gradio 应用
|
| 63 |
demo.launch()
|
|
|
|
| 8 |
model = model_class.from_pretrained('gpt2')
|
| 9 |
tokenizer = GPT2Tokenizer.from_pretrained("gpt2")
|
| 10 |
|
| 11 |
+
|
| 12 |
def search_index(query):
|
|
|
|
| 13 |
return "example_uuid"
|
| 14 |
|
| 15 |
|
|
|
|
| 16 |
def download_video(uuid):
|
| 17 |
dataset_name = "quchenyuan/360x_dataset"
|
| 18 |
dataset_path = "360_dataset/binocular/"
|
|
|
|
| 22 |
storage_dir = Path("videos")
|
| 23 |
storage_dir.mkdir(exist_ok=True)
|
| 24 |
|
| 25 |
+
storage_limit = 40 * 1024 * 1024 * 1024
|
| 26 |
current_storage = sum(f.stat().st_size for f in storage_dir.glob('*') if f.is_file())
|
| 27 |
if current_storage + os.path.getsize(video_filename) > storage_limit:
|
| 28 |
oldest_file = min(storage_dir.glob('*'), key=os.path.getmtime)
|
|
|
|
| 40 |
return video_path
|
| 41 |
|
| 42 |
|
|
|
|
| 43 |
if __name__ == "__main__":
|
| 44 |
with gr.Blocks() as demo:
|
| 45 |
with gr.Column():
|
| 46 |
with gr.Row():
|
| 47 |
+
search_input = gr.Textbox(label="Query", placeholder="Enter a query to search for a video.")
|
| 48 |
with gr.Row():
|
| 49 |
with gr.Column():
|
| 50 |
+
video_output_1 = gr.Video()
|
| 51 |
with gr.Column():
|
| 52 |
+
video_output_2 = gr.Video()
|
| 53 |
with gr.Column():
|
| 54 |
+
video_output_3 = gr.Video()
|
| 55 |
with gr.Row():
|
| 56 |
+
submit_button = gr.Button(value="搜索")
|
| 57 |
|
| 58 |
+
submit_button.click(search_and_show_video, search_input,
|
| 59 |
+
outputs=[video_output_1, video_output_2, video_output_3])
|
| 60 |
|
|
|
|
| 61 |
demo.launch()
|