65 lines
2.5 KiB
Python
65 lines
2.5 KiB
Python
|
import os
|
||
|
|
||
|
import gradio as gr
|
||
|
from gradio_pdf import PDF
|
||
|
|
||
|
current_pdf_file = None
|
||
|
|
||
|
with gr.Blocks() as demo:
|
||
|
with gr.Row():
|
||
|
with gr.Column(scale=1):
|
||
|
with gr.Row():
|
||
|
# gr.Label("会议名称")
|
||
|
conf_name = gr.Dropdown(choices=["ECCV2022", "ECCV2020", "CVPR2024"], value="ECCV2022", label="会议名称", show_label=True)
|
||
|
conf_button = gr.Button("查看会议论文", variant='primary')
|
||
|
dataframe = gr.Dataframe(headers=["论文名称"], col_count=(1, "fixed"), type='array', height=800)
|
||
|
with gr.Row():
|
||
|
look_input = gr.Textbox(placeholder="关键词检索", label="关键词过滤")
|
||
|
filter_button = gr.Button("过滤")
|
||
|
# up_button = gr.Button("加载")
|
||
|
|
||
|
with gr.Column(scale=2):
|
||
|
pdf = PDF(label="Upload a PDF", interactive=True, height=1000)
|
||
|
|
||
|
|
||
|
# name = gr.Textbox(show_label=False)
|
||
|
# pdf.upload(lambda f: f, pdf, name)
|
||
|
|
||
|
def up_load():
|
||
|
global current_pdf_file
|
||
|
n = r"D:\py\keyan_qingbao\te_u\paper_down_load\ECCV_2022\main_paper\3d-siamese-transformer-network-for-single-object-tracking-on-point-clouds_ECCV_2022.pdf"
|
||
|
current_pdf_file = n
|
||
|
return n
|
||
|
|
||
|
|
||
|
def load_conf_list(conf_name):
|
||
|
if conf_name == "ECCV2022":
|
||
|
root_dir = r"D:\py\keyan_qingbao\te_u\paper_down_load\ECCV_2022\main_paper"
|
||
|
return [[i] for i in os.listdir(root_dir)]
|
||
|
|
||
|
|
||
|
def look_dataframe(evt: gr.SelectData):
|
||
|
global current_pdf_file
|
||
|
if evt.value:
|
||
|
root_dir = r"D:\py\keyan_qingbao\te_u\paper_down_load\ECCV_2022\main_paper"
|
||
|
n = os.path.join(root_dir, evt.value)
|
||
|
if os.path.exists(n):
|
||
|
current_pdf_file = n
|
||
|
return PDF(value=current_pdf_file, label="Upload a PDF", interactive=True, height=1000)
|
||
|
|
||
|
|
||
|
def filter_by_word(words, paper_list):
|
||
|
word_list = words.strip().split()
|
||
|
paper_list_filter = [p[0] for p in paper_list]
|
||
|
for word in word_list:
|
||
|
paper_list_filter = [p for p in paper_list_filter if word in p]
|
||
|
return [[p] for p in paper_list_filter]
|
||
|
|
||
|
|
||
|
filter_button.click(filter_by_word, inputs=[look_input, dataframe], outputs=[dataframe])
|
||
|
dataframe.select(look_dataframe, inputs=None, outputs=[pdf])
|
||
|
conf_button.click(load_conf_list, inputs=[conf_name], outputs=[dataframe])
|
||
|
# up_button.click(up_load, inputs=None, outputs=[pdf])
|
||
|
|
||
|
demo.launch()
|