forked from thygate/stable-diffusion-webui-depthmap-script
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.py
54 lines (40 loc) · 1.71 KB
/
install.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import launch
import platform
import sys
# TODO: some dependencies apparently being reinstalled on every run. Investigate and fix.
if sys.version_info < (3, 8):
launch.run_pip("install importlib-metadata", "importlib-metadata for depthmap script")
import importlib_metadata
else:
import importlib.metadata as importlib_metadata
if not launch.is_installed('packaging'):
launch.run_pip("install packaging", "packaging requirement for depthmap script")
from packaging.version import Version
def ensure(module_name, min_version=None):
if launch.is_installed(module_name):
if min_version is None or Version(importlib_metadata.version(module_name)) >= Version(min_version):
return
requirement = f'{module_name}>={min_version}' if min_version is not None else module_name
cmd = f'install "{requirement}"'
msg = f'{requirement} requirement for depthmap script'
launch.run_pip(cmd, msg)
ensure('timm', '0.9.2') # For midas, specified just in case
ensure('matplotlib')
ensure('trimesh')
ensure('numba', '0.57.0')
ensure('vispy', '0.13.0')
ensure('rembg', '2.0.50')
if not launch.is_installed("moviepy"):
launch.run_pip('install "moviepy==1.0.2"', "moviepy requirement for depthmap script")
ensure('transforms3d', '0.4.1')
ensure('imageio') # 2.4.1
try: # Dirty hack to not reinstall every time
importlib_metadata.version('imageio-ffmpeg')
except:
ensure('imageio-ffmpeg')
if not launch.is_installed("networkx"):
launch.run_pip('install install "networkx==2.5"', "networkx requirement for depthmap script")
if platform.system() == 'Windows':
ensure('pyqt5')
if platform.system() == 'Darwin':
ensure('pyqt6')