Visual Question Answering inference on echocardiogram images using MedGemma and LLaVA-Med models.
# Create and activate the environment
conda create -n echoqa python=3.10 -y
conda activate echoqa
# Install PyTorch with CUDA support (for T4 GPU)
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu118
# Install core dependencies
pip install transformers>=4.50.0 accelerate pydicom pillow numpy pandas tqdm huggingface_hub bitsandbytes sentencepiece einops
# Install LLaVA-Med (required for LLaVA-Med model)
pip install git+https://github.com/microsoft/LLaVA-Med.git
MedGemma requires accepting the license on Hugging Face:
huggingface-cli login
python main.py --model medgemma
python main.py --model llava-med
python main.py --model both
python main.py --model medgemma --num-samples 10
Both models are optimized for NVIDIA T4 (16GB VRAM):
/home/lavondali/MIMICEchoQAInfer/Data/mimic-iv-ext-echoqa/1.0.0/MIMICEchoQA/MIMICEchoQA.json/home/lavondali/mount-folder/MIMIC-Echo-IV/ (GCP bucket mount)./outputs/ directoryThe script automatically:
Results are saved as JSON files in the outputs/ directory:
medgemma_results.jsonllava-med_results.jsonEach result contains:
messages_id: Sample identifierquestion: The question askedprediction: Model's answerground_truth: Correct answercorrect_option: Correct option letter (A/B/C/D)structure: Cardiac structure being queriedview: Echocardiographic view13 commits
HTML
92.6%
Python
7.4%
Visual Question Answering inference on echocardiogram images using MedGemma and LLaVA-Med models.
# Create and activate the environment
conda create -n echoqa python=3.10 -y
conda activate echoqa
# Install PyTorch with CUDA support (for T4 GPU)
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu118
# Install core dependencies
pip install transformers>=4.50.0 accelerate pydicom pillow numpy pandas tqdm huggingface_hub bitsandbytes sentencepiece einops
# Install LLaVA-Med (required for LLaVA-Med model)
pip install git+https://github.com/microsoft/LLaVA-Med.git
MedGemma requires accepting the license on Hugging Face:
huggingface-cli login
python main.py --model medgemma
python main.py --model llava-med
python main.py --model both
python main.py --model medgemma --num-samples 10
Both models are optimized for NVIDIA T4 (16GB VRAM):
/home/lavondali/MIMICEchoQAInfer/Data/mimic-iv-ext-echoqa/1.0.0/MIMICEchoQA/MIMICEchoQA.json/home/lavondali/mount-folder/MIMIC-Echo-IV/ (GCP bucket mount)./outputs/ directoryThe script automatically:
Results are saved as JSON files in the outputs/ directory:
medgemma_results.jsonllava-med_results.jsonEach result contains:
messages_id: Sample identifierquestion: The question askedprediction: Model's answerground_truth: Correct answercorrect_option: Correct option letter (A/B/C/D)structure: Cardiac structure being queriedview: Echocardiographic view13 commits
HTML
92.6%
Python
7.4%