Views
No views yet
1import argparse
2import torch
3from transformers import (AutoModel, AutoTokenizer,
4 BitsAndBytesConfig, CLIPImageProcessor,
5 GenerationConfig)
6def parse_args():
7 parser = argparse.ArgumentParser(description='UniBiomed')
8 parser.add_argument('--model_path', default='Luffy503/UniBiomed')
9 return args
10args = parse_args()
11
12# load model
13model = AutoModel.from_pretrained(
14 args.model_path,
15 torch_dtype=torch.bfloat16,
16 low_cpu_mem_usage=True,
17 use_flash_attn=True,
18 trust_remote_code=True,
19 ).eval().cuda()
20tokenizer = AutoTokenizer.from_pretrained(
21 args.model_path,
22 trust_remote_code=True,
23)
24
25# define data input, image and text instruction
26data_dict = {}
27image, text = None, None
28data_dict['image'] = image
29data_dict['text'] = text
30
31# output
32pred_dict = model.predict_forward(**data_dict, tokenizer=tokenizer)
33# text description
34prediction = pred_dict['prediction']
35# segmentation mask
36mask = pred_dict['prediction_masks'][0][0]1@article{wu2025unibiomed,
2 title={UniBiomed: A Universal Foundation Model for Grounded Biomedical Image Interpretation},
3 author={Wu, Linshan and Nie, Yuxiang and He, Sunan and Zhuang, Jiaxin and Chen, Hao},
4 journal={arXiv preprint arXiv:2504.21336},
5 year={2025}
6}