Andrei Shadrikov commited on
Commit
1de13f7
·
1 Parent(s): e3971db
Files changed (1) hide show
  1. app.py +32 -31
app.py CHANGED
@@ -75,40 +75,41 @@ def interact_with_pdf(doc, question):
75
  return sorted(outputs, key=lambda x: x["score"], reverse=True)[0]['answer']
76
 
77
 
78
- text_interface = gr.Interface(
79
- fn=extract_text,
80
- inputs=PDF(label="Upload PDF"),
81
- outputs=gr.Textbox(label="Extracted Text"),
82
- title="PDF extractor",
83
- description="Extracts text from the PDF container."
84
- )
 
85
 
86
- pdf_interface = gr.Interface(
87
- fn=process_pdf,
88
- inputs=[PDF(label="Upload PDF"), out_files],
89
- outputs=[gr.File(label="Download ZIP"), out_files],
90
- title="PDF to Image Converter",
91
- description="Converts PDF pages to images and outputs a ZIP file."
92
- )
93
 
94
- image_interface = gr.Interface(
95
- fn=interact_with_pdf,
96
- inputs=[
97
- PDF(label="Upload PDF"),
98
- gr.Textbox(label="Text Query")
99
- ],
100
- outputs=gr.Textbox(label="Possible Answer"),
101
- title="Ask Your PDF",
102
- description="Searches for text in the uploaded image based on the provided query."
103
- )
104
 
105
- # Create a tabbed interface
106
- tabbed_interface = gr.TabbedInterface(
107
- [text_interface, pdf_interface, image_interface],
108
- title="PDF interaction",
109
- tab_names=["Text extractor", "Converter", "Interaction"],
110
- # description="Choose a tab to perform the desired task."
111
- )
112
 
113
  # Launch the app
114
  tabbed_interface.launch()
 
75
  return sorted(outputs, key=lambda x: x["score"], reverse=True)[0]['answer']
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
 
114
  # Launch the app
115
  tabbed_interface.launch()