Skip to content

Commit 500ee72

Browse files
authored
Merge pull request #409 from thygate/marigold
Two mode models supported
2 parents 5250c8b + 51ea821 commit 500ee72

19 files changed

+841
-41
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
__pycache__/
22
venv/
3+
.idea/

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
## Changelog
2+
### 0.4.6
3+
* Support for [Depth Anything](https://github.com/LiheYoung/Depth-Anything).
4+
### 0.4.5
5+
* Preliminary support for [Marigold](https://marigoldmonodepth.github.io). [PR #385](https://github.com/thygate/stable-diffusion-webui-depthmap-script/pull/385).
26
### 0.4.4
37
* Compatibility with stable-diffusion-webui 1.6.0
48
### 0.4.3 video processing tab

README.md

+28-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# High Resolution Depth Maps for Stable Diffusion WebUI
22
This program is an addon for [AUTOMATIC1111's Stable Diffusion WebUI](https://github.com/AUTOMATIC1111/stable-diffusion-webui) that creates depth maps. Using either generated or custom depth maps, it can also create 3D stereo image pairs (side-by-side or anaglyph), normalmaps and 3D meshes. The outputs of the script can be viewed directly or used as an asset for a 3D engine. Please see [wiki](https://github.com/thygate/stable-diffusion-webui-depthmap-script/wiki/Viewing-Results) to learn more. The program has integration with [Rembg](https://github.com/danielgatis/rembg). It also supports batch processing, processing of videos, and can also be run in standalone mode, without Stable Diffusion WebUI.
33

4-
To generate realistic depth maps from individual images, this script uses code and models from the [MiDaS](https://github.com/isl-org/MiDaS) and [ZoeDepth](https://github.com/isl-org/ZoeDepth) repositories by Intel ISL, or LeReS from the [AdelaiDepth](https://github.com/aim-uofa/AdelaiDepth) repository by Advanced Intelligent Machines. Multi-resolution merging as implemented by [BoostingMonocularDepth](https://github.com/compphoto/BoostingMonocularDepth) is used to generate high resolution depth maps.
4+
To generate realistic depth maps from individual images, this script uses code and models from the [Marigold](https://github.com/prs-eth/Marigold/) repository, from the [MiDaS](https://github.com/isl-org/MiDaS) and [ZoeDepth](https://github.com/isl-org/ZoeDepth) repositories by Intel ISL, or LeReS from the [AdelaiDepth](https://github.com/aim-uofa/AdelaiDepth) repository by Advanced Intelligent Machines. Multi-resolution merging as implemented by [BoostingMonocularDepth](https://github.com/compphoto/BoostingMonocularDepth) is used to generate high resolution depth maps.
55

66
Stereoscopic images are created using a custom-written algorithm.
77

@@ -94,7 +94,7 @@ Feel free to comment and share in the discussions and submit issues.
9494

9595
## Acknowledgements
9696

97-
This project relies on code and information from following papers :
97+
This project relies on code and information from the following papers :
9898

9999
MiDaS :
100100

@@ -198,3 +198,29 @@ ZoeDepth :
198198
copyright = {arXiv.org perpetual, non-exclusive license}
199199
}
200200
```
201+
202+
Marigold - Repurposing Diffusion-Based Image Generators for Monocular Depth Estimation:
203+
204+
```
205+
@misc{ke2023repurposing,
206+
title={Repurposing Diffusion-Based Image Generators for Monocular Depth Estimation},
207+
author={Bingxin Ke and Anton Obukhov and Shengyu Huang and Nando Metzger and Rodrigo Caye Daudt and Konrad Schindler},
208+
year={2023},
209+
eprint={2312.02145},
210+
archivePrefix={arXiv},
211+
primaryClass={cs.CV}
212+
}
213+
```
214+
215+
Depth Anything: Unleashing the Power of Large-Scale Unlabeled Data
216+
217+
```
218+
@misc{yang2024depth,
219+
title={Depth Anything: Unleashing the Power of Large-Scale Unlabeled Data},
220+
author={Lihe Yang and Bingyi Kang and Zilong Huang and Xiaogang Xu and Jiashi Feng and Hengshuang Zhao},
221+
year={2024},
222+
eprint={2401.10891},
223+
archivePrefix={arXiv},
224+
primaryClass={cs.CV}
225+
}
226+
```

bundled_sources.txt

+3
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,6 @@ https://github.com/aim-uofa/AdelaiDepth/tree/main/LeReS/Minist_Test/lib/
1717

1818
pix2pix
1919
https://github.com/junyanz/pytorch-CycleGAN-and-pix2pix/
20+
21+
Marigold
22+
https://github.com/prs-eth/Marigold/tree/22437a

install.py

+22
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
# Installs dependencies
2+
13
import launch
24
import platform
35
import sys
6+
import importlib.metadata
47

58
# TODO: some dependencies apparently being reinstalled on every run. Investigate and fix.
69

@@ -38,6 +41,8 @@ def ensure(module_name, min_version=None):
3841
launch.run_pip('install "moviepy==1.0.2"', "moviepy requirement for depthmap script")
3942
ensure('transforms3d', '0.4.1')
4043

44+
ensure('diffusers', '0.20.1') # For Merigold
45+
4146
ensure('imageio') # 2.4.1
4247
try: # Dirty hack to not reinstall every time
4348
importlib_metadata.version('imageio-ffmpeg')
@@ -52,3 +57,20 @@ def ensure(module_name, min_version=None):
5257

5358
if platform.system() == 'Darwin':
5459
ensure('pyqt6')
60+
61+
# Depth Anything
62+
def get_installed_version(package: str):
63+
try:
64+
return importlib.metadata.version(package)
65+
except Exception:
66+
return None
67+
def try_install_from_wheel(pkg_name: str, wheel_url: str):
68+
if get_installed_version(pkg_name) is not None:
69+
return
70+
try:
71+
launch.run_pip(f"install {wheel_url}", f" {pkg_name} requirement for depthmap script")
72+
except Exception as e:
73+
print('Failed to install wheel for Depth Anything support. It won\'t work.')
74+
try_install_from_wheel(
75+
"depth_anything",
76+
"https://github.com/huchenlei/Depth-Anything/releases/download/v1.0.0/depth_anything-2024.1.22.0-py2.py3-none-any.whl")

marigold/marigold/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .marigold_pipeline import MarigoldPipeline, MarigoldDepthOutput

0 commit comments

Comments
 (0)