|
import numpy as np |
|
import gradio as gr |
|
import textInput |
|
from BERT_inference import BertClassificationModel |
|
|
|
|
|
output = [] |
|
keys = [] |
|
|
|
|
|
|
|
|
|
with gr.Blocks(css = ".output {min-height: 500px}") as demo: |
|
|
|
gr.Markdown("# TSA - 文本整理助手") |
|
gr.Markdown("请选择要输入的文件或填入文本") |
|
topic_num = gr.Number(label="主题个数") |
|
max_length = gr.Number(label="摘要最大长度") |
|
with gr.Tabs(): |
|
with gr.Tab("文本输入"): |
|
text_input = gr.TextArea(lines=10) |
|
text_button = gr.Button("生成") |
|
|
|
with gr.Tab("文件输入"): |
|
gr.Markdown("目前支持的格式有PDF、Word、txt") |
|
file_input = gr.File(file_types=["text", ".pdf", ".docx"]) |
|
file_button = gr.Button("生成") |
|
|
|
with gr.Tabs(): |
|
with gr.Tab("分类页"): |
|
text_keys_output = gr.TextArea(lines=30) |
|
|
|
with gr.Tab("摘要页",): |
|
|
|
text_ab_output = gr.TextArea(lines=30) |
|
|
|
with gr.Tab("下载页"): |
|
file_txt_output = gr.File(label="txt格式") |
|
file_docx_output = gr.File(label="docx格式") |
|
file_pdf_output = gr.File(label="pdf格式") |
|
|
|
text_button.click(textInput.text_dump_to_lines, inputs=[text_input,topic_num,max_length], outputs=[text_keys_output,text_ab_output,file_txt_output,file_docx_output,file_pdf_output]) |
|
file_button.click(textInput.file_dump_to_lines,inputs=[file_input,topic_num,max_length], outputs=[text_keys_output,text_ab_output,file_txt_output,file_docx_output,file_pdf_output]) |
|
|
|
|
|
demo.queue().launch() |