想问一下部署deepseekvl2,运行github上面的sample后出现这个问题怎么解决呢?
import torch
from transformers import AutoModelForCausalLM
from deepseek_vl2.models import DeepseekVLV2Processor, DeepseekVLV2ForCausalLM
from deepseek_vl2.utils.io import load_pil_images
# specify the path to the model
model_path = "deepseek-ai/deepseek-vl2-small"
vl_chat_processor: DeepseekVLV2Processor = DeepseekVLV2Processor.from_pretrained(model_path)
tokenizer = vl_chat_processor.tokenizer
vl_gpt: DeepseekVLV2ForCausalLM = AutoModelForCausalLM.from_pretrained(model_path, trust_remote_code=True)
vl_gpt = vl_gpt.to(torch.bfloat16).cuda().eval()
## single image conversation example
conversation = [
{
"role": "<|User|>",
"content": "<image>\n<|ref|>The giraffe at the back.<|/ref|>.",
"images": ["./images/visual_grounding.jpeg"],
},
{"role": "<|Assistant|>", "content": ""},
]
## multiple images (or in-context learning) conversation example
# conversation = [
# {
# "role": "User",
# "content": "<image_placeholder>A dog wearing nothing in the foreground, "
# "<image_placeholder>a dog wearing a santa hat, "
# "<image_placeholder>a dog wearing a wizard outfit, and "
# "<image_placeholder>what's the dog wearing?",
# "images": [
# "images/dog_a.png",
# "images/dog_b.png",
# "images/dog_c.png",
# "images/dog_d.png",
# ],
# },
# {"role": "Assistant", "content": ""}
# ]
# load images and prepare for inputs
pil_images = load_pil_images(conversation)
prepare_inputs = vl_chat_processor(
conversations=conversation,
images=pil_images,
force_batchify=True,
system_prompt=""
).to(vl_gpt.device)
# run image encoder to get the image embeddings
inputs_embeds = vl_gpt.prepare_inputs_embeds(**prepare_inputs)
# run the model to get the response
outputs = 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)
OSError Traceback (most recent call last)
Cell In[2], line 10
8 # specify the path to the model
9 model_path = "deepseek-ai/deepseek-vl2-small"
---> 10 vl_chat_processor: DeepseekVLV2Processor = DeepseekVLV2Processor.from_pretrained(model_path)
11 tokenizer = vl_chat_processor.tokenizer
13 vl_gpt: DeepseekVLV2ForCausalLM = AutoModelForCausalLM.from_pretrained(model_path, trust_remote_code=True)
File ~/autodl-tmp/conda/envs/DeepSeek_VL2/lib/python3.8/site-packages/transformers/processing_utils.py:465, in ProcessorMixin.from_pretrained(cls, pretrained_model_name_or_path, cache_dir, force_download, local_files_only, token, revision, **kwargs)
462 if token is not None:
463 kwargs["token"] = token
--> 465 args = cls._get_arguments_from_pretrained(pretrained_model_name_or_path, **kwargs)
466 processor_dict, kwargs = cls.get_processor_dict(pretrained_model_name_or_path, **kwargs)
468 return cls.from_args_and_dict(args, processor_dict, **kwargs)
File ~/autodl-tmp/conda/envs/DeepSeek_VL2/lib/python3.8/site-packages/transformers/processing_utils.py:511, in ProcessorMixin._get_arguments_from_pretrained(cls, pretrained_model_name_or_path, **kwargs)
508 else:
509 attribute_class = getattr(transformers_module, class_name)
--> 511 args.append(attribute_class.from_pretrained(pretrained_model_name_or_path, **kwargs))
512 return args
File ~/autodl-tmp/conda/envs/DeepSeek_VL2/lib/python3.8/site-packages/transformers/tokenization_utils_base.py:2032, in PreTrainedTokenizerBase.from_pretrained(cls, pretrained_model_name_or_path, cache_dir, force_download, local_files_only, token, revision, trust_remote_code, *init_inputs, **kwargs)
2026 logger.info(
2027 f"Can't load following files from cache: {unresolved_files} and cannot check if these "
2028 "files are necessary for the tokenizer to operate."
2029 )
2031 if all(full_file_name is None for full_file_name in resolved_vocab_files.values()):
-> 2032 raise EnvironmentError(
2033 f"Can't load tokenizer for '{pretrained_model_name_or_path}'. If you were trying to load it from "
2034 "'https://huggingface.co/models', make sure you don't have a local directory with the same name. "
2035 f"Otherwise, make sure '{pretrained_model_name_or_path}' is the correct path to a directory "
2036 f"containing all relevant files for a {cls.name} tokenizer."
2037 )
2039 for file_id, file_path in vocab_files.items():
2040 if file_id not in resolved_vocab_files:
OSError: Can't load tokenizer for 'deepseek-ai/deepseek-vl2-small'. If you were trying to load it from 'https://huggingface.co/models', make sure you don't have a local directory with the same name. Otherwise, make sure 'deepseek-ai/deepseek-vl2-small' is the correct path to a directory containing all relevant files for a LlamaTokenizerFast tokenizer.
[ ]: