abbiepam commited on
Commit
1c5f0cf
·
1 Parent(s): e2e9754

Upload Cheyenne-launch.py

Browse files
Files changed (1) hide show
  1. RF-modLaunch/Cheyenne-launch.py +220 -0
RF-modLaunch/Cheyenne-launch.py ADDED
@@ -0,0 +1,220 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import sys
3
+ import platform
4
+ import version
5
+ import warnings
6
+
7
+ warnings.filterwarnings("ignore", category=FutureWarning, module="insightface")
8
+ warnings.filterwarnings("ignore", category=UserWarning, module="torchvision")
9
+ warnings.filterwarnings("ignore", category=UserWarning, module="gradio")
10
+ warnings.filterwarnings("ignore", category=UserWarning, module="torchsde")
11
+ warnings.filterwarnings("ignore", category=UserWarning)
12
+
13
+ warnings.filterwarnings(
14
+ "ignore", category=UserWarning, module="torchvision.transforms.functional_tensor"
15
+ )
16
+ warnings.filterwarnings(
17
+ "ignore", category=UserWarning, message="TypedStorage is deprecated"
18
+ )
19
+
20
+ from modules.launch_util import (
21
+ is_installed,
22
+ run,
23
+ python,
24
+ run_pip,
25
+ repo_dir,
26
+ git_clone,
27
+ requirements_met,
28
+ script_path,
29
+ dir_repos,
30
+ )
31
+ from modules.util import load_file_from_url
32
+ from modules.path import (
33
+ modelfile_path,
34
+ lorafile_path,
35
+ controlnet_path,
36
+ vae_approx_path,
37
+ upscaler_path,
38
+ faceswap_path,
39
+ )
40
+
41
+ REINSTALL_ALL = False
42
+
43
+
44
+ def prepare_environment():
45
+ torch_index_url = os.environ.get(
46
+ "TORCH_INDEX_URL", "https://download.pytorch.org/whl/cu118"
47
+ )
48
+ torch_command = os.environ.get(
49
+ "TORCH_COMMAND",
50
+ f"pip install torch==2.0.1 torchvision==0.17.0 --extra-index-url {torch_index_url}",
51
+ )
52
+ insightface_package = os.environ.get(
53
+ "INSIGHTFACE_PACKAGE",
54
+ f"https://github.com/Gourieff/sd-webui-reactor/raw/main/example/insightface-0.7.3-cp310-cp310-win_amd64.whl",
55
+ )
56
+ requirements_file = os.environ.get("REQS_FILE", "requirements_versions.txt")
57
+
58
+ xformers_package = os.environ.get("XFORMERS_PACKAGE", "xformers==0.0.21")
59
+
60
+ comfy_repo = os.environ.get(
61
+ "COMFY_REPO", "https://github.com/comfyanonymous/ComfyUI"
62
+ )
63
+ comfy_commit_hash = os.environ.get(
64
+ "COMFY_COMMIT_HASH", "107e78b1cb079f652408bece8b0045927dc9f1fd"
65
+ )
66
+
67
+ print(f"Python {sys.version}")
68
+ print(f"RuinedFooocus version: {version.version}")
69
+
70
+ comfyui_name = "ComfyUI-from-StabilityAI-Official"
71
+ git_clone(comfy_repo, repo_dir(comfyui_name), "Inference Engine", comfy_commit_hash)
72
+ sys.path.append(os.path.join(script_path, dir_repos, comfyui_name))
73
+
74
+ if REINSTALL_ALL or not is_installed("torch") or not is_installed("torchvision"):
75
+ run(
76
+ f'"{python}" -m {torch_command}',
77
+ "Installing torch and torchvision",
78
+ "Couldn't install torch",
79
+ live=True,
80
+ )
81
+
82
+ if REINSTALL_ALL or not is_installed("insightface"):
83
+ if platform.system() == "Windows":
84
+ run_pip(f"install {insightface_package}", "insightace", live=True)
85
+
86
+ if REINSTALL_ALL or not is_installed("xformers"):
87
+ if platform.system() == "Windows":
88
+ if platform.python_version().startswith("3.10"):
89
+ run_pip(
90
+ f"install -U -I --no-deps {xformers_package}", "xformers", live=True
91
+ )
92
+ else:
93
+ print(
94
+ "Installation of xformers is not supported in this version of Python."
95
+ )
96
+ print(
97
+ "You can also check this and build manually: https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Xformers#building-xformers-on-windows-by-duckness"
98
+ )
99
+ if not is_installed("xformers"):
100
+ exit(0)
101
+ elif platform.system() == "Linux":
102
+ run_pip(f"install -U -I --no-deps {xformers_package}", "xformers")
103
+
104
+ if REINSTALL_ALL or not requirements_met(requirements_file):
105
+ run_pip(f'install -r "{requirements_file}"', "requirements")
106
+
107
+ return
108
+
109
+
110
+ model_filenames = [
111
+ (
112
+ "sd_xl_base_1.0_0.9vae.safetensors",
113
+ "https://civitai.com/api/download/models/231698",
114
+ ),
115
+ ]
116
+
117
+ lora_filenames = [
118
+ (
119
+ "sd_xl_offset_example-lora_1.0.safetensors",
120
+ "https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/sd_xl_offset_example-lora_1.0.safetensors",
121
+ ),
122
+ (
123
+ "lcm-lora-sdxl.safetensors",
124
+ "https://huggingface.co/latent-consistency/lcm-lora-sdxl/resolve/main/pytorch_lora_weights.safetensors",
125
+ ),
126
+ (
127
+ "lcm-lora-ssd-1b.safetensors",
128
+ "https://huggingface.co/latent-consistency/lcm-lora-ssd-1b/resolve/main/pytorch_lora_weights.safetensors",
129
+ ),
130
+ ]
131
+
132
+ vae_approx_filenames = [
133
+ (
134
+ "taesdxl_decoder",
135
+ "https://github.com/madebyollin/taesd/raw/main/taesdxl_decoder.pth",
136
+ )
137
+ ]
138
+
139
+ controlnet_filenames = [
140
+ (
141
+ "control-lora-canny-rank128.safetensors",
142
+ "https://huggingface.co/stabilityai/control-lora/resolve/main/control-LoRAs-rank128/control-lora-canny-rank128.safetensors",
143
+ ),
144
+ (
145
+ "control-lora-depth-rank128.safetensors",
146
+ "https://huggingface.co/stabilityai/control-lora/resolve/main/control-LoRAs-rank128/control-lora-depth-rank128.safetensors",
147
+ ),
148
+ (
149
+ "control-lora-recolor-rank128.safetensors",
150
+ "https://huggingface.co/stabilityai/control-lora/resolve/main/control-LoRAs-rank128/control-lora-recolor-rank128.safetensors",
151
+ ),
152
+ (
153
+ "control-lora-sketch-rank128-metadata.safetensors",
154
+ "https://huggingface.co/stabilityai/control-lora/resolve/main/control-LoRAs-rank128/control-lora-sketch-rank128-metadata.safetensors",
155
+ ),
156
+ ]
157
+
158
+ upscaler_filenames = [
159
+ (
160
+ "4x-UltraSharp.pth",
161
+ "https://huggingface.co/lokCX/4x-Ultrasharp/resolve/main/4x-UltraSharp.pth",
162
+ ),
163
+ ]
164
+
165
+ faceswap_filenames = [
166
+ (
167
+ "inswapper_128.onnx",
168
+ "https://huggingface.co/ezioruan/inswapper_128.onnx/resolve/main/inswapper_128.onnx",
169
+ ),
170
+ (
171
+ "GFPGANv1.4.pth",
172
+ "https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.4.pth",
173
+ ),
174
+ (
175
+ "detection_Resnet50_Final.pth",
176
+ "https://github.com/xinntao/facexlib/releases/download/v0.1.0/detection_Resnet50_Final.pth",
177
+ ),
178
+ (
179
+ "parsing_parsenet.pth",
180
+ "https://github.com/xinntao/facexlib/releases/download/v0.2.2/parsing_parsenet.pth",
181
+ ),
182
+ ]
183
+
184
+
185
+ def download_models():
186
+ for file_name, url in model_filenames:
187
+ load_file_from_url(url=url, model_dir=modelfile_path, file_name=file_name)
188
+ for file_name, url in lora_filenames:
189
+ load_file_from_url(url=url, model_dir=lorafile_path, file_name=file_name)
190
+ for file_name, url in controlnet_filenames:
191
+ load_file_from_url(url=url, model_dir=controlnet_path, file_name=file_name)
192
+ for file_name, url in vae_approx_filenames:
193
+ load_file_from_url(url=url, model_dir=vae_approx_path, file_name=file_name)
194
+ for file_name, url in upscaler_filenames:
195
+ load_file_from_url(url=url, model_dir=upscaler_path, file_name=file_name)
196
+ # for file_name, url in faceswap_filenames:
197
+ # load_file_from_url(url=url, model_dir=faceswap_path, file_name=file_name)
198
+ return
199
+
200
+
201
+ def clear_comfy_args():
202
+ argv = sys.argv
203
+ sys.argv = [sys.argv[0]]
204
+ import comfy.cli_args
205
+
206
+ sys.argv = argv
207
+
208
+
209
+ def cuda_malloc():
210
+ import cuda_malloc
211
+
212
+
213
+ prepare_environment()
214
+
215
+ clear_comfy_args()
216
+ # cuda_malloc()
217
+
218
+ download_models()
219
+
220
+ from webui import *