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

Can't load CLIP-ViT-H-14-frozen-xlm-roberta-large-laion5B-s13B-b90k #594

Closed
kimihailv opened this issue Aug 10, 2023 · 7 comments
Closed

Comments

@kimihailv
Copy link

When I am trying to load this model, the following error occurred:

import open_clip
model, preprocess_train, preprocess_val = open_clip.create_model_and_transforms('hf-hub:laion/CLIP-ViT-H-14-frozen-xlm-roberta-large-laion5B-s13B-b90k')
Downloading (…)ip_pytorch_model.bin: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 4.77G/4.77G [02:20<00:00, 33.9MB/s]
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/huggingface_hub/utils/_errors.py", line 261, in hf_raise_for_status
    response.raise_for_status()
  File "/usr/local/lib/python3.8/dist-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://huggingface.co/laion/CLIP-ViT-H-14-frozen-xlm-roberta-large-laion5B-s13B-b90k/resolve/main/open_clip_config.json
@kimihailv
Copy link
Author

The same for laion/CLIP-ViT-B-32-xlm-roberta-base-laion5B-s13B-b90k

@kimihailv
Copy link
Author

if I try to load model without HF, this error encountered:

import open_clip
model, _, preprocess = open_clip.create_model_and_transforms('xlm-roberta-large-ViT-H-14', pretrained='frozen_laion5b_s13b_b90k')
Downloading (…)lve/main/config.json: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 616/616 [00:00<00:00, 136kB/s]
Downloading model.safetensors: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2.24G/2.24G [01:05<00:00, 34.4MB/s]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.8/dist-packages/open_clip/factory.py", line 308, in create_model_and_transforms
    model = create_model(
  File "/usr/local/lib/python3.8/dist-packages/open_clip/factory.py", line 228, in create_model
    load_checkpoint(model, checkpoint_path)
  File "/usr/local/lib/python3.8/dist-packages/open_clip/factory.py", line 104, in load_checkpoint
    incompatible_keys = model.load_state_dict(state_dict, strict=strict)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 2041, in load_state_dict
    raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
RuntimeError: Error(s) in loading state_dict for CustomTextCLIP:
        Unexpected key(s) in state_dict: "text.transformer.embeddings.position_ids". 

@dcferreira
Copy link

Downgrading my transformers version worked for me.

pip install -U transformers==4.30.2

@EIFY
Copy link
Contributor

EIFY commented Aug 11, 2023

I also just put out a PR yesterday to fix this: #595

if I try to load model without HF, this error encountered:

import open_clip
model, _, preprocess = open_clip.create_model_and_transforms('xlm-roberta-large-ViT-H-14', pretrained='frozen_laion5b_s13b_b90k')
Downloading (…)lve/main/config.json: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 616/616 [00:00<00:00, 136kB/s]
Downloading model.safetensors: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2.24G/2.24G [01:05<00:00, 34.4MB/s]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.8/dist-packages/open_clip/factory.py", line 308, in create_model_and_transforms
    model = create_model(
  File "/usr/local/lib/python3.8/dist-packages/open_clip/factory.py", line 228, in create_model
    load_checkpoint(model, checkpoint_path)
  File "/usr/local/lib/python3.8/dist-packages/open_clip/factory.py", line 104, in load_checkpoint
    incompatible_keys = model.load_state_dict(state_dict, strict=strict)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 2041, in load_state_dict
    raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
RuntimeError: Error(s) in loading state_dict for CustomTextCLIP:
        Unexpected key(s) in state_dict: "text.transformer.embeddings.position_ids". 

@kimihailv
Copy link
Author

What about first error, when config can't be found?

@rwightman
Copy link
Collaborator

no open_clip_config.json was pushed by whoever uploaded this model, so the hf-hub method won't work as it sourced the model config from the hub instead of open_clip...

@zhangluustb
Copy link

use this instead:
model, _, preprocess = open_clip.create_model_and_transforms('xlm-roberta-large-ViT-H-14', pretrained='frozen_laion5b_s13b_b90k')
tokenizer = open_clip.get_tokenizer('xlm-roberta-large-ViT-H-14')

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

5 participants