Skip to content

[FEATURE] DINOv2 Feature Map extraction #2068

Answered by FLamefiREz
FLamefiREz asked this question in Q&A
Discussion options

You must be logged in to vote

here, I found an example

from transformers import Dinov2Backbone
import torch

# model_ = torch.load("weights/dinov2_s_cow_front_face_fine_tuned_model.pth")
model = Dinov2Backbone.from_pretrained("facebook/dinov2-base")

pixel_values = torch.randn(1, 3, 224, 224)

outputs = model(pixel_values)

for feature_map in outputs.feature_maps:
    print(feature_map.shape)

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by FLamefiREz
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
enhancement New feature or request
2 participants
Converted from issue

This discussion was converted from issue #2066 on January 10, 2024 22:47.