You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I can run Janus-Pro-7B demo. However it doesn't work when I try to change the assistant content from "" to "你好。" or "你好.". As long as '.' or '。' exists in the assistant content Janus doesnt work. just output an empty string.
Here my codes.
importtorchfromtransformersimportAutoModelForCausalLMfromjanus.modelsimportMultiModalityCausalLM, VLChatProcessorfromjanus.utils.ioimportload_pil_images# specify the path to the modelmodel_path="deepseek-ai/Janus-Pro-7B"vl_chat_processor: VLChatProcessor=VLChatProcessor.from_pretrained(model_path)
tokenizer=vl_chat_processor.tokenizervl_gpt: MultiModalityCausalLM=AutoModelForCausalLM.from_pretrained(
model_path, trust_remote_code=True
)
vl_gpt=vl_gpt.to(torch.bfloat16).cuda().eval()
conversation= [
{
"role": "<|User|>",
"content": f"<image_placeholder>\n{tellmewhatyousee.}",
"images": [image],
},
{"role": "<|Assistant|>", "content": "这是你好。"}, # if content is "", janus can work. Otherwise doesnt
]
# load images and prepare for inputspil_images=load_pil_images(conversation)
prepare_inputs=vl_chat_processor(
conversations=conversation, images=pil_images, force_batchify=True
).to(vl_gpt.device)
# # run image encoder to get the image embeddingsinputs_embeds=vl_gpt.prepare_inputs_embeds(**prepare_inputs)
# # run the model to get the responseoutputs=vl_gpt.language_model.generate(
inputs_embeds=inputs_embeds,
attention_mask=prepare_inputs.attention_mask,
pad_token_id=tokenizer.eos_token_id,
bos_token_id=tokenizer.bos_token_id,
eos_token_id=tokenizer.eos_token_id,
max_new_tokens=512,
do_sample=False,
use_cache=True,
)
answer=tokenizer.decode(outputs[0].cpu().tolist(), skip_special_tokens=True)
print(f"{prepare_inputs['sft_format'][0]}", answer)
The text was updated successfully, but these errors were encountered:
I can run Janus-Pro-7B demo. However it doesn't work when I try to change the assistant content from "" to "你好。" or "你好.". As long as '.' or '。' exists in the assistant content Janus doesnt work. just output an empty string.
Here my codes.
The text was updated successfully, but these errors were encountered: