From 4affab9d3eec48733d7206b0d2f3196f7f51f64d Mon Sep 17 00:00:00 2001 From: Jenia Golbstein Date: Sat, 20 Dec 2025 18:23:46 +0200 Subject: [PATCH] Fix normalization in vision transformer outputs When cat_token=True, the code manually splits the output tensor to fit self.norm (which expects embed_dim). It appears the normalization step was accidentally skipped for the first half (local features), while the second half is correctly normalized. This results in a single output tensor containing mixed scales, which contradicts the behavior of cat_token=False where the full signal is normalized. --- src/depth_anything_3/model/dinov2/vision_transformer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/depth_anything_3/model/dinov2/vision_transformer.py b/src/depth_anything_3/model/dinov2/vision_transformer.py index f0f8e23a..82cc49fa 100644 --- a/src/depth_anything_3/model/dinov2/vision_transformer.py +++ b/src/depth_anything_3/model/dinov2/vision_transformer.py @@ -385,7 +385,7 @@ def get_intermediate_layers( elif outputs[0][1].shape[-1] == (self.embed_dim * 2): outputs = [ torch.cat( - [out[1][..., : self.embed_dim], self.norm(out[1][..., self.embed_dim :])], + [self.norm(out[1][..., : self.embed_dim]), self.norm(out[1][..., self.embed_dim :])], dim=-1, ) for out in outputs