More detailes can be found in our paper at
https://arxiv.org/abs/2403.01487. We have released the pretraining model and the pyotrch code at
https://github.com/InfiMM/infimm-hd/. Feel free to build your model from our pretrained model.
1import torch
2from transformers import AutoModelForCausalLM, AutoProcessor
3
4processor = AutoProcessor.from_pretrained("Infi-MM/infimm-hd", trust_remote_code=True)
5
6prompts = [
7 {
8 "role": "user",
9 "content": [
10 {"image": "/xxx/test.jpg"}, # change it with you image
11 "Please describe the image in detail.",
12 ],
13 }
14]
15inputs = processor(prompts)
16# use bf16 and gpu 0
17model = AutoModelForCausalLM.from_pretrained(
18 "Infi-MM/infimm-hd",
19 torch_dtype=torch.bfloat16,
20 trust_remote_code=True,
21).to(0).eval()
22
23inputs = inputs
24
25inputs["batch_images"] = inputs["batch_images"].to(torch.bfloat16)
26for k in inputs:
27 inputs[k] = inputs[k].to(model.device)
28
29generated_ids = model.generate(
30 **inputs,
31 min_new_tokens=0,
32 max_new_tokens=256,
33)
34generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)
35print(generated_text)
The copyright of the images belongs to the original authors.
Please feel free to contact us via email
infimmbytedance@gmail.com if you have any questions.
1@misc{liu2024infimmhd,
2 title={InfiMM-HD: A Leap Forward in High-Resolution Multimodal Understanding},
3 author={Haogeng Liu and Quanzeng You and Xiaotian Han and Yiqi Wang and Bohan Zhai and Yongfei Liu and Yunzhe Tao and Huaibo Huang and Ran He and Hongxia Yang},
4 year={2024},
5 eprint={2403.01487},
6 archivePrefix={arXiv},
7 primaryClass={cs.CV}
8}