r3gm commited on
Commit
e522f71
1 Parent(s): 4d83375

Upload 4 files

Browse files
Files changed (4) hide show
  1. README.md +14 -4
  2. app.py +913 -0
  3. packages.txt +3 -0
  4. requirements.txt +4 -0
README.md CHANGED
@@ -1,4 +1,14 @@
1
- ---
2
- license: mit
3
- title: DiffuseCraft
4
- ---
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: 🧩 DiffuseCraft
3
+ emoji: 🧩🖼️
4
+ colorFrom: red
5
+ colorTo: pink
6
+ sdk: gradio
7
+ sdk_version: 4.28.3
8
+ app_file: app.py
9
+ pinned: true
10
+ license: mit
11
+ short_description: Stunning images using stable diffusion.
12
+ ---
13
+
14
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,913 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ task_stablepy = {
2
+ 'txt2img': 'txt2img',
3
+ 'img2img': 'img2img',
4
+ 'inpaint': 'inpaint',
5
+ 'sd_openpose ControlNet': 'openpose',
6
+ 'sd_canny ControlNet': 'canny',
7
+ 'sd_mlsd ControlNet': 'mlsd',
8
+ 'sd_scribble ControlNet': 'scribble',
9
+ 'sd_softedge ControlNet': 'softedge',
10
+ 'sd_segmentation ControlNet': 'segmentation',
11
+ 'sd_depth ControlNet': 'depth',
12
+ 'sd_normalbae ControlNet': 'normalbae',
13
+ 'sd_lineart ControlNet': 'lineart',
14
+ 'sd_lineart_anime ControlNet': 'lineart_anime',
15
+ 'sd_shuffle ControlNet': 'shuffle',
16
+ 'sd_ip2p ControlNet': 'ip2p',
17
+ 'sdxl_canny T2I Adapter': 'sdxl_canny',
18
+ 'sdxl_sketch T2I Adapter': 'sdxl_sketch',
19
+ 'sdxl_lineart T2I Adapter': 'sdxl_lineart',
20
+ 'sdxl_depth-midas T2I Adapter': 'sdxl_depth-midas',
21
+ 'sdxl_openpose T2I Adapter': 'sdxl_openpose'
22
+ }
23
+
24
+ task_model_list = list(task_stablepy.keys())
25
+
26
+ #######################
27
+ # UTILS
28
+ #######################
29
+ import spaces
30
+ import os
31
+ from stablepy import Model_Diffusers
32
+ from stablepy.diffusers_vanilla.model import scheduler_names
33
+ from stablepy.diffusers_vanilla.style_prompt_config import STYLE_NAMES
34
+ import torch
35
+ import re
36
+
37
+ preprocessor_controlnet = {
38
+ "openpose": [
39
+ "Openpose",
40
+ "None",
41
+ ],
42
+ "scribble": [
43
+ "HED",
44
+ "Pidinet",
45
+ "None",
46
+ ],
47
+ "softedge": [
48
+ "Pidinet",
49
+ "HED",
50
+ "HED safe",
51
+ "Pidinet safe",
52
+ "None",
53
+ ],
54
+ "segmentation": [
55
+ "UPerNet",
56
+ "None",
57
+ ],
58
+ "depth": [
59
+ "DPT",
60
+ "Midas",
61
+ "None",
62
+ ],
63
+ "normalbae": [
64
+ "NormalBae",
65
+ "None",
66
+ ],
67
+ "lineart": [
68
+ "Lineart",
69
+ "Lineart coarse",
70
+ "LineartAnime",
71
+ "None",
72
+ "None (anime)",
73
+ ],
74
+ "shuffle": [
75
+ "ContentShuffle",
76
+ "None",
77
+ ],
78
+ "canny": [
79
+ "Canny"
80
+ ],
81
+ "mlsd": [
82
+ "MLSD"
83
+ ],
84
+ "ip2p": [
85
+ "ip2p"
86
+ ]
87
+ }
88
+
89
+
90
+ def download_things(directory, url, hf_token="", civitai_api_key=""):
91
+ url = url.strip()
92
+
93
+ if "drive.google.com" in url:
94
+ original_dir = os.getcwd()
95
+ os.chdir(directory)
96
+ os.system(f"gdown --fuzzy {url}")
97
+ os.chdir(original_dir)
98
+ elif "huggingface.co" in url:
99
+ url = url.replace("?download=true", "")
100
+ if "/blob/" in url:
101
+ url = url.replace("/blob/", "/resolve/")
102
+ user_header = f'"Authorization: Bearer {hf_token}"'
103
+ if hf_token:
104
+ os.system(f"aria2c --console-log-level=error --summary-interval=10 --header={user_header} -c -x 16 -k 1M -s 16 {url} -d {directory} -o {url.split('/')[-1]}")
105
+ else:
106
+ os.system (f"aria2c --optimize-concurrent-downloads --console-log-level=error --summary-interval=10 -c -x 16 -k 1M -s 16 {url} -d {directory} -o {url.split('/')[-1]}")
107
+ elif "civitai.com" in url:
108
+ if "?" in url:
109
+ url = url.split("?")[0]
110
+ if civitai_api_key:
111
+ url = url + f"?token={civitai_api_key}"
112
+ os.system(f"aria2c --console-log-level=error --summary-interval=10 -c -x 16 -k 1M -s 16 -d {directory} {url}")
113
+ else:
114
+ print("\033[91mYou need an API key to download Civitai models.\033[0m")
115
+ else:
116
+ os.system(f"aria2c --console-log-level=error --summary-interval=10 -c -x 16 -k 1M -s 16 -d {directory} {url}")
117
+
118
+
119
+ def get_model_list(directory_path):
120
+ model_list = []
121
+ valid_extensions = {'.ckpt' , '.pt', '.pth', '.safetensors', '.bin'}
122
+
123
+ for filename in os.listdir(directory_path):
124
+ if os.path.splitext(filename)[1] in valid_extensions:
125
+ name_without_extension = os.path.splitext(filename)[0]
126
+ file_path = os.path.join(directory_path, filename)
127
+ # model_list.append((name_without_extension, file_path))
128
+ model_list.append(file_path)
129
+ print('\033[34mFILE: ' + file_path + '\033[0m')
130
+ return model_list
131
+
132
+
133
+ def process_string(input_string):
134
+ parts = input_string.split('/')
135
+
136
+ if len(parts) == 2:
137
+ first_element = parts[1]
138
+ complete_string = input_string
139
+ result = (first_element, complete_string)
140
+ return result
141
+ else:
142
+ return None
143
+
144
+
145
+ directory_models = 'models'
146
+ os.makedirs(directory_models, exist_ok=True)
147
+ directory_loras = 'loras'
148
+ os.makedirs(directory_loras, exist_ok=True)
149
+ directory_vaes = 'vaes'
150
+ os.makedirs(directory_vaes, exist_ok=True)
151
+
152
+ # - **Download SD 1.5 Models**
153
+ download_model = "https://huggingface.co/frankjoshua/toonyou_beta6/resolve/main/toonyou_beta6.safetensors"
154
+ # - **Download VAEs**
155
+ download_vae = "https://huggingface.co/fp16-guy/anything_kl-f8-anime2_vae-ft-mse-840000-ema-pruned_blessed_clearvae_fp16_cleaned/resolve/main/anything_fp16.safetensors"
156
+ # - **Download LoRAs**
157
+ download_lora = "https://civitai.com/api/download/models/97655, https://civitai.com/api/download/models/124358"
158
+ load_diffusers_format_model = ['runwayml/stable-diffusion-v1-5', 'stabilityai/stable-diffusion-xl-base-1.0']
159
+ CIVITAI_API_KEY = ""
160
+ hf_token = ""
161
+
162
+ # Download stuffs
163
+ for url in [url.strip() for url in download_model.split(',')]:
164
+ if not os.path.exists(f"./models/{url.split('/')[-1]}"):
165
+ download_things(directory_models, url, hf_token, CIVITAI_API_KEY)
166
+ for url in [url.strip() for url in download_vae.split(',')]:
167
+ if not os.path.exists(f"./vaes/{url.split('/')[-1]}"):
168
+ download_things(directory_vaes, url, hf_token, CIVITAI_API_KEY)
169
+ for url in [url.strip() for url in download_lora.split(',')]:
170
+ if not os.path.exists(f"./loras/{url.split('/')[-1]}"):
171
+ download_things(directory_loras, url, hf_token, CIVITAI_API_KEY)
172
+
173
+ # Download Embeddings
174
+ directory_embeds = 'embedings'
175
+ os.makedirs(directory_embeds, exist_ok=True)
176
+ download_embeds = [
177
+ 'https://huggingface.co/datasets/Nerfgun3/bad_prompt/resolve/main/bad_prompt.pt',
178
+ 'https://huggingface.co/datasets/Nerfgun3/bad_prompt/blob/main/bad_prompt_version2.pt',
179
+ 'https://huggingface.co/embed/EasyNegative/resolve/main/EasyNegative.safetensors',
180
+ 'https://huggingface.co/embed/negative/resolve/main/EasyNegativeV2.safetensors',
181
+ 'https://huggingface.co/embed/negative/resolve/main/bad-hands-5.pt',
182
+ 'https://huggingface.co/embed/negative/resolve/main/bad-artist.pt',
183
+ 'https://huggingface.co/embed/negative/resolve/main/ng_deepnegative_v1_75t.pt',
184
+ 'https://huggingface.co/embed/negative/resolve/main/bad-artist-anime.pt',
185
+ 'https://huggingface.co/embed/negative/resolve/main/bad-image-v2-39000.pt',
186
+ 'https://huggingface.co/embed/negative/resolve/main/verybadimagenegative_v1.3.pt',
187
+ ]
188
+
189
+ for url_embed in download_embeds:
190
+ if not os.path.exists(f"./embedings/{url_embed.split('/')[-1]}"):
191
+ download_things(directory_embeds, url_embed, hf_token, CIVITAI_API_KEY)
192
+
193
+ # Build list models
194
+ embed_list = get_model_list(directory_embeds)
195
+ model_list = get_model_list(directory_models)
196
+ model_list = model_list + load_diffusers_format_model
197
+ lora_model_list = get_model_list(directory_loras)
198
+ lora_model_list.insert(0, "None")
199
+ vae_model_list = get_model_list(directory_vaes)
200
+ vae_model_list.insert(0, "None")
201
+
202
+ print('\033[33m🏁 Download and listing of valid models completed.\033[0m')
203
+
204
+ upscaler_dict_gui = {
205
+ None : None,
206
+ "Lanczos" : "Lanczos",
207
+ "Nearest" : "Nearest",
208
+ "RealESRGAN_x4plus" : "https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth",
209
+ "RealESRNet_x4plus" : "https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.1/RealESRNet_x4plus.pth",
210
+ "RealESRGAN_x4plus_anime_6B": "https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.4/RealESRGAN_x4plus_anime_6B.pth",
211
+ "RealESRGAN_x2plus": "https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.1/RealESRGAN_x2plus.pth",
212
+ "realesr-animevideov3": "https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-animevideov3.pth",
213
+ "realesr-general-x4v3": "https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-general-x4v3.pth",
214
+ "realesr-general-wdn-x4v3" : "https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-general-wdn-x4v3.pth",
215
+ "4x-UltraSharp" : "https://huggingface.co/Shandypur/ESRGAN-4x-UltraSharp/resolve/main/4x-UltraSharp.pth",
216
+ "4x_foolhardy_Remacri" : "https://huggingface.co/FacehugmanIII/4x_foolhardy_Remacri/resolve/main/4x_foolhardy_Remacri.pth",
217
+ "Remacri4xExtraSmoother" : "https://huggingface.co/hollowstrawberry/upscalers-backup/resolve/main/ESRGAN/Remacri%204x%20ExtraSmoother.pth",
218
+ "AnimeSharp4x" : "https://huggingface.co/hollowstrawberry/upscalers-backup/resolve/main/ESRGAN/AnimeSharp%204x.pth",
219
+ "lollypop" : "https://huggingface.co/hollowstrawberry/upscalers-backup/resolve/main/ESRGAN/lollypop.pth",
220
+ "RealisticRescaler4x" : "https://huggingface.co/hollowstrawberry/upscalers-backup/resolve/main/ESRGAN/RealisticRescaler%204x.pth",
221
+ "NickelbackFS4x" : "https://huggingface.co/hollowstrawberry/upscalers-backup/resolve/main/ESRGAN/NickelbackFS%204x.pth"
222
+ }
223
+
224
+
225
+ def extract_parameters(input_string):
226
+ parameters = {}
227
+ input_string = input_string.replace("\n", "")
228
+
229
+ if not "Negative prompt:" in input_string:
230
+ print("Negative prompt not detected")
231
+ parameters["prompt"] = input_string
232
+ return parameters
233
+
234
+ parm = input_string.split("Negative prompt:")
235
+ parameters["prompt"] = parm[0]
236
+ if not "Steps:" in parm[1]:
237
+ print("Steps not detected")
238
+ parameters["neg_prompt"] = parm[1]
239
+ return parameters
240
+ parm = parm[1].split("Steps:")
241
+ parameters["neg_prompt"] = parm[0]
242
+ input_string = "Steps:" + parm[1]
243
+
244
+ # Extracting Steps
245
+ steps_match = re.search(r'Steps: (\d+)', input_string)
246
+ if steps_match:
247
+ parameters['Steps'] = int(steps_match.group(1))
248
+
249
+ # Extracting Size
250
+ size_match = re.search(r'Size: (\d+x\d+)', input_string)
251
+ if size_match:
252
+ parameters['Size'] = size_match.group(1)
253
+ width, height = map(int, parameters['Size'].split('x'))
254
+ parameters['width'] = width
255
+ parameters['height'] = height
256
+
257
+ # Extracting other parameters
258
+ other_parameters = re.findall(r'(\w+): (.*?)(?=, \w+|$)', input_string)
259
+ for param in other_parameters:
260
+ parameters[param[0]] = param[1].strip('"')
261
+
262
+ return parameters
263
+
264
+
265
+ #######################
266
+ # GUI
267
+ #######################
268
+ import spaces
269
+ import gradio as gr
270
+ from PIL import Image
271
+ import IPython.display
272
+ import time, json
273
+ from IPython.utils import capture
274
+ import logging
275
+ logging.getLogger("diffusers").setLevel(logging.ERROR)
276
+ import diffusers
277
+ diffusers.utils.logging.set_verbosity(40)
278
+ import warnings
279
+ warnings.filterwarnings(action="ignore", category=FutureWarning, module="diffusers")
280
+ warnings.filterwarnings(action="ignore", category=UserWarning, module="diffusers")
281
+ warnings.filterwarnings(action="ignore", category=FutureWarning, module="transformers")
282
+ from stablepy import logger
283
+ logger.setLevel(logging.DEBUG)
284
+
285
+
286
+ class GuiSD:
287
+ def __init__(self):
288
+ self.model = None
289
+
290
+ @spaces.GPU
291
+ def infer(self, model, pipe_params):
292
+ images, image_list = model(**pipe_params)
293
+ return images
294
+
295
+ # @spaces.GPU
296
+ def generate_pipeline(
297
+ self,
298
+ prompt,
299
+ neg_prompt,
300
+ num_images,
301
+ steps,
302
+ cfg,
303
+ clip_skip,
304
+ seed,
305
+ lora1,
306
+ lora_scale1,
307
+ lora2,
308
+ lora_scale2,
309
+ lora3,
310
+ lora_scale3,
311
+ lora4,
312
+ lora_scale4,
313
+ lora5,
314
+ lora_scale5,
315
+ sampler,
316
+ img_height,
317
+ img_width,
318
+ model_name,
319
+ vae_model,
320
+ task,
321
+ image_control,
322
+ preprocessor_name,
323
+ preprocess_resolution,
324
+ image_resolution,
325
+ style_prompt, # list []
326
+ style_json_file,
327
+ image_mask,
328
+ strength,
329
+ low_threshold,
330
+ high_threshold,
331
+ value_threshold,
332
+ distance_threshold,
333
+ controlnet_output_scaling_in_unet,
334
+ controlnet_start_threshold,
335
+ controlnet_stop_threshold,
336
+ textual_inversion,
337
+ syntax_weights,
338
+ loop_generation,
339
+ leave_progress_bar,
340
+ disable_progress_bar,
341
+ image_previews,
342
+ display_images,
343
+ save_generated_images,
344
+ image_storage_location,
345
+ retain_compel_previous_load,
346
+ retain_detailfix_model_previous_load,
347
+ retain_hires_model_previous_load,
348
+ t2i_adapter_preprocessor,
349
+ t2i_adapter_conditioning_scale,
350
+ t2i_adapter_conditioning_factor,
351
+ upscaler_model_path,
352
+ upscaler_increases_size,
353
+ esrgan_tile,
354
+ esrgan_tile_overlap,
355
+ hires_steps,
356
+ hires_denoising_strength,
357
+ hires_sampler,
358
+ hires_prompt,
359
+ hires_negative_prompt,
360
+ hires_before_adetailer,
361
+ hires_after_adetailer,
362
+ xformers_memory_efficient_attention,
363
+ freeu,
364
+ generator_in_cpu,
365
+ adetailer_inpaint_only,
366
+ adetailer_verbose,
367
+ adetailer_sampler,
368
+ adetailer_active_a,
369
+ prompt_ad_a,
370
+ negative_prompt_ad_a,
371
+ strength_ad_a,
372
+ face_detector_ad_a,
373
+ person_detector_ad_a,
374
+ hand_detector_ad_a,
375
+ mask_dilation_a,
376
+ mask_blur_a,
377
+ mask_padding_a,
378
+ adetailer_active_b,
379
+ prompt_ad_b,
380
+ negative_prompt_ad_b,
381
+ strength_ad_b,
382
+ face_detector_ad_b,
383
+ person_detector_ad_b,
384
+ hand_detector_ad_b,
385
+ mask_dilation_b,
386
+ mask_blur_b,
387
+ mask_padding_b,
388
+ ):
389
+
390
+ task = task_stablepy[task]
391
+
392
+ # First load
393
+ model_precision = torch.float16
394
+ if not self.model:
395
+ from stablepy import Model_Diffusers
396
+
397
+ print("Loading model...")
398
+ self.model = Model_Diffusers(
399
+ base_model_id=model_name,
400
+ task_name=task,
401
+ vae_model=vae_model if vae_model != "None" else None,
402
+ type_model_precision=model_precision
403
+ )
404
+
405
+ self.model.load_pipe(
406
+ model_name,
407
+ task_name=task,
408
+ vae_model=vae_model if vae_model != "None" else None,
409
+ type_model_precision=model_precision
410
+ )
411
+
412
+ if task != "txt2img" and not image_control:
413
+ raise ValueError("No control image found: To use this function, you have to upload an image in 'Image ControlNet/Inpaint/Img2img'")
414
+
415
+ if task == "inpaint" and not image_mask:
416
+ raise ValueError("No mask image found: Specify one in 'Image Mask'")
417
+
418
+ if upscaler_model_path in [None, "Lanczos", "Nearest"]:
419
+ upscaler_model = upscaler_model_path
420
+ else:
421
+ directory_upscalers = 'upscalers'
422
+ os.makedirs(directory_upscalers, exist_ok=True)
423
+
424
+ url_upscaler = upscaler_dict_gui[upscaler_model_path]
425
+
426
+ if not os.path.exists(f"./upscalers/{url_upscaler.split('/')[-1]}"):
427
+ download_things(directory_upscalers, url_upscaler, hf_token)
428
+
429
+ upscaler_model = f"./upscalers/{url_upscaler.split('/')[-1]}"
430
+
431
+ if textual_inversion and self.model.class_name == "StableDiffusionXLPipeline":
432
+ print("No Textual inversion for SDXL")
433
+
434
+ logging.getLogger("ultralytics").setLevel(logging.INFO if adetailer_verbose else logging.ERROR)
435
+
436
+ adetailer_params_A = {
437
+ "face_detector_ad" : face_detector_ad_a,
438
+ "person_detector_ad" : person_detector_ad_a,
439
+ "hand_detector_ad" : hand_detector_ad_a,
440
+ "prompt": prompt_ad_a,
441
+ "negative_prompt" : negative_prompt_ad_a,
442
+ "strength" : strength_ad_a,
443
+ # "image_list_task" : None,
444
+ "mask_dilation" : mask_dilation_a,
445
+ "mask_blur" : mask_blur_a,
446
+ "mask_padding" : mask_padding_a,
447
+ "inpaint_only" : adetailer_inpaint_only,
448
+ "sampler" : adetailer_sampler,
449
+ }
450
+
451
+ adetailer_params_B = {
452
+ "face_detector_ad" : face_detector_ad_b,
453
+ "person_detector_ad" : person_detector_ad_b,
454
+ "hand_detector_ad" : hand_detector_ad_b,
455
+ "prompt": prompt_ad_b,
456
+ "negative_prompt" : negative_prompt_ad_b,
457
+ "strength" : strength_ad_b,
458
+ # "image_list_task" : None,
459
+ "mask_dilation" : mask_dilation_b,
460
+ "mask_blur" : mask_blur_b,
461
+ "mask_padding" : mask_padding_b,
462
+ }
463
+ pipe_params = {
464
+ "prompt": prompt,
465
+ "negative_prompt": neg_prompt,
466
+ "img_height": img_height,
467
+ "img_width": img_width,
468
+ "num_images": num_images,
469
+ "num_steps": steps,
470
+ "guidance_scale": cfg,
471
+ "clip_skip": clip_skip,
472
+ "seed": seed,
473
+ "image": image_control,
474
+ "preprocessor_name": preprocessor_name,
475
+ "preprocess_resolution": preprocess_resolution,
476
+ "image_resolution": image_resolution,
477
+ "style_prompt": style_prompt if style_prompt else "",
478
+ "style_json_file": "",
479
+ "image_mask": image_mask, # only for Inpaint
480
+ "strength": strength, # only for Inpaint or ...
481
+ "low_threshold": low_threshold,
482
+ "high_threshold": high_threshold,
483
+ "value_threshold": value_threshold,
484
+ "distance_threshold": distance_threshold,
485
+ "lora_A": lora1 if lora1 != "None" else None,
486
+ "lora_scale_A": lora_scale1,
487
+ "lora_B": lora2 if lora2 != "None" else None,
488
+ "lora_scale_B": lora_scale2,
489
+ "lora_C": lora3 if lora3 != "None" else None,
490
+ "lora_scale_C": lora_scale3,
491
+ "lora_D": lora4 if lora4 != "None" else None,
492
+ "lora_scale_D": lora_scale4,
493
+ "lora_E": lora5 if lora5 != "None" else None,
494
+ "lora_scale_E": lora_scale5,
495
+ "textual_inversion": embed_list if textual_inversion and self.model.class_name != "StableDiffusionXLPipeline" else [],
496
+ "syntax_weights": syntax_weights, # "Classic"
497
+ "sampler": sampler,
498
+ "xformers_memory_efficient_attention": xformers_memory_efficient_attention,
499
+ "gui_active": True,
500
+ "loop_generation": loop_generation,
501
+ "controlnet_conditioning_scale": float(controlnet_output_scaling_in_unet),
502
+ "control_guidance_start": float(controlnet_start_threshold),
503
+ "control_guidance_end": float(controlnet_stop_threshold),
504
+ "generator_in_cpu": generator_in_cpu,
505
+ "FreeU": freeu,
506
+ "adetailer_A": adetailer_active_a,
507
+ "adetailer_A_params": adetailer_params_A,
508
+ "adetailer_B": adetailer_active_b,
509
+ "adetailer_B_params": adetailer_params_B,
510
+ "leave_progress_bar": leave_progress_bar,
511
+ "disable_progress_bar": disable_progress_bar,
512
+ "image_previews": image_previews,
513
+ "display_images": display_images,
514
+ "save_generated_images": save_generated_images,
515
+ "image_storage_location": image_storage_location,
516
+ "retain_compel_previous_load": retain_compel_previous_load,
517
+ "retain_detailfix_model_previous_load": retain_detailfix_model_previous_load,
518
+ "retain_hires_model_previous_load": retain_hires_model_previous_load,
519
+ "t2i_adapter_preprocessor": t2i_adapter_preprocessor,
520
+ "t2i_adapter_conditioning_scale": float(t2i_adapter_conditioning_scale),
521
+ "t2i_adapter_conditioning_factor": float(t2i_adapter_conditioning_factor),
522
+ "upscaler_model_path": upscaler_model,
523
+ "upscaler_increases_size": upscaler_increases_size,
524
+ "esrgan_tile": esrgan_tile,
525
+ "esrgan_tile_overlap": esrgan_tile_overlap,
526
+ "hires_steps": hires_steps,
527
+ "hires_denoising_strength": hires_denoising_strength,
528
+ "hires_prompt": hires_prompt,
529
+ "hires_negative_prompt": hires_negative_prompt,
530
+ "hires_sampler": hires_sampler,
531
+ "hires_before_adetailer": hires_before_adetailer,
532
+ "hires_after_adetailer": hires_after_adetailer
533
+ }
534
+
535
+ # print(pipe_params)
536
+
537
+ return self.infer(self.model, pipe_params)
538
+
539
+
540
+ sd_gen = GuiSD()
541
+
542
+ title_tab_one = "<h2 style='color: #2C5F2D;'>SD Interactive</h2>"
543
+ title_tab_adetailer = "<h2 style='color: #97BC62;'>Adetailer</h2>"
544
+ title_tab_hires = "<h2 style='color: #97BC62;'>High-resolution</h2>"
545
+ title_tab_settings = "<h2 style='color: #97BC62;'>Settings</h2>"
546
+
547
+ CSS ="""
548
+ .contain { display: flex; flex-direction: column; }
549
+ #component-0 { height: 100%; }
550
+ #gallery { flex-grow: 1; }
551
+ """
552
+
553
+ with gr.Blocks(theme="NoCrypt/miku", css=CSS) as app:
554
+ gr.Markdown("# 🧩 DiffuseCraft")
555
+ gr.Markdown(
556
+ f"""
557
+ ### This demo uses [diffusers](https://github.com/huggingface/diffusers) to perform different tasks in image generation.
558
+ """
559
+ )
560
+ with gr.Tab("Generation"):
561
+ with gr.Row():
562
+
563
+ with gr.Column(scale=2):
564
+ task_gui = gr.Dropdown(label="Task", choices=task_model_list, value=task_model_list[0])
565
+ model_name_gui = gr.Dropdown(label="Model", choices=model_list, value=model_list[0], allow_custom_value=True)
566
+ prompt_gui = gr.Textbox(lines=5, placeholder="Enter prompt")
567
+ neg_prompt_gui = gr.Textbox(lines=3, placeholder="Enter Neg prompt")
568
+ generate_button = gr.Button(value="GENERATE", variant="primary")
569
+
570
+ result_images = gr.Gallery(
571
+ label="Generated images",
572
+ show_label=False,
573
+ elem_id="gallery",
574
+ columns=[2],
575
+ rows=[3],
576
+ object_fit="contain",
577
+ # height="auto",
578
+ interactive=False,
579
+ preview=True,
580
+ selected_index=50,
581
+ )
582
+
583
+ with gr.Column(scale=1):
584
+ steps_gui = gr.Slider(minimum=1, maximum=100, step=1, value=30, label="Steps")
585
+ cfg_gui = gr.Slider(minimum=0, maximum=30, step=0.5, value=7.5, label="CFG")
586
+ sampler_gui = gr.Dropdown(label="Sampler", choices=scheduler_names, value="Euler a")
587
+ img_height_gui = gr.Slider(minimum=64, maximum=4096, step=8, value=1024, label="Img Height")
588
+ img_width_gui = gr.Slider(minimum=64, maximum=4096, step=8, value=1024, label="Img Width")
589
+ clip_skip_gui = gr.Checkbox(value=True, label="Layer 2 Clip Skip")
590
+ free_u_gui = gr.Checkbox(value=True, label="FreeU")
591
+ seed_gui = gr.Number(minimum=-1, maximum=9999999999, value=-1, label="Seed")
592
+ num_images_gui = gr.Slider(minimum=1, maximum=16, step=1, value=1, label="Images")
593
+ prompt_s_options = [("Compel (default) format: (word)weight", "Compel"), ("Classic (sd1.5 long prompts) format: (word:weight)", "Classic")]
594
+ prompt_syntax_gui = gr.Dropdown(label="Prompt Syntax", choices=prompt_s_options, value=prompt_s_options[0][1])
595
+ vae_model_gui = gr.Dropdown(label="VAE Model", choices=vae_model_list)
596
+
597
+ with gr.Accordion("ControlNet / Img2img / Inpaint", open=False, visible=True):
598
+ image_control = gr.Image(label="Image ControlNet/Inpaint/Img2img", type="filepath")
599
+ image_mask_gui = gr.Image(label="Image Mask", type="filepath")
600
+ strength_gui = gr.Slider(minimum=0.01, maximum=1.0, step=0.01, value=0.35, label="Strength")
601
+ image_resolution_gui = gr.Slider(minimum=64, maximum=2048, step=64, value=1024, label="Image Resolution")
602
+ preprocessor_name_gui = gr.Dropdown(label="Preprocessor Name", choices=preprocessor_controlnet["canny"])
603
+
604
+ def change_preprocessor_choices(task):
605
+ if task in preprocessor_controlnet.keys():
606
+ choices_task = preprocessor_controlnet[task]
607
+ else:
608
+ choices_task = preprocessor_controlnet["canny"]
609
+ return gr.update(choices=choices_task, value=choices_task[0])
610
+
611
+ task_gui.change(
612
+ change_preprocessor_choices,
613
+ [task_gui],
614
+ [preprocessor_name_gui],
615
+ )
616
+ preprocess_resolution_gui = gr.Slider(minimum=64, maximum=2048, step=64, value=512, label="Preprocess Resolution")
617
+ low_threshold_gui = gr.Slider(minimum=1, maximum=255, step=1, value=100, label="Canny low threshold")
618
+ high_threshold_gui = gr.Slider(minimum=1, maximum=255, step=1, value=200, label="Canny high threshold")
619
+ value_threshold_gui = gr.Slider(minimum=1, maximum=2.0, step=0.01, value=0.1, label="Hough value threshold (MLSD)")
620
+ distance_threshold_gui = gr.Slider(minimum=1, maximum=20.0, step=0.01, value=0.1, label="Hough distance threshold (MLSD)")
621
+ control_net_output_scaling_gui = gr.Slider(minimum=0, maximum=5.0, step=0.1, value=1, label="ControlNet Output Scaling in UNet")
622
+ control_net_start_threshold_gui = gr.Slider(minimum=0, maximum=1, step=0.01, value=0, label="ControlNet Start Threshold (%)")
623
+ control_net_stop_threshold_gui = gr.Slider(minimum=0, maximum=1, step=0.01, value=1, label="ControlNet Stop Threshold (%)")
624
+
625
+ with gr.Accordion("T2I adapter", open=False, visible=True):
626
+ t2i_adapter_preprocessor_gui = gr.Checkbox(value=True, label="T2i Adapter Preprocessor")
627
+ adapter_conditioning_scale_gui = gr.Slider(minimum=0, maximum=5., step=0.1, value=1, label="Adapter Conditioning Scale")
628
+ adapter_conditioning_factor_gui = gr.Slider(minimum=0, maximum=1., step=0.01, value=0.55, label="Adapter Conditioning Factor (%)")
629
+
630
+ with gr.Accordion("LoRA", open=False, visible=False):
631
+ lora1_gui = gr.Dropdown(label="Lora1", choices=lora_model_list)
632
+ lora_scale_1_gui = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1, label="Lora Scale 1")
633
+ lora2_gui = gr.Dropdown(label="Lora2", choices=lora_model_list)
634
+ lora_scale_2_gui = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1, label="Lora Scale 2")
635
+ lora3_gui = gr.Dropdown(label="Lora3", choices=lora_model_list)
636
+ lora_scale_3_gui = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1, label="Lora Scale 3")
637
+ lora4_gui = gr.Dropdown(label="Lora4", choices=lora_model_list)
638
+ lora_scale_4_gui = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1, label="Lora Scale 4")
639
+ lora5_gui = gr.Dropdown(label="Lora5", choices=lora_model_list)
640
+ lora_scale_5_gui = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1, label="Lora Scale 5")
641
+
642
+ with gr.Accordion("Styles", open=False, visible=True):
643
+
644
+ try:
645
+ style_names_found = sd_gen.model.STYLE_NAMES
646
+ except:
647
+ style_names_found = STYLE_NAMES
648
+
649
+ style_prompt_gui = gr.Dropdown(
650
+ style_names_found,
651
+ multiselect=True,
652
+ value=None,
653
+ label="Style Prompt",
654
+ interactive=True,
655
+ )
656
+ style_json_gui = gr.File(label="Style JSON File")
657
+ style_button = gr.Button("Load styles")
658
+
659
+ def load_json_style_file(json):
660
+ if not sd_gen.model:
661
+ gr.Info("First load the model")
662
+ return gr.update(value=None, choices=STYLE_NAMES)
663
+
664
+ sd_gen.model.load_style_file(json)
665
+ gr.Info(f"{len(sd_gen.model.STYLE_NAMES)} styles loaded")
666
+ return gr.update(value=None, choices=sd_gen.model.STYLE_NAMES)
667
+
668
+ style_button.click(load_json_style_file, [style_json_gui], [style_prompt_gui])
669
+
670
+ with gr.Accordion("Textual inversion", open=False, visible=False):
671
+ active_textual_inversion_gui = gr.Checkbox(value=False, label="Active Textual Inversion in prompt")
672
+
673
+ with gr.Accordion("Hires fix", open=False, visible=False):
674
+
675
+ upscaler_keys = list(upscaler_dict_gui.keys())
676
+
677
+ upscaler_model_path_gui = gr.Dropdown(label="Upscaler", choices=upscaler_keys, value=upscaler_keys[0])
678
+ upscaler_increases_size_gui = gr.Slider(minimum=1.1, maximum=6., step=0.1, value=1.5, label="Upscale by")
679
+ esrgan_tile_gui = gr.Slider(minimum=0, value=100, maximum=500, step=1, label="ESRGAN Tile")
680
+ esrgan_tile_overlap_gui = gr.Slider(minimum=1, maximum=200, step=1, value=10, label="ESRGAN Tile Overlap")
681
+ hires_steps_gui = gr.Slider(minimum=0, value=30, maximum=100, step=1, label="Hires Steps")
682
+ hires_denoising_strength_gui = gr.Slider(minimum=0.1, maximum=1.0, step=0.01, value=0.55, label="Hires Denoising Strength")
683
+ hires_sampler_gui = gr.Dropdown(label="Hires Sampler", choices=["Use same sampler"] + scheduler_names[:-1], value="Use same sampler")
684
+ hires_prompt_gui = gr.Textbox(label="Hires Prompt", placeholder="Main prompt will be use", lines=3)
685
+ hires_negative_prompt_gui = gr.Textbox(label="Hires Negative Prompt", placeholder="Main negative prompt will be use", lines=3)
686
+
687
+ with gr.Accordion("Detailfix", open=False, visible=False):
688
+
689
+ # Adetailer Inpaint Only
690
+ adetailer_inpaint_only_gui = gr.Checkbox(label="Inpaint only", value=True)
691
+
692
+ # Adetailer Verbose
693
+ adetailer_verbose_gui = gr.Checkbox(label="Verbose", value=False)
694
+
695
+ # Adetailer Sampler
696
+ adetailer_sampler_options = ["Use same sampler"] + scheduler_names[:-1]
697
+ adetailer_sampler_gui = gr.Dropdown(label="Adetailer sampler:", choices=adetailer_sampler_options, value="Use same sampler")
698
+
699
+ with gr.Accordion("Detailfix A", open=False, visible=True):
700
+ # Adetailer A
701
+ adetailer_active_a_gui = gr.Checkbox(label="Enable Adetailer A", value=False)
702
+ prompt_ad_a_gui = gr.Textbox(label="Main prompt", placeholder="Main prompt will be use", lines=3)
703
+ negative_prompt_ad_a_gui = gr.Textbox(label="Negative prompt", placeholder="Main negative prompt will be use", lines=3)
704
+ strength_ad_a_gui = gr.Number(label="Strength:", value=0.35, step=0.01, minimum=0.01, maximum=1.0)
705
+ face_detector_ad_a_gui = gr.Checkbox(label="Face detector", value=True)
706
+ person_detector_ad_a_gui = gr.Checkbox(label="Person detector", value=True)
707
+ hand_detector_ad_a_gui = gr.Checkbox(label="Hand detector", value=False)
708
+ mask_dilation_a_gui = gr.Number(label="Mask dilation:", value=4, minimum=1)
709
+ mask_blur_a_gui = gr.Number(label="Mask blur:", value=4, minimum=1)
710
+ mask_padding_a_gui = gr.Number(label="Mask padding:", value=32, minimum=1)
711
+
712
+ with gr.Accordion("Detailfix B", open=False, visible=True):
713
+ # Adetailer B
714
+ adetailer_active_b_gui = gr.Checkbox(label="Enable Adetailer B", value=False)
715
+ prompt_ad_b_gui = gr.Textbox(label="Main prompt", placeholder="Main prompt will be use", lines=3)
716
+ negative_prompt_ad_b_gui = gr.Textbox(label="Negative prompt", placeholder="Main negative prompt will be use", lines=3)
717
+ strength_ad_b_gui = gr.Number(label="Strength:", value=0.35, step=0.01, minimum=0.01, maximum=1.0)
718
+ face_detector_ad_b_gui = gr.Checkbox(label="Face detector", value=True)
719
+ person_detector_ad_b_gui = gr.Checkbox(label="Person detector", value=True)
720
+ hand_detector_ad_b_gui = gr.Checkbox(label="Hand detector", value=False)
721
+ mask_dilation_b_gui = gr.Number(label="Mask dilation:", value=4, minimum=1)
722
+ mask_blur_b_gui = gr.Number(label="Mask blur:", value=4, minimum=1)
723
+ mask_padding_b_gui = gr.Number(label="Mask padding:", value=32, minimum=1)
724
+
725
+ with gr.Accordion("Other settings", open=False, visible=False):
726
+ hires_before_adetailer_gui = gr.Checkbox(value=False, label="Hires Before Adetailer")
727
+ hires_after_adetailer_gui = gr.Checkbox(value=True, label="Hires After Adetailer")
728
+ loop_generation_gui = gr.Slider(minimum=1, value=1, label="Loop Generation")
729
+ leave_progress_bar_gui = gr.Checkbox(value=True, label="Leave Progress Bar")
730
+ disable_progress_bar_gui = gr.Checkbox(value=False, label="Disable Progress Bar")
731
+ image_previews_gui = gr.Checkbox(value=False, label="Image Previews")
732
+ display_images_gui = gr.Checkbox(value=False, label="Display Images")
733
+ save_generated_images_gui = gr.Checkbox(value=False, label="Save Generated Images")
734
+ image_storage_location_gui = gr.Textbox(value="./images", label="Image Storage Location")
735
+ retain_compel_previous_load_gui = gr.Checkbox(value=False, label="Retain Compel Previous Load")
736
+ retain_detailfix_model_previous_load_gui = gr.Checkbox(value=False, label="Retain Detailfix Model Previous Load")
737
+ retain_hires_model_previous_load_gui = gr.Checkbox(value=False, label="Retain Hires Model Previous Load")
738
+ xformers_memory_efficient_attention_gui = gr.Checkbox(value=False, label="Xformers Memory Efficient Attention")
739
+ generator_in_cpu_gui = gr.Checkbox(value=False, label="Generator in CPU")
740
+
741
+ with gr.Tab("Inpaint mask maker", render=True):
742
+
743
+ def create_mask_now(img, invert):
744
+ import numpy as np
745
+ import time
746
+
747
+ time.sleep(0.5)
748
+
749
+ transparent_image = img["layers"][0]
750
+
751
+ # Extract the alpha channel
752
+ alpha_channel = np.array(transparent_image)[:, :, 3]
753
+
754
+ # Create a binary mask by thresholding the alpha channel
755
+ binary_mask = alpha_channel > 1
756
+
757
+ if invert:
758
+ print("Invert")
759
+ # Invert the binary mask so that the drawn shape is white and the rest is black
760
+ binary_mask = np.invert(binary_mask)
761
+
762
+ # Convert the binary mask to a 3-channel RGB mask
763
+ rgb_mask = np.stack((binary_mask,) * 3, axis=-1)
764
+
765
+ # Convert the mask to uint8
766
+ rgb_mask = rgb_mask.astype(np.uint8) * 255
767
+
768
+ return img["background"], rgb_mask
769
+
770
+ with gr.Row():
771
+ with gr.Column(scale=2):
772
+ # image_base = gr.ImageEditor(label="Base image", show_label=True, brush=gr.Brush(colors=["#000000"]))
773
+ image_base = gr.ImageEditor(
774
+ sources=["upload", "clipboard"],
775
+ # crop_size="1:1",
776
+ # enable crop (or disable it)
777
+ # transforms=["crop"],
778
+ brush=gr.Brush(
779
+ default_size="16", # or leave it as 'auto'
780
+ color_mode="fixed", # 'fixed' hides the user swatches and colorpicker, 'defaults' shows it
781
+ #default_color="black", # html names are supported
782
+ colors=[
783
+ "rgba(0, 0, 0, 1)", # rgb(a)
784
+ "rgba(0, 0, 0, 0.1)",
785
+ "rgba(255, 255, 255, 0.1)",
786
+ # "hsl(360, 120, 120)" # in fact any valid colorstring
787
+ ]
788
+ ),
789
+ eraser=gr.Eraser(default_size="16")
790
+ )
791
+ invert_mask = gr.Checkbox(value=False, label="Invert mask")
792
+ btn = gr.Button("Create mask")
793
+ with gr.Column(scale=1):
794
+ img_source = gr.Image(interactive=False)
795
+ img_result = gr.Image(label="Mask image", show_label=True, interactive=False)
796
+ btn_send = gr.Button("Send to the first tab")
797
+
798
+ btn.click(create_mask_now, [image_base, invert_mask], [img_source, img_result])
799
+
800
+ def send_img(img_source, img_result):
801
+ return img_source, img_result
802
+ btn_send.click(send_img, [img_source, img_result], [image_control, image_mask_gui])
803
+
804
+ generate_button.click(
805
+ fn=sd_gen.generate_pipeline,
806
+ inputs=[
807
+ prompt_gui,
808
+ neg_prompt_gui,
809
+ num_images_gui,
810
+ steps_gui,
811
+ cfg_gui,
812
+ clip_skip_gui,
813
+ seed_gui,
814
+ lora1_gui,
815
+ lora_scale_1_gui,
816
+ lora2_gui,
817
+ lora_scale_2_gui,
818
+ lora3_gui,
819
+ lora_scale_3_gui,
820
+ lora4_gui,
821
+ lora_scale_4_gui,
822
+ lora5_gui,
823
+ lora_scale_5_gui,
824
+ sampler_gui,
825
+ img_height_gui,
826
+ img_width_gui,
827
+ model_name_gui,
828
+ vae_model_gui,
829
+ task_gui,
830
+ image_control,
831
+ preprocessor_name_gui,
832
+ preprocess_resolution_gui,
833
+ image_resolution_gui,
834
+ style_prompt_gui,
835
+ style_json_gui,
836
+ image_mask_gui,
837
+ strength_gui,
838
+ low_threshold_gui,
839
+ high_threshold_gui,
840
+ value_threshold_gui,
841
+ distance_threshold_gui,
842
+ control_net_output_scaling_gui,
843
+ control_net_start_threshold_gui,
844
+ control_net_stop_threshold_gui,
845
+ active_textual_inversion_gui,
846
+ prompt_syntax_gui,
847
+ loop_generation_gui,
848
+ leave_progress_bar_gui,
849
+ disable_progress_bar_gui,
850
+ image_previews_gui,
851
+ display_images_gui,
852
+ save_generated_images_gui,
853
+ image_storage_location_gui,
854
+ retain_compel_previous_load_gui,
855
+ retain_detailfix_model_previous_load_gui,
856
+ retain_hires_model_previous_load_gui,
857
+ t2i_adapter_preprocessor_gui,
858
+ adapter_conditioning_scale_gui,
859
+ adapter_conditioning_factor_gui,
860
+ upscaler_model_path_gui,
861
+ upscaler_increases_size_gui,
862
+ esrgan_tile_gui,
863
+ esrgan_tile_overlap_gui,
864
+ hires_steps_gui,
865
+ hires_denoising_strength_gui,
866
+ hires_sampler_gui,
867
+ hires_prompt_gui,
868
+ hires_negative_prompt_gui,
869
+ hires_before_adetailer_gui,
870
+ hires_after_adetailer_gui,
871
+ xformers_memory_efficient_attention_gui,
872
+ free_u_gui,
873
+ generator_in_cpu_gui,
874
+ adetailer_inpaint_only_gui,
875
+ adetailer_verbose_gui,
876
+ adetailer_sampler_gui,
877
+ adetailer_active_a_gui,
878
+ prompt_ad_a_gui,
879
+ negative_prompt_ad_a_gui,
880
+ strength_ad_a_gui,
881
+ face_detector_ad_a_gui,
882
+ person_detector_ad_a_gui,
883
+ hand_detector_ad_a_gui,
884
+ mask_dilation_a_gui,
885
+ mask_blur_a_gui,
886
+ mask_padding_a_gui,
887
+ adetailer_active_b_gui,
888
+ prompt_ad_b_gui,
889
+ negative_prompt_ad_b_gui,
890
+ strength_ad_b_gui,
891
+ face_detector_ad_b_gui,
892
+ person_detector_ad_b_gui,
893
+ hand_detector_ad_b_gui,
894
+ mask_dilation_b_gui,
895
+ mask_blur_b_gui,
896
+ mask_padding_b_gui,
897
+ ],
898
+ outputs=[result_images],
899
+ queue=True,
900
+ )
901
+
902
+
903
+
904
+ app.queue() # default_concurrency_limit=40
905
+
906
+ app.launch(
907
+ # max_threads=40,
908
+ # share=False,
909
+ show_error=True,
910
+ # quiet=False,
911
+ debug=True,
912
+ # allowed_paths=["./assets/"],
913
+ )
packages.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ git-lfs
2
+ aria2 -y
3
+ ffmpeg
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ git+https://github.com/R3gm/stablepy.git@lazyload
2
+ torch==2.2.0
3
+ gdown
4
+ opencv-python