Andrei Shadrikov commited on
Commit
c3edca2
·
1 Parent(s): 23b7c2e
Files changed (1) hide show
  1. app.py +26 -16
app.py CHANGED
@@ -82,7 +82,7 @@ def interact_with_pdf(doc, question):
82
  outputs += p(img, question)
83
  return sorted(outputs, key=lambda x: x["score"], reverse=True)[0]['answer']
84
 
85
-
86
  text_interface = gr.Interface(
87
  fn=extract_text,
88
  inputs=PDF(label="Загрузить PDF"),
@@ -116,27 +116,37 @@ tabbed_interface = gr.TabbedInterface(
116
  title="Взаимодействие с PDF",
117
  tab_names=["В текст", "В картинки", "Задай вопрос"],
118
  # description="Choose a tab to perform the desired task.",
119
- css=custom_css
 
120
  )
121
  '''
122
 
123
  with gr.Blocks() as tabbed_interface:
124
  with gr.Tab("В текст"):
125
- inp1 = PDF(label="Загрузить PDF")
126
- out1 = gr.Textbox(label="Полученный текст")
127
- btn1 = gr.Button("Запустить")
128
- btn1.click(fn=extract_text, inputs=inp1, outputs=out1)
 
 
 
129
  with gr.Tab("В картинки"):
130
- inp2 = PDF(label="Загрузить PDF")
131
- out2 = gr.File(label="Скачать ZIP архив")
132
- btn2 = gr.Button("Запустить")
133
- btn2.click(fn=process_pdf, inputs=[inp2, out_files], outputs=[out2, out_files])
 
 
 
134
  with gr.Tab("Задай вопрос"):
135
- inp3 = PDF(label="Загрузить PDF")
136
- inp4 = gr.Textbox(label="Что хотите найти?")
137
- out3 = gr.Textbox(label="Возможный ответ")
138
- btn3 = gr.Button("Запустить")
139
- btn3.click(fn=interact_with_pdf, inputs=[inp3, inp4], outputs=out3)
140
- '''
 
 
 
141
 
142
  tabbed_interface.launch(show_api=False, max_threads=8)
 
82
  outputs += p(img, question)
83
  return sorted(outputs, key=lambda x: x["score"], reverse=True)[0]['answer']
84
 
85
+ '''
86
  text_interface = gr.Interface(
87
  fn=extract_text,
88
  inputs=PDF(label="Загрузить PDF"),
 
116
  title="Взаимодействие с PDF",
117
  tab_names=["В текст", "В картинки", "Задай вопрос"],
118
  # description="Choose a tab to perform the desired task.",
119
+ css=custom_css,
120
+ analytics_enabled=True
121
  )
122
  '''
123
 
124
  with gr.Blocks() as tabbed_interface:
125
  with gr.Tab("В текст"):
126
+ with gr.Row():
127
+ with gr.Column():
128
+ inp1 = PDF(label="Загрузить PDF")
129
+ btn_sbm1 = gr.Button("Запустить")
130
+ with gr.Column():
131
+ out1 = gr.Textbox(label="Полученный текст")
132
+ btn_sbm1.click(fn=extract_text, inputs=inp1, outputs=out1)
133
  with gr.Tab("В картинки"):
134
+ with gr.Row():
135
+ with gr.Column():
136
+ inp2 = PDF(label="Загрузить PDF")
137
+ btn_sbm2 = gr.Button("Запустить")
138
+ with gr.Column():
139
+ out2 = gr.File(label="Скачать ZIP архив")
140
+ btn_sbm2.click(fn=process_pdf, inputs=[inp2, out_files], outputs=[out2, out_files])
141
  with gr.Tab("Задай вопрос"):
142
+ with gr.Row():
143
+ with gr.Column():
144
+ inp3 = PDF(label="Загрузить PDF")
145
+ inp4 = gr.Textbox(label="Что хотите найти?")
146
+ btn_sbm3 = gr.Button("Запустить")
147
+ with gr.Column():
148
+ out3 = gr.Textbox(label="Возможный ответ")
149
+ btn_sbm3.click(fn=interact_with_pdf, inputs=[inp3, inp4], outputs=out3)
150
+
151
 
152
  tabbed_interface.launch(show_api=False, max_threads=8)