How to load model without pretrained weight

I can do ( with internet connection)

TFViTModel.from_pretrained(
  'google/vit-base-patch16-224'
)

now, without internet, and without requiring the pretrained weight, how to load this model?

Until now, it gives

OSError: We couldn't connect to 'https://huggingface.co' to load this file, couldn't find it in the cached files and it looks like google/vit-base-patch16-224 is not the path to a directory containing a file named config.json.
Checkout your internet connection or see how to run the library in offline mode at 'https://huggingface.co/docs/transformers/installation#offline-mode'.

Tried this but still pytorch - Make sure BERT model does not load pretrained weights? - Stack Overflow

from transformers import AutoConfig
config = AutoConfig.from_pretrained('google/vit-base-patch16-224')
model =  AutoModel.from_config(config)

This works

config =  AutoConfig.from_pretrained('..config.json', local_files_only=True)
model = TFViTModel.from_config(config)

For my particular model, the config.json file is from config.json · google/vit-base-patch16-224 at main

1 Like

Hi. Do you mean you downloaded the config.json file on the local environment?