Andrei Shadrikov commited on
Commit
79a48cc
·
1 Parent(s): 1de13f7
Files changed (1) hide show
  1. app.py +19 -19
app.py CHANGED
@@ -76,38 +76,38 @@ def interact_with_pdf(doc, question):
76
 
77
 
78
  with gr.Blocks(theme=gr.themes.Default(primary_hue=gr.themes.colors.red, secondary_hue=gr.themes.colors.pink)) as demo:
79
- text_interface = gr.Interface(
80
  fn=extract_text,
81
- inputs=PDF(label="Upload PDF"),
82
- outputs=gr.Textbox(label="Extracted Text"),
83
- title="PDF extractor",
84
- description="Extracts text from the PDF container."
85
  )
86
 
87
- pdf_interface = gr.Interface(
88
  fn=process_pdf,
89
- inputs=[PDF(label="Upload PDF"), out_files],
90
- outputs=[gr.File(label="Download ZIP"), out_files],
91
- title="PDF to Image Converter",
92
- description="Converts PDF pages to images and outputs a ZIP file."
93
  )
94
 
95
- image_interface = gr.Interface(
96
  fn=interact_with_pdf,
97
  inputs=[
98
- PDF(label="Upload PDF"),
99
- gr.Textbox(label="Text Query")
100
  ],
101
- outputs=gr.Textbox(label="Possible Answer"),
102
- title="Ask Your PDF",
103
- description="Searches for text in the uploaded image based on the provided query."
104
  )
105
 
106
  # Create a tabbed interface
107
- tabbed_interface = gr.TabbedInterface(
108
  [text_interface, pdf_interface, image_interface],
109
- title="PDF interaction",
110
- tab_names=["Text extractor", "Converter", "Interaction"],
111
  # description="Choose a tab to perform the desired task."
112
  )
113
 
 
76
 
77
 
78
  with gr.Blocks(theme=gr.themes.Default(primary_hue=gr.themes.colors.red, secondary_hue=gr.themes.colors.pink)) as demo:
79
+ text_interface = demo.Interface(
80
  fn=extract_text,
81
+ inputs=PDF(label="Загрузить PDF"),
82
+ outputs=demo.Textbox(label="Полученный текст"),
83
+ title="PDF в текст",
84
+ description="Сервис вынимает содержащийся в PDF контейнере текст."
85
  )
86
 
87
+ pdf_interface = demo.Interface(
88
  fn=process_pdf,
89
+ inputs=[PDF(label="Загрузить PDF"), out_files],
90
+ outputs=[demo.File(label="Скачать ZIP архив"), out_files],
91
+ title="PDF в картинки",
92
+ description="Переводит постранично файл в изображения, и предлагает бскачать в виде ZIP архива."
93
  )
94
 
95
+ image_interface = demo.Interface(
96
  fn=interact_with_pdf,
97
  inputs=[
98
+ PDF(label="Загрузить PDF"),
99
+ demo.Textbox(label="Что хотите найти?")
100
  ],
101
+ outputs=demo.Textbox(label="Возможный ответ"),
102
+ title="Спроси PDF",
103
+ description="Сервис через методы OCR сканирует загруженный файл для нахождения ответа на заданный вопрос."
104
  )
105
 
106
  # Create a tabbed interface
107
+ tabbed_interface = demo.TabbedInterface(
108
  [text_interface, pdf_interface, image_interface],
109
+ title="Взаимодействие с PDF",
110
+ tab_names=["В текст", "В картинки", "Задай вопрос"],
111
  # description="Choose a tab to perform the desired task."
112
  )
113