Andrei Shadrikov
commited on
Commit
·
1de13f7
1
Parent(s):
e3971db
themes
Browse files
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 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
|
|
85 |
|
86 |
-
pdf_interface = gr.Interface(
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
)
|
93 |
|
94 |
-
image_interface = gr.Interface(
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
)
|
104 |
|
105 |
-
# Create a tabbed interface
|
106 |
-
tabbed_interface = gr.TabbedInterface(
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
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()
|