dafajudin
connect to model
5e5ca2a
raw
history blame
767 Bytes
import gradio as gr
from transformers import pipeline
generator = pipeline("visual-question-answering", model="jihadzakki/blip1-medvqa")
def format_answer(image, question):
result = generator(image, question)
print(result) # Print the result to see its structure
predicted_answer = result[0].get('answer', 'No answer found') # Adjust this key if necessary
return f"Predicted Answer: {predicted_answer}"
VisualQAApp = gr.Interface(
fn=format_answer,
inputs=[
gr.Image(label="Upload image", type="pil"),
gr.Textbox(label="Question"),
],
outputs=[gr.Textbox(label="Answer")],
title="Visual Question Answering using BLIP Model",
description="VQA",
allow_flagging="never"
)
VisualQAApp.launch(share=True)