Closed kanlions closed 2 years ago
Hi,
That's because the checkpoint you are loading (facebook/deit-base-patch16-224) needs to be loaded in a ViTModel
/ViTForImageClassification
rather than a DeiTModel
. As explained in the docs of DeiT, the authors also trained more efficient ViT models:
The authors of DeiT also released more efficiently trained ViT models, which you can directly plug into ViTModel or ViTForImageClassification. Techniques like data augmentation, optimization, and regularization were used in order to simulate training on a much larger dataset (while only using ImageNet-1k for pre-training). There are 4 variants available (in 3 different sizes): facebook/deit-tiny-patch16-224, facebook/deit-small-patch16-224, facebook/deit-base-patch16-224 and facebook/deit-base-patch16-384. Note that one should use DeiTFeatureExtractor in order to prepare images for the model.
@NielsRogge
Thank you very much for responding and I have got my mistake but still I have a confusion. Because Initially I started with 'facebook/deit-base-distilled-patch16-224' from the tutorial mentioned https://huggingface.co/docs/transformers/v4.19.2/en/model_doc/deit#transformers.DeiTFeatureExtractor
Still I get this issue. I understand I am not doing any classification so I get some warning but still I am not able to comprehend this. Any direction will be appreciated. Thanks in advance
Some weights of the model checkpoint at facebook/deit-base-distilled-patch16-224 were not used when initializing DeiTModel: ['distillation_classifier.bias', 'cls_classifier.weight', 'distillation_classifier.weight', 'cls_classifier.bias']
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.
Please note that issues that do not follow the contributing guidelines are likely to be ignored.
Hi,
When initializing a DeiTModel
, it won't include the heads on top. For that, you'll need to instantiate a DeiTForImageClassification
or DeiTForImageClassificationWithTeacher
model.
System Info
Who can help?
@NielsRogge The warning I get is this and a big list of layers You are using a model of type vit to instantiate a model of type deit. This is not supported for all configurations of models and can yield errors. Some weights of the model checkpoint at facebook/deit-base-patch16-224 were not used when initializing DeiTModel:
Information
Tasks
examples
folder (such as GLUE/SQuAD, ...)Reproduction
I did the following from transformers import DeiTFeatureExtractor, DeiTModel feature_extractor = DeiTFeatureExtractor.from_pretrained("facebook/deit-base-patch16-224") model = DeiTModel.from_pretrained("facebook/deit-base-patch16-224") inputs_ref = feature_extractor(images=im_ref, return_tensors="pt") with torch.no_grad(): outputs_ref = model(**inputs_ref) last_hidden_states_ref = outputs_ref.last_hidden_state
The warning I get is this and a big list of layers You are using a model of type vit to instantiate a model of type deit. This is not supported for all configurations of models and can yield errors. Some weights of the model checkpoint at facebook/deit-base-patch16-224 were not used when initializing DeiTModel:
The images are simple scenes only.
Expected behavior