Views
No views yet

| Model | Visual Encoder | LLM | PEFT | MMEp | MMEC | MMMUV | MMMUT |
|---|---|---|---|---|---|---|---|
| bunny-v1_0-3B | SigLIP | Phi-2(2.7B) | LoRA | 1488.8 | 289.3 | 38.2 | 33.0 |
| opencsg-bunny-v0.1-3B | SigLIP | Phi-2(2.7B) | LoRA | 1527.1 | 299.3 | 38.4 | 33.0 |
pip install torch transformers accelerate pillow1import torch
2import transformers
3from transformers import AutoModelForCausalLM, AutoTokenizer
4from PIL import Image
5import warnings
6
7# disable some warnings
8transformers.logging.set_verbosity_error()
9transformers.logging.disable_progress_bar()
10warnings.filterwarnings('ignore')
11
12# set device
13torch.set_default_device('cpu') # or 'cuda'
14
15# create model
16model = AutoModelForCausalLM.from_pretrained(
17 'opencsg/opencsg-bunny-v0.1-3B',
18 torch_dtype=torch.float16,
19 device_map='auto',
20 trust_remote_code=True)
21tokenizer = AutoTokenizer.from_pretrained(
22 'opencsg/opencsg-bunny-v0.1-3B',
23 trust_remote_code=True)
24
25# text prompt
26prompt = 'Why is the image funny?'
27text = f"A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions. USER: <image>\n{prompt} ASSISTANT:"
28text_chunks = [tokenizer(chunk).input_ids for chunk in text.split('<image>')]
29input_ids = torch.tensor(text_chunks[0] + [-200] + text_chunks[1], dtype=torch.long).unsqueeze(0)
30
31# image, sample images can be found in images folder
32image = Image.open('example_2.png')
33image_tensor = model.process_images([image], model.config).to(dtype=model.dtype)
34
35# generate
36output_ids = model.generate(
37 input_ids,
38 images=image_tensor,
39 max_new_tokens=100,
40 use_cache=True)[0]
41
42print(tokenizer.decode(output_ids[input_ids.shape[1]:], skip_special_tokens=True).strip())
| Model | Visual Encoder | LLM | PEFT | MMEp | MMEC | MMMUV | MMMUT |
|---|---|---|---|---|---|---|---|
| bunny-v1_0-3B | SigLIP | Phi-2(2.7B) | LoRA | 1488.8 | 289.3 | 38.2 | 33.0 |
| opencsg-bunny-v0.1-3B | SigLIP | Phi-2(2.7B) | LoRA | 1527.1 | 299.3 | 38.4 | 33.0 |
pip install torch transformers accelerate pillow1import torch
2import transformers
3from transformers import AutoModelForCausalLM, AutoTokenizer
4from PIL import Image
5import warnings
6
7# disable some warnings
8transformers.logging.set_verbosity_error()
9transformers.logging.disable_progress_bar()
10warnings.filterwarnings('ignore')
11
12# set device
13torch.set_default_device('cpu') # or 'cuda'
14
15# create model
16model = AutoModelForCausalLM.from_pretrained(
17 'opencsg/opencsg-bunny-v0.1-3B',
18 torch_dtype=torch.float16,
19 device_map='auto',
20 trust_remote_code=True)
21tokenizer = AutoTokenizer.from_pretrained(
22 'opencsg/opencsg-bunny-v0.1-3B',
23 trust_remote_code=True)
24
25# text prompt
26prompt = 'Why is the image funny?'
27text = f"A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions. USER: <image>\n{prompt} ASSISTANT:"
28text_chunks = [tokenizer(chunk).input_ids for chunk in text.split('<image>')]
29input_ids = torch.tensor(text_chunks[0] + [-200] + text_chunks[1], dtype=torch.long).unsqueeze(0)
30
31# image, sample images can be found in images folder
32image = Image.open('example_2.png')
33image_tensor = model.process_images([image], model.config).to(dtype=model.dtype)
34
35# generate
36output_ids = model.generate(
37 input_ids,
38 images=image_tensor,
39 max_new_tokens=100,
40 use_cache=True)[0]
41
42print(tokenizer.decode(output_ids[input_ids.shape[1]:], skip_special_tokens=True).strip())