Downloads · 30 days
9
25% of all-time downloads
Shoriful025/vqa-multimodal-medical-report
vqa-multimodal-medical-report is a machine learning model from Shoriful025. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
The vqa-multimodal-medical-report model is a Vision-Question Answering (VQA) system built on the ViLT (Vision-and-Language Transformer) architecture. It is specialized in the medical domain, specifically designed to a…
Downloads · 30 days
9
25% of all-time downloads
All-time downloads
36
Public
Repo size
—
Likes
1
Public
Click a slice to open those files.
.md3.3 KB · 51%
From the Hugging Face model README
The vqa-multimodal-medical-report model is a Vision-Question Answering (VQA) system built on the ViLT (Vision-and-Language Transformer) architecture. It is specialized in the medical domain, specifically designed to answer complex clinical questions based on a provided medical image (e.g., X-ray) and a text question. It performs joint reasoning over visual and textual inputs.
ViltForQuestionAnswering).To get an answer based on an X-ray and a question:
from transformers import ViltProcessor, ViltForQuestionAnswering
from PIL import Image
import torch
# Load model and processor
model_name = "YourOrg/vqa-multimodal-medical-report"
processor = ViltProcessor.from_pretrained(model_name)
model = ViltForQuestionAnswering.from_pretrained(model_name)
# Define inputs (Conceptual image loading)
# image = Image.open("path/to/xray_scan.jpg").convert("RGB")
# Dummy image for demonstration
dummy_image = Image.new('RGB', (384, 384), color = 'white')
question = "What is the location of the acute finding?"
# Process the inputs
encoding = processor(dummy_image, question, return_tensors="pt")
# Inference
with torch.no_grad():
outputs = model(**encoding)
logits = outputs.logits
# Find the predicted answer
idx = logits.argmax(-1).item()
predicted_answer = model.config.id2label[idx]
print(f"Question: {question}")
print(f"Predicted Answer: **{predicted_answer}**")