Skip to content

Commit 91b5ea2

Browse files
committed
Fix timm incompatibility
Backports isl-org/MiDaS#234 Fixes thygate#319 Fixes thygate#323
1 parent 80f9fa3 commit 91b5ea2

File tree

5 files changed

+13
-9
lines changed

5 files changed

+13
-9
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
## Changelog
2+
### 0.4.4
3+
* Compatibility with stable-diffusion-webui 1.6.0
24
### 0.4.3 video processing tab
35
* Added an option to process videos directly from a video file. This leads to better results than batch-processing individual frames of a video. Allows generating depthmap videos, that can be used in further generations as custom depthmap videos.
46
* UI improvements.

dmidas/backbones/beit.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def _get_rel_pos_bias(self, window_size):
4444
old_sub_table = old_relative_position_bias_table[:old_num_relative_distance - 3]
4545

4646
old_sub_table = old_sub_table.reshape(1, old_width, old_height, -1).permute(0, 3, 1, 2)
47-
new_sub_table = F.interpolate(old_sub_table, size=(new_height, new_width), mode="bilinear")
47+
new_sub_table = F.interpolate(old_sub_table, size=(int(new_height),int(new_width)), mode="bilinear")
4848
new_sub_table = new_sub_table.permute(0, 2, 3, 1).reshape(new_num_relative_distance - 3, -1)
4949

5050
new_relative_position_bias_table = torch.cat(
@@ -96,12 +96,12 @@ def block_forward(self, x, resolution, shared_rel_pos_bias: Optional[torch.Tenso
9696
Modification of timm.models.beit.py: Block.forward to support arbitrary window sizes.
9797
"""
9898
if self.gamma_1 is None:
99-
x = x + self.drop_path(self.attn(self.norm1(x), resolution, shared_rel_pos_bias=shared_rel_pos_bias))
100-
x = x + self.drop_path(self.mlp(self.norm2(x)))
99+
x = x + self.drop_path1(self.attn(self.norm1(x), resolution, shared_rel_pos_bias=shared_rel_pos_bias))
100+
x = x + self.drop_path2(self.mlp(self.norm2(x)))
101101
else:
102-
x = x + self.drop_path(self.gamma_1 * self.attn(self.norm1(x), resolution,
102+
x = x + self.drop_path1(self.gamma_1 * self.attn(self.norm1(x), resolution,
103103
shared_rel_pos_bias=shared_rel_pos_bias))
104-
x = x + self.drop_path(self.gamma_2 * self.mlp(self.norm2(x)))
104+
x = x + self.drop_path2(self.gamma_2 * self.mlp(self.norm2(x)))
105105
return x
106106

107107

dzoedepth/models/base_models/midas.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,9 @@ def build(midas_model_type="DPT_BEiT_L_384", train_midas=False, use_pretrained_m
338338
kwargs = MidasCore.parse_img_size(kwargs)
339339
img_size = kwargs.pop("img_size", [384, 384])
340340
print("img_size", img_size)
341-
midas = torch.hub.load("intel-isl/MiDaS", midas_model_type,
341+
# TODO: use locally-bundled midas
342+
# The repo should be changed back to isl-org/MiDaS once this MR lands
343+
midas = torch.hub.load("AyaanShah2204/MiDaS", midas_model_type,
342344
pretrained=use_pretrained_midas, force_reload=force_reload)
343345
kwargs.update({'keep_aspect_ratio': force_keep_ar})
344346
midas_core = MidasCore(midas, trainable=train_midas, fetch_features=fetch_features,

install.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ def ensure(module_name, min_version=None):
2222
msg = f'{requirement} requirement for depthmap script'
2323
launch.run_pip(cmd, msg)
2424

25-
if not launch.is_installed("timm"): #0.6.7 # For midas
26-
launch.run_pip('install --force-reinstall "timm==0.6.12"', "timm requirement for depthmap script")
25+
26+
ensure('timm', '0.9.2') # For midas, specified just in case
2727

2828
ensure('matplotlib')
2929

src/misc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def get_commit_hash():
1515

1616
REPOSITORY_NAME = "stable-diffusion-webui-depthmap-script"
1717
SCRIPT_NAME = "DepthMap"
18-
SCRIPT_VERSION = "v0.4.3"
18+
SCRIPT_VERSION = "v0.4.4"
1919
SCRIPT_FULL_NAME = f"{SCRIPT_NAME} {SCRIPT_VERSION} ({get_commit_hash()})"
2020

2121

0 commit comments

Comments
 (0)