QINGCHE commited on
Commit
02907a7
1 Parent(s): 6854433

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +50 -7
app.py CHANGED
@@ -1,10 +1,53 @@
 
1
  import gradio as gr
2
- import time
 
3
 
4
- def to_black(text):
5
- time.sleep(120)
6
- output = "hahah"
7
- return output
8
 
9
- interface = gr.Interface(fn=to_black, inputs="text", outputs="text")
10
- interface.queue().launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
  import gradio as gr
3
+ import textInput
4
+ from BERT_inference import BertClassificationModel
5
 
 
 
 
 
6
 
7
+
8
+
9
+
10
+
11
+ output = []
12
+ keys = []
13
+
14
+ # css = ".output {min-height: 500px}"
15
+
16
+
17
+ with gr.Blocks(css = ".output {min-height: 500px}") as demo:
18
+ #用markdown语法编辑输出一段话
19
+ gr.Markdown("# 文本分类系统")
20
+ gr.Markdown("请选择要输入的文件或填入文本")
21
+ topic_num = gr.Number(label="主题个数")
22
+ max_length = gr.Number(label="摘要最大长度")
23
+ with gr.Tabs():
24
+ with gr.Tab("文本输入"):
25
+ text_input = gr.TextArea(lines=10)
26
+ text_button = gr.Button("生成")
27
+
28
+ with gr.Tab("文件输入"):
29
+ gr.Markdown("目前支持的格式有PDF、Word、txt")
30
+ file_input = gr.File(file_types=["text", ".pdf", ".docx"])
31
+ file_button = gr.Button("生成")
32
+ # 设置tab选项卡
33
+ with gr.Tabs():
34
+ with gr.Tab("分类页"):
35
+ text_keys_output = gr.TextArea(lines=30)
36
+
37
+ with gr.Tab("摘要页",):
38
+ #Blocks特有组件,设置所有子组件按水平排列
39
+ text_ab_output = gr.TextArea(lines=30)
40
+
41
+ with gr.Tab("下载页"):
42
+ file_txt_output = gr.File(label="txt格式")
43
+ file_docx_output = gr.File(label="docx格式")
44
+ file_pdf_output = gr.File(label="pdf格式")
45
+ # with gr.Accordion("Open for More!"):
46
+ # gr.Markdown("Look at me...")
47
+ 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])
48
+ 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])
49
+
50
+ try:
51
+ demo.queue().launch()
52
+ except Exception as e:
53
+ print("error",e)