Spaces:
Sleeping
Sleeping
import gradio as gr | |
from transformers import BlipProcessor, BlipForConditionalGeneration | |
from PIL import Image | |
# Load your model | |
processor = BlipProcessor.from_pretrained("mshsahmed/blip-vqa-finetuned-kvasir-v58849") | |
model = BlipForConditionalGeneration.from_pretrained("mshsahmed/blip-vqa-finetuned-kvasir-v58849") | |
def vqa_pipeline(image, question): | |
inputs = processor(image, question, return_tensors="pt") | |
out = model.generate(**inputs) | |
answer = processor.decode(out[0], skip_special_tokens=True) | |
return answer | |
iface = gr.Interface( | |
fn=vqa_pipeline, | |
inputs=[gr.Image(type="pil"), gr.Textbox(lines=1, placeholder="Ask a question...")], | |
outputs="text", | |
title="Medical VQA Demo", | |
description="Upload an image and ask a question. The model will answer based on the image content." | |
) | |
iface.launch() | |