21 lines
604 B
Python
21 lines
604 B
Python
import torch
|
|
from PIL import Image
|
|
from modelscope import AutoModel, AutoTokenizer
|
|
model_path = '/share/fshare/common/models/OpenBMB/MiniCPM-V-2_6'
|
|
model = AutoModel.from_pretrained(model_path, trust_remote_code=True).to(dtype=torch.bfloat16)
|
|
model = model.to(device='cuda:3')
|
|
model = model.eval()
|
|
tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
|
|
|
|
|
|
image = Image.open('demo.jpeg').convert('RGB')
|
|
question = '图片里有什么?'
|
|
msgs = [{'role': 'user', 'content': [image, question]}]
|
|
|
|
res = model.chat(
|
|
image=None,
|
|
msgs=msgs,
|
|
tokenizer=tokenizer
|
|
)
|
|
print(res)
|