Skip to content

pooler of dino-v2 is newly initialized when loading the pre-trained model #25377

@garychan22

Description

@garychan22

System Info

I have encountered the following warning when loading facebook/dinov2-giant:

Some weights of Dinov2Model were not initialized from the model checkpoint at models--facebook--dinov2-giant and are newly initialized:['pooler.dense.bias', 'pooler.dense.weight']

does this mean that we cannot utilize the output.pooler_output as the global feature?

transformers 4.32.0.dev0

Who can help?

No response

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

import os
from transformers import AutoImageProcessor, AutoModel
from PIL import Image

image_path = 'COCO_val2014_000000000285.jpg'
image = Image.open(image_path)

processor = AutoImageProcessor.from_pretrained(r"models--facebook--dinov2-giant")
model = AutoModel.from_pretrained(r"models--facebook--dinov2-giant")

inputs = processor(images=[image] * 2, return_tensors="pt")
outputs = model(**inputs)
last_hidden_states = outputs.last_hidden_state # bs x 257 x 1536, all features [global, patch ....]
global_feature = outputs.pooler_output # bs x 1536, global image feature after pooling layer

print(last_hidden_states.size())

Expected behavior

expect the outputs.pooler_output is meaningful

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions