Spaces:
Running
Running
File size: 1,474 Bytes
73d7797 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
import gradio as gr
from tasks.image_caption import image_captioning
from tasks.image_retrieval import image_retrieval
from tasks.visual_qa import visual_qa
caption_interface = gr.Interface(
fn=image_captioning,
inputs=gr.Image(type="pil", label="Upload Image"),
outputs=gr.Textbox(label="Generated Caption"),
title="Image Captioning",
description="Generate a caption for the uploaded image.",
allow_flagging="never"
)
retrieval_interface = gr.Interface(
fn=image_retrieval,
inputs=[
gr.Textbox(label="Image URL"),
gr.Textbox(label="Description Text")
],
outputs=[
gr.Image(label="Retrieved Image"),
gr.Textbox(label="Matching Probability")
],
title="Image Retrieval",
description="Check if the image and text match semantically.",
allow_flagging="never"
)
vqa_interface = gr.Interface(
fn=visual_qa,
inputs=[
gr.Image(type="pil", label="Upload Image"),
gr.Textbox(label="Question")
],
outputs=gr.Textbox(label="Answer"),
title="Visual Question Answering",
description="Answer questions about the uploaded image.",
allow_flagging="never"
)
# Combine vision-langauge tasks into a tabbed interface
app = gr.TabbedInterface(
interface_list=[caption_interface, retrieval_interface, vqa_interface],
tab_names=["Image Captioning", "Image Retrieval", "Visual Q&A"]
)
app.launch()
|