testing-hf-spaces / apps /multimodal_visual_qa.py
rexsimiloluwah
added more applications
bbfb60a
Raw
History Blame Contribute Delete
884 Bytes
# import gradio as gr
# from transformers import AutoProcessor
# from transformers import BlipForQuestionAnswering
# model = BlipForQuestionAnswering.from_pretrained("Salesforce/blip-vqa-base")
# processor = AutoProcessor.from_pretrained("Salesforce/blip-vqa-base")
# def process_image(image, question: str):
# inputs = processor(image, question, return_tensors="pt")
# output = model.generate(**inputs)
# answer = processor.decode(output[0], skip_special_tokens=True)
# return answer
# multimodal_visual_qa_interface = gr.Interface(
# fn=process_image,
# inputs=[
# gr.Image(label="Input Image", type="pil"),
# gr.Textbox(label="Enter question to prompt the image")
# ],
# outputs=gr.Textbox(label="Answer"),
# title="Multimodal Visual QA Application",
# description="This app can help you ask questions about an image"
# )