Spaces:
Running
Running
import gradio as gr | |
from app import answer_question_from_doc # Assuming `answer_question_from_doc` is in app.py | |
from appImage import answer_question_from_image # Assuming `answer_question_from_image` is in appImage.py | |
# Create tabs for Document QA and Image QA | |
with gr.Blocks() as demo: | |
with gr.Tab("Document QA"): | |
gr.Markdown("### Document Question Answering") | |
file_input = gr.File(label="Upload PDF") | |
question_input = gr.Textbox(label="Ask a Question") | |
file_output = gr.Textbox(label="Answer") | |
file_input.change(answer_question_from_doc, [file_input, question_input], file_output) | |
with gr.Tab("Image QA"): | |
gr.Markdown("### Image Question Answering") | |
img_input = gr.Image(label="Upload Image") | |
img_question_input = gr.Textbox(label="Ask a Question") | |
img_output = gr.Textbox(label="Answer") | |
img_input.change(answer_question_from_image, [img_input, img_question_input], img_output) | |
app = gr.mount_gradio_app(app, demo, path="/") | |
# Root redirect to Gradio app | |
def home(): | |
return RedirectResponse(url="/") |