# Loading Weights from Customized Model

**URL:** <https://discuss.huggingface.co/t/loading-weights-from-customized-model/53746>\
**Category:** 🤗Transformers\
**Created:** [September 6, 2023, 6:59am UTC](https://discuss.huggingface.co/t/loading-weights-from-customized-model/53746 "2023-09-06T06:59:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pmoct](https://avatars.discourse-cdn.com/v4/letter/p/58956e/32.png) [@pmoct](https://discuss.huggingface.co/u/pmoct)\
**Post date:** [September 6, 2023, 6:59am UTC](https://discuss.huggingface.co/t/loading-weights-from-customized-model/53746/1 "2023-09-06T06:59:45Z")

</div>

Hello!

I have trained a ViTAdapter model, that I added a prediction head to, with the following code:

```auto
model = AutoAdapterModel.from_pretrained(
    'google/vit-base-patch16-224-in21k',
    from_tf=bool(".ckpt" in 'google/vit-base-patch16-224-in21k'),
    config=config,
    cache_dir=None,
    revision='main',
    use_auth_token=None,
    ignore_mismatched_sizes=False,
)

model.add_image_classification_head(
    "classification_head",
    num_labels = len(labels),
    id2label=id2label,
)

```

I now want to load up the weights, so I can use the model on new images. However, when I call the following:

```auto
model = AutoAdapterModel.from_pretrained("path_to_model_weights")

```

I get the error

> Some weights of the model checkpoint at vit\_adapter\_orange\_surgical\_task/vit-adapter-surgery were not used when initializing ViTAdapterModel

I believe this is because the weights from the added prediction head cannot be initialized onto a basic ViTAdapterModel. Is there a way to call .from\_pretrained from a custom model instead of AutoAdapterModel? Alternatively, could a prediction head be added onto the loaded model above and filled with the weights from the trained head?

I appreciate any help and advice!  
Thank you
