Views
No views yet
[!NOTE] This is the full merged model (base model + LoRA adapter) for easy deployment and inference. The original LoRA adapter is available here.
Thinking Process:
The frame shows the phacoemulsification phase with the ultrasonic tip positioned within the lens nucleus. The corneal incision margins appear well-maintained. Safety margins around the posterior capsule are adequate but require continuous monitoring.
Final Answer:
Maintain steady foot pedal pressure and keep the phaco tip centered within the nuclear material to avoid inadvertent contact with the posterior capsule.| Parameter | Value |
|---|---|
| Base Model | google/medgemma-1.5-4b-it |
| Fine-tuning Method | LoRA |
| LoRA Rank (r) | 16 |
| LoRA Alpha | 16 |
| LoRA Dropout | 0.05 |
| Target Modules | all-linear |
| Quantization | 4bit-nf4-double_quant |
| Image Resolution | 896 x 896 |
| Optimizer | AdamW (fused) |
| Learning Rate | 2e-4 |
| Scheduler | Linear |
| Warmup Ratio | 0.03 |
| Max Gradient Norm | 0.3 |
| Epochs | 3 (with early stopping) |
| Effective Batch Size | 24 |
| Precision | bfloat16 |
| Cross-Validation | 5-fold GroupKFold (grouped by surgery case) |



1from transformers import AutoProcessor, AutoModelForImageTextToText
2from PIL import Image
3import torch
4
5# Load the merged model and processor
6model_path = "mehti/medgemma-cataract-surgical-analysis"
7processor = AutoProcessor.from_pretrained(model_path)
8model = AutoModelForImageTextToText.from_pretrained(
9 model_path,
10 torch_dtype=torch.bfloat16,
11 device_map="auto",
12)
13model.eval()
14
15# Load a surgical frame (replace with your image)
16image = Image.open("surgical_frame.jpg").convert("RGB")
17
18messages = [
19 {
20 "role": "user",
21 "content": [
22 {"type": "image", "image": image},
23 {
24 "type": "text",
25 "text": (
26 "You are an expert ophthalmic surgeon reviewing a frame from a cataract surgery video. "
27 "Analyze the surgical scene and provide a chain-of-thought reasoning followed by a "
28 "clear instruction for a surgical resident.\n\n"
29 "Format your response as:\nThinking Process:\n<your reasoning>\n\nFinal Answer:\n<your instruction>"
30 ),
31 },
32 ],
33 }
34]
35
36inputs = processor.apply_chat_template(
37 messages,
38 add_generation_prompt=True,
39 tokenize=True,
40 return_dict=True,
41 return_tensors="pt",
42).to(model.device, dtype=torch.bfloat16)
43
44with torch.inference_mode():
45 output = model.generate(**inputs, max_new_tokens=512, do_sample=False)
46
47decoded = processor.decode(output[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True)
48print(decoded)1vllm serve mehti/medgemma-cataract-surgical-analysis \
2 --host 0.0.0.0 \
3 --port 8000 \
4 --dtype bfloat16 \
5 --max-model-len 4096 \
6 --gpu-memory-utilization 0.901@article{medgemma2025,
2 title={MedGemma Technical Report},
3 author={Sellergren, Andrew and Kazemzadeh, Sahar and Jaroensri, Tiam and Kiraly, Atilla and Traverse, Madeleine and Kohlberger, Timo and Xu, Shawn and Jamil, Fayaz and Hughes, C{\'\i}an and Lau, Charles and Chen, Justin and Mahvar, Fereshteh and Yatziv, Liron and Chen, Tiffany and Sterling, Bram and others},
4 journal={arXiv preprint arXiv:2507.05201},
5 year={2025}
6}1@misc{qin2025lmodlargemultimodalophthalmology,
2 title={LMOD: A Large Multimodal Ophthalmology Dataset and Benchmark for Large Vision-Language Models},
3 author={Zhenyue Qin and Yu Yin and Dylan Campbell and Xuansheng Wu and Ke Zou and Yih-Chung Tham and Ninghao Liu and Xiuzhen Zhang and Qingyu Chen},
4 year={2025},
5 eprint={2410.01620},
6 archivePrefix={arXiv},
7 primaryClass={cs.CV},
8 url={https://arxiv.org/abs/2410.01620},
9}@misc{qwen3technicalreport,
title={Qwen3 Technical Report},
author={Qwen Team},
year={2025},
eprint={2505.09388},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2505.09388},
}@article{Qwen2.5-VL,
title={Qwen2.5-VL Technical Report},
author={Bai, Shuai and Chen, Keqin and Liu, Xuejing and Wang, Jialin and Ge, Wenbin and Song, Sibo and Dang, Kai and Wang, Peng and Wang, Shijie and Tang, Jun and Zhong, Humen and Zhu, Yuanzhi and Yang, Mingkun and Li, Zhaohai and Wan, Jianqiang and Wang, Pengfei and Ding, Wei and Fu, Zheren and Xu, Yiheng and Ye, Jiabo and Zhang, Xi and Xie, Tianbao and Cheng, Zesen and Zhang, Hang and Yang, Zhibo and Xu, Haiyang and Lin, Junyang},
journal={arXiv preprint arXiv:2502.13923},
year={2025}
}@article{Qwen2VL,
title={Qwen2-VL: Enhancing Vision-Language Model's Perception of the World at Any Resolution},
author={Wang, Peng and Bai, Shuai and Tan, Sinan and Wang, Shijie and Fan, Zhihao and Bai, Jinze and Chen, Keqin and Liu, Xuejing and Wang, Jialin and Ge, Wenbin and Fan, Yang and Dang, Kai and Du, Mengfei and Ren, Xuancheng and Men, Rui and Liu, Dayiheng and Zhou, Chang and Zhou, Jingren and Lin, Junyang},
journal={arXiv preprint arXiv:2409.12191},
year={2024}
}@article{Qwen-VL,
title={Qwen-VL: A Versatile Vision-Language Model for Understanding, Localization, Text Reading, and Beyond},
author={Bai, Jinze and Bai, Shuai and Yang, Shusheng and Wang, Shijie and Tan, Sinan and Wang, Peng and Lin, Junyang and Zhou, Chang and Zhou, Jingren},
journal={arXiv preprint arXiv:2308.12966},
year={2023}
}