forked from aigc-apps/sd-webui-EasyPhoto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.py
91 lines (79 loc) · 3.43 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import launch
import platform
# Package check util
# Modified from https://github.com/Bing-su/adetailer/blob/main/install.py
import importlib.util
from importlib.metadata import version
from packaging.version import parse
def is_installed(package: str):
min_version = "0.0.0"
max_version = "99999999.99999999.99999999"
pkg_name = package
version_check = True
if "==" in package:
pkg_name, _version = package.split("==")
min_version = max_version = _version
elif "<=" in package:
pkg_name, _version = package.split("<=")
max_version = _version
elif ">=" in package:
pkg_name, _version = package.split(">=")
min_version = _version
else:
version_check = False
package = pkg_name
try:
spec = importlib.util.find_spec(package)
except ModuleNotFoundError:
message = f"is_installed check for {str(package)} failed as error ModuleNotFoundError"
print(message)
return False
if spec is None:
message = f"is_installed check for {str(package)} failed as 'spec is None'"
print(message)
return False
if not version_check:
return True
if package == "google.protobuf":
package = "protobuf"
try:
pkg_version = version(package)
return parse(min_version) <= parse(pkg_version) <= parse(max_version)
except Exception as e:
message = f"is_installed check for {str(package)} failed as error {str(e)}"
print(message)
return False
# End of Package check util
if not is_installed("cv2"):
print('Installing requirements for easyphoto-webui')
launch.run_pip("install opencv-python", "requirements for opencv")
if not is_installed("tensorflow-cpu"):
print('Installing requirements for easyphoto-webui')
launch.run_pip("install tensorflow-cpu", "requirements for tensorflow")
if not is_installed("onnx"):
print('Installing requirements for easyphoto-webui')
launch.run_pip("install onnx", "requirements for onnx")
if not is_installed("onnxruntime"):
print('Installing requirements for easyphoto-webui')
launch.run_pip("install onnxruntime", "requirements for onnxruntime")
if not is_installed("modelscope==1.9.3"):
print('Installing requirements for easyphoto-webui')
launch.run_pip("install modelscope==1.9.3", "requirements for modelscope")
if not is_installed("diffusers==0.18.2"):
print('Installing requirements for easyphoto-webui')
launch.run_pip("install diffusers==0.18.2", "requirements for diffusers")
if not is_installed("imageio>=2.29.0"):
print('Installing requirements for easyphoto-webui')
launch.run_pip("install imageio>=2.29.0", "requirements for imageio")
# Temporarily pin fsspec==2023.9.2. See https://github.com/huggingface/datasets/issues/6330 for details.
if not is_installed("fsspec==2023.9.2"):
print('Installing requirements for easyphoto-webui')
launch.run_pip("install fsspec==2023.9.2", "requirements for fsspec")
# `StableDiffusionXLPipeline` in diffusers requires the invisible-watermark library.
if not launch.is_installed("invisible-watermark"):
print('Installing requirements for easyphoto-webui')
launch.run_pip("install invisible-watermark", "requirements for invisible-watermark")
if platform.system() != 'Windows':
if not is_installed("nvitop"):
print('Installing requirements for easyphoto-webui')
launch.run_pip("install nvitop==1.3.0", "requirements for tensorflow")