facebookresearch / dinov2

PyTorch code and models for the DINOv2 self-supervised learning method.
Apache License 2.0
8.89k stars 777 forks source link

acquire patch tokens #396

Closed wangyf8848 closed 4 months ago

wangyf8848 commented 6 months ago

Hello, may I ask if I can get the code of the model? I want to get the patch tokens or even the output of the middle layer, not just the class token.

qasfb commented 4 months ago

The get_intermediate_layers function is what you need ! The model code is in https://github.com/facebookresearch/dinov2/blob/main/dinov2/models/vision_transformer.py