𧬠CLOVER: Cost-Effective Instruction Learning for Pathology Vision and Language Analysis
CLOVER-Qwen2.5-VL is an upgraded version of CLOVER, built upon Qwen2.5-VL, a powerful multimodal large language model for conversational pathology analysis. It efficiently adapts vision-language models (VLMs) to clinical domains with minimal computational cost while maintaining strong reasoning and question-answering capabilities.
π§Ύ This work is published in Nature Computational Science.
π Quick Start
Installation
# Create environment
conda create -n clover python=3.10
conda activate clover
pip install torch==2.4.0 torchvision==0.19.0 --extra-index-url https://download.pytorch.org/whl/cu118
pip install transformers==4.52.4 accelerate qwen-vl-utils
Run
from transformers import Qwen2_5_VLForConditionalGeneration, AutoTokenizer, AutoProcessor
from qwen_vl_utils import process_vision_info
import torch
# default: Load the model and processer on the available device(s)
model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
"jline/CLOVER-Qwen2.5-VL", torch_dtype=torch.bfloat16, device_map="auto"
)
processor = AutoProcessor.from_pretrained("jline/CLOVER-Qwen2.5-VL")
messages = [
{
"role": "user",
"content": [
{
"type": "image",
"image": "./image_path.png",
},
{"type": "text", "text": "Describe this image."},
],
}
]
# Preparation for inference
text = processor.apply_chat_template(
messages, tokenize=False, add_generation_prompt=True
)
image_inputs, video_inputs = process_vision_info(messages)
inputs = processor(
text=[text],
images=image_inputs,
videos=video_inputs,
padding=True,
return_tensors="pt",
)
inputs = inputs.to("cuda")
# Inference: Generation of the output
generated_ids = model.generate(**inputs, max_new_tokens=128)
generated_ids_trimmed = [
out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
]
output_text = processor.batch_decode(
generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
)
print(output_text)
π Citation
If you find CLOVER useful for your research, please cite:
@article{chen2025cost,
title={Cost-effective instruction learning for pathology vision and language analysis},
author={Chen, K. and Liu, M. and Yan, F. and others},
journal={Nature Computational Science},
year={2025},
doi={10.1038/s43588-025-00818-5}
}
- Downloads last month
- 19
Inference Providers
NEW
This model isn't deployed by any Inference Provider.
π
Ask for provider support