mlfoundations / open_clip

An open source implementation of CLIP.
Other
9.93k stars 959 forks source link

TypeError: CLIPTextCfg.__init__() got an unexpected keyword argument 'hf_proj_type' #747

Closed ahmed1996said closed 8 months ago

ahmed1996said commented 10 months ago

Hi, I'm using open-clip-torch==2.20.0 to load a clip model from HuggingFace Hub. I was able to load the model with no issues in the past, but now I'm getting this error:

>>> import open_clip
>>> model, preprocess_train, preprocess_val = open_clip.create_model_and_transforms('hf-hub:microsoft/BiomedCLIP-PubMedBERT_256-vit_base_patch16_224')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "PATH_TO_CONDA_ENV/lib/python3.10/site-packages/open_clip/factory.py", line 308, in create_model_and_transforms
    model = create_model(
  File "PATH_TO_CONDA_ENV/lib/python3.10/site-packages/open_clip/factory.py", line 190, in create_model
    model = CustomTextCLIP(**model_cfg, cast_dtype=cast_dtype)
  File "PATH_TO_CONDA_ENV/lib/python3.10/site-packages/open_clip/model.py", line 273, in __init__
    self.text = _build_text_tower(embed_dim, text_cfg, quick_gelu, cast_dtype)
  File "PATH_TO_CONDA_ENV/lib/python3.10/site-packages/open_clip/model.py", line 155, in _build_text_tower
    text_cfg = CLIPTextCfg(**text_cfg)
TypeError: CLIPTextCfg.__init__() got an unexpected keyword argument 'hf_proj_type'

_Note that I replaced the actual path to the conda env with "PATH_TO_CONDAENV" above.

gabrielilharco commented 10 months ago

Hi @ahmed1996said. I'd recommend switching to the latest openclip version (2.23). I just tested your command and it works for me

rwightman commented 8 months ago

this seems like a version / config mismatch, so updating should solve