Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot load pretrained model to run the inference s1_pipe #3

Closed
aquarter147 opened this issue May 21, 2024 · 1 comment
Closed

Cannot load pretrained model to run the inference s1_pipe #3

aquarter147 opened this issue May 21, 2024 · 1 comment

Comments

@aquarter147
Copy link

aquarter147 commented May 21, 2024

I encountered an issue while attempting to load a pre-trained model using the from_pretrained method in the transformers library. The error message indicates a discrepancy in the shape of the class_embedding tensor between the pre-trained model and the code. Specifically, the model expects a tensor of shape [1280] for class_embedding, while the code expects [1024]

CUDA_VISIBLE_DEVICES=0 python gen_s1.py --config cfgs/s1.yaml  validation_dataset.filepaths=['pumpkin.png'] validation_dataset.crop_size=224

/home/thaoanh/anaconda3/envs/wonder3dd/lib/python3.10/site-packages/diffusers/utils/outputs.py:63: UserWarning: torch.utils._pytree._register_pytree_node is deprecated. Please use torch.utils._pytree.register_pytree_node instead.
  torch.utils._pytree._register_pytree_node(
{'pretrained_model_name_or_path': '/home/thaoanh/workspace/Envision3D/ckpts/s1_pipe', 'revision': None, 'validation_dataset': {'root_dir': './example_imgs/', 'bg_color': 'white', 'crop_size': 224, 'img_wh': [256, 256], 'filepaths': ['pumpkin.png']}, 'seed': 43, 'validation_batch_size': 1, 'enable_xformers_memory_efficient_attention': True, 'dataloader_num_workers': 64, 'save_dir': './img_outputs/'}
Loading pipeline components...:  40%|████████████████████████████████████████████▊                                                                   | 2/5 [00:00<00:00, 27.49it/s]
Traceback (most recent call last):
  File "/home/thaoanh/workspace/Envision3D/gen_s1.py", line 230, in <module>
    main(cfg)
  File "/home/thaoanh/workspace/Envision3D/gen_s1.py", line 177, in main
    pipeline = load_envision3d_pipeline(cfg)
  File "/home/thaoanh/workspace/Envision3D/gen_s1.py", line 154, in load_envision3d_pipeline
    pipeline = MVDiffusionRefImagePipeline.from_pretrained(
  File "/home/thaoanh/anaconda3/envs/wonder3dd/lib/python3.10/site-packages/diffusers/pipelines/pipeline_utils.py", line 1265, in from_pretrained
    loaded_sub_model = load_sub_model(
  File "/home/thaoanh/anaconda3/envs/wonder3dd/lib/python3.10/site-packages/diffusers/pipelines/pipeline_utils.py", line 520, in load_sub_model
    loaded_sub_model = load_method(os.path.join(cached_folder, name), **loading_kwargs)
  File "/home/thaoanh/anaconda3/envs/wonder3dd/lib/python3.10/site-packages/transformers/modeling_utils.py", line 3677, in from_pretrained
    ) = cls._load_pretrained_model(
  File "/home/thaoanh/anaconda3/envs/wonder3dd/lib/python3.10/site-packages/transformers/modeling_utils.py", line 4104, in _load_pretrained_model
    new_error_msgs, offload_index, state_dict_index = _load_state_dict_into_meta_model(
  File "/home/thaoanh/anaconda3/envs/wonder3dd/lib/python3.10/site-packages/transformers/modeling_utils.py", line 886, in _load_state_dict_into_meta_model
    set_module_tensor_to_device(model, param_name, param_device, **set_module_kwargs)
  File "/home/thaoanh/anaconda3/envs/wonder3dd/lib/python3.10/site-packages/accelerate/utils/modeling.py", line 358, in set_module_tensor_to_device
    raise ValueError(
ValueError: Trying to set a tensor of shape torch.Size([1280]) in "class_embedding" (which has shape torch.Size([1024])), this look incorrect
```.`
@Pang-Yatian
Copy link
Member

Hi, we cannot reproduce this error on our side.

Please ensure the environment is consistent as listed in req.txt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants