mlfoundations / open_clip

An open source implementation of CLIP.
Other
10.45k stars 991 forks source link

Model config for RN50x64 not found #211

Closed lopho closed 2 years ago

lopho commented 2 years ago

Instantiating a RN50x64 model without pretrained weights fails.

import open_clip
m = open_clip.create_model('RN50x64')
ERROR:root:Model config for RN50x64 not found; available models ['RN50', 'RN50-quickgelu', 'RN50x4', 'RN50x16', 'RN101', 'RN101-quickgelu', 'timm-convnext_base', 'timm-convnext_large', 'timm-convnext_xlarge', 'timm-efficientnetv2_rw_s', 'timm-resnetaa50d', 'timm-swin_base_patch4_window7_224', 'timm-vit_medium_patch16_gap_256', 'timm-vit_relpos_medium_patch16_cls_224', 'ViT-B-16', 'ViT-B-16-plus', 'ViT-B-16-plus-240', 'ViT-B-32', 'ViT-B-32-plus-256', 'ViT-B-32-quickgelu', 'ViT-e-14', 'ViT-g-14', 'ViT-G-14', 'ViT-H-14', 'ViT-H-16', 'ViT-L-14', 'ViT-L-14-280', 'ViT-L-14-336', 'ViT-L-16', 'ViT-L-16-320', 'ViT-M-16', 'ViT-M-16-alt', 'ViT-M-32', 'ViT-M-32-alt', 'ViT-S-16', 'ViT-S-16-alt', 'ViT-S-32', 'ViT-S-32-alt'].
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/.../open_clip/src/open_clip/factory.py", line 123, in create_model
    raise RuntimeError(f'Model config for {model_name} not found.')

With pretrained succeeds.

import open_clip
m = open_clip.create_model('RN50x64', pretrained = 'openai')
type(m)
<class 'open_clip.model.CLIP'>

Calling open_clip.get_model_config('RN50x64') returns None.

import open_clip
c = open_clip.get_model_config('RN50x64')
type(c)
<class 'NoneType'>

I would expect create_model to instantiate a randomly initialized model, and get_model_config to return the model config for RN50x64.

rwightman commented 2 years ago

@lopho hmm, yeah I had that config locally at one point as I noticed it was missing but seems to have got lost in the shuffle. FYI the 'openai' pretrained tag obtains the model config from the jit scripted checkpoint and that's why it works without a json config... I'll add one soon