Spaces:
Running
Running
Create main.py
Browse files
main.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from app import answer_question_from_doc # Assuming `answer_question_from_doc` is in app.py
|
| 3 |
+
from appImage import answer_question_from_image # Assuming `answer_question_from_image` is in appImage.py
|
| 4 |
+
|
| 5 |
+
# Create tabs for Document QA and Image QA
|
| 6 |
+
with gr.Blocks() as demo:
|
| 7 |
+
with gr.Tab("Document QA"):
|
| 8 |
+
gr.Markdown("### Document Question Answering")
|
| 9 |
+
file_input = gr.File(label="Upload PDF")
|
| 10 |
+
question_input = gr.Textbox(label="Ask a Question")
|
| 11 |
+
file_output = gr.Textbox(label="Answer")
|
| 12 |
+
file_input.change(answer_question_from_doc, [file_input, question_input], file_output)
|
| 13 |
+
|
| 14 |
+
with gr.Tab("Image QA"):
|
| 15 |
+
gr.Markdown("### Image Question Answering")
|
| 16 |
+
img_input = gr.Image(label="Upload Image")
|
| 17 |
+
img_question_input = gr.Textbox(label="Ask a Question")
|
| 18 |
+
img_output = gr.Textbox(label="Answer")
|
| 19 |
+
img_input.change(answer_question_from_image, [img_input, img_question_input], img_output)
|
| 20 |
+
|
| 21 |
+
demo.launch()
|