Search code examples
pythonmachine-learningdeep-learninghuggingface-transformershuggingface

OSError: [model] does not appear to have a file named config.json


I want to load a huggingface model. The model I want to load has about 150K downloads so I don't think there is any problem with the model itself.

With the both loading codes below I get the same error:

from transformers import AutoModel
AutoModel.from_pretrained("laion/CLIP-convnext_large_d_320.laion2B-s29B-b131K-ft-soup")

And

from transformers import CLIPProcessor, CLIPModel
model_id = "laion/CLIP-convnext_large_d_320.laion2B-s29B-b131K-ft-soup"
processor = CLIPProcessor.from_pretrained(model_id)
model = CLIPModel.from_pretrained(model_id)

With both I get:

OSError: laion/CLIP-convnext_large_d_320.laion2B-s29B-b131K-ft-soup does not appear to have a file named preprocessor_config.json. Checkout 'https://huggingface.co/laion/CLIP-convnext_large_d_320.laion2B-s29B-b131K-ft-soup/main' for available files.

Any help to load the model would be appreciated.


Solution

  • It seems this model is an OpenCLIP only model right now. You can not load it the usual way.

    You should first install open_clip with pip install open_clip_torch then use this code:

    import open_clip
    
    model, preprocess_train, preprocess_val = open_clip.create_model_and_transforms('hf-hub:laion/CLIP-convnext_large_d_320.laion2B-s29B-b131K-ft-soup')
    tokenizer = open_clip.get_tokenizer('hf-hub:laion/CLIP-convnext_large_d_320.laion2B-s29B-b131K-ft-soup')