From b7e8a7cdadbe5596e9d1d4838bc52bba175015a1 Mon Sep 17 00:00:00 2001 From: Semjon Kravtsenko Date: Sun, 3 Sep 2023 22:26:57 +0300 Subject: [PATCH 1/2] Compatibility with timm 0.9.5 Authored by: lllyasviel --- midas/backbones/beit.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/midas/backbones/beit.py b/midas/backbones/beit.py index 7a24e02c..1a898086 100644 --- a/midas/backbones/beit.py +++ b/midas/backbones/beit.py @@ -95,6 +95,8 @@ def block_forward(self, x, resolution, shared_rel_pos_bias: Optional[torch.Tenso """ Modification of timm.models.beit.py: Block.forward to support arbitrary window sizes. """ + if hasattr(self, 'drop_path1') and not hasattr(self, 'drop_path'): + self.drop_path = self.drop_path1 if self.gamma_1 is None: x = x + self.drop_path(self.attn(self.norm1(x), resolution, shared_rel_pos_bias=shared_rel_pos_bias)) x = x + self.drop_path(self.mlp(self.norm2(x))) From 6a138812e9926f8b3a66eb63d43f3b60e1eb2020 Mon Sep 17 00:00:00 2001 From: Semjon Kravtsenko Date: Sun, 3 Sep 2023 22:31:05 +0300 Subject: [PATCH 2/2] Compatibility with torch 2.1.0 dev Authored by: AyaanShah2204 --- midas/backbones/beit.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/midas/backbones/beit.py b/midas/backbones/beit.py index 1a898086..642a8096 100644 --- a/midas/backbones/beit.py +++ b/midas/backbones/beit.py @@ -44,7 +44,7 @@ def _get_rel_pos_bias(self, window_size): old_sub_table = old_relative_position_bias_table[:old_num_relative_distance - 3] old_sub_table = old_sub_table.reshape(1, old_width, old_height, -1).permute(0, 3, 1, 2) - new_sub_table = F.interpolate(old_sub_table, size=(new_height, new_width), mode="bilinear") + new_sub_table = F.interpolate(old_sub_table, size=(int(new_height), int(new_width)), mode="bilinear") new_sub_table = new_sub_table.permute(0, 2, 3, 1).reshape(new_num_relative_distance - 3, -1) new_relative_position_bias_table = torch.cat(