Skip to content

Commit 2b91251

Browse files
committed
removed aesthetic gradients as built-in
added support for extensions
1 parent 26d1073 commit 2b91251

14 files changed

Lines changed: 249 additions & 410 deletions

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ __pycache__
2727
notification.mp3
2828
/SwinIR
2929
/textual_inversion
30-
.vscode
30+
.vscode

extensions/put extension here.txt

Whitespace-only changes.

modules/aesthetic_clip.py

Lines changed: 0 additions & 241 deletions
This file was deleted.

modules/images_history.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ def show_images_history(gr, opts, tabname, run_pnginfo, switch_dict):
310310
forward = gr.Button('Prev batch')
311311
backward = gr.Button('Next batch')
312312
with gr.Column(scale=3):
313-
load_info = gr.HTML(visible=not custom_dir)
313+
load_info = gr.HTML(visible=not custom_dir)
314314
with gr.Row(visible=False) as warning:
315315
warning_box = gr.Textbox("Message", interactive=False)
316316

modules/img2img.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def process_batch(p, input_dir, output_dir, args):
5656
processed_image.save(os.path.join(output_dir, filename))
5757

5858

59-
def img2img(mode: int, prompt: str, negative_prompt: str, prompt_style: str, prompt_style2: str, init_img, init_img_with_mask, init_img_inpaint, init_mask_inpaint, mask_mode, steps: int, sampler_index: int, mask_blur: int, inpainting_fill: int, restore_faces: bool, tiling: bool, n_iter: int, batch_size: int, cfg_scale: float, denoising_strength: float, seed: int, subseed: int, subseed_strength: float, seed_resize_from_h: int, seed_resize_from_w: int, seed_enable_extras: bool, height: int, width: int, resize_mode: int, inpaint_full_res: bool, inpaint_full_res_padding: int, inpainting_mask_invert: int, img2img_batch_input_dir: str, img2img_batch_output_dir: str, aesthetic_lr=0, aesthetic_weight=0, aesthetic_steps=0, aesthetic_imgs=None, aesthetic_slerp=False, aesthetic_imgs_text="", aesthetic_slerp_angle=0.15, aesthetic_text_negative=False, *args):
59+
def img2img(mode: int, prompt: str, negative_prompt: str, prompt_style: str, prompt_style2: str, init_img, init_img_with_mask, init_img_inpaint, init_mask_inpaint, mask_mode, steps: int, sampler_index: int, mask_blur: int, inpainting_fill: int, restore_faces: bool, tiling: bool, n_iter: int, batch_size: int, cfg_scale: float, denoising_strength: float, seed: int, subseed: int, subseed_strength: float, seed_resize_from_h: int, seed_resize_from_w: int, seed_enable_extras: bool, height: int, width: int, resize_mode: int, inpaint_full_res: bool, inpaint_full_res_padding: int, inpainting_mask_invert: int, img2img_batch_input_dir: str, img2img_batch_output_dir: str, *args):
6060
is_inpaint = mode == 1
6161
is_batch = mode == 2
6262

@@ -109,7 +109,8 @@ def img2img(mode: int, prompt: str, negative_prompt: str, prompt_style: str, pro
109109
inpainting_mask_invert=inpainting_mask_invert,
110110
)
111111

112-
shared.aesthetic_clip.set_aesthetic_params(p, float(aesthetic_lr), float(aesthetic_weight), int(aesthetic_steps), aesthetic_imgs, aesthetic_slerp, aesthetic_imgs_text, aesthetic_slerp_angle, aesthetic_text_negative)
112+
p.scripts = modules.scripts.scripts_txt2img
113+
p.script_args = args
113114

114115
if shared.cmd_opts.enable_console_prompts:
115116
print(f"\nimg2img: {prompt}", file=shared.progress_print_out)

modules/processing.py

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ def __init__(self, sd_model=None, outpath_samples=None, outpath_grids=None, prom
104104
self.seed_resize_from_h = 0
105105
self.seed_resize_from_w = 0
106106

107+
self.scripts = None
108+
self.script_args = None
109+
self.all_prompts = None
110+
self.all_seeds = None
111+
self.all_subseeds = None
112+
107113

108114
def init(self, all_prompts, all_seeds, all_subseeds):
109115
pass
@@ -350,32 +356,35 @@ def process_images(p: StableDiffusionProcessing) -> Processed:
350356
shared.prompt_styles.apply_styles(p)
351357

352358
if type(p.prompt) == list:
353-
all_prompts = p.prompt
359+
p.all_prompts = p.prompt
354360
else:
355-
all_prompts = p.batch_size * p.n_iter * [p.prompt]
361+
p.all_prompts = p.batch_size * p.n_iter * [p.prompt]
356362

357363
if type(seed) == list:
358-
all_seeds = seed
364+
p.all_seeds = seed
359365
else:
360-
all_seeds = [int(seed) + (x if p.subseed_strength == 0 else 0) for x in range(len(all_prompts))]
366+
p.all_seeds = [int(seed) + (x if p.subseed_strength == 0 else 0) for x in range(len(p.all_prompts))]
361367

362368
if type(subseed) == list:
363-
all_subseeds = subseed
369+
p.all_subseeds = subseed
364370
else:
365-
all_subseeds = [int(subseed) + x for x in range(len(all_prompts))]
371+
p.all_subseeds = [int(subseed) + x for x in range(len(p.all_prompts))]
366372

367373
def infotext(iteration=0, position_in_batch=0):
368-
return create_infotext(p, all_prompts, all_seeds, all_subseeds, comments, iteration, position_in_batch)
374+
return create_infotext(p, p.all_prompts, p.all_seeds, p.all_subseeds, comments, iteration, position_in_batch)
369375

370376
if os.path.exists(cmd_opts.embeddings_dir) and not p.do_not_reload_embeddings:
371377
model_hijack.embedding_db.load_textual_inversion_embeddings()
372378

379+
if p.scripts is not None:
380+
p.scripts.run_alwayson_scripts(p)
381+
373382
infotexts = []
374383
output_images = []
375384

376385
with torch.no_grad(), p.sd_model.ema_scope():
377386
with devices.autocast():
378-
p.init(all_prompts, all_seeds, all_subseeds)
387+
p.init(p.all_prompts, p.all_seeds, p.all_subseeds)
379388

380389
if state.job_count == -1:
381390
state.job_count = p.n_iter
@@ -387,9 +396,9 @@ def infotext(iteration=0, position_in_batch=0):
387396
if state.interrupted:
388397
break
389398

390-
prompts = all_prompts[n * p.batch_size:(n + 1) * p.batch_size]
391-
seeds = all_seeds[n * p.batch_size:(n + 1) * p.batch_size]
392-
subseeds = all_subseeds[n * p.batch_size:(n + 1) * p.batch_size]
399+
prompts = p.all_prompts[n * p.batch_size:(n + 1) * p.batch_size]
400+
seeds = p.all_seeds[n * p.batch_size:(n + 1) * p.batch_size]
401+
subseeds = p.all_subseeds[n * p.batch_size:(n + 1) * p.batch_size]
393402

394403
if (len(prompts) == 0):
395404
break
@@ -490,10 +499,10 @@ def infotext(iteration=0, position_in_batch=0):
490499
index_of_first_image = 1
491500

492501
if opts.grid_save:
493-
images.save_image(grid, p.outpath_grids, "grid", all_seeds[0], all_prompts[0], opts.grid_format, info=infotext(), short_filename=not opts.grid_extended_filename, p=p, grid=True)
502+
images.save_image(grid, p.outpath_grids, "grid", p.all_seeds[0], p.all_prompts[0], opts.grid_format, info=infotext(), short_filename=not opts.grid_extended_filename, p=p, grid=True)
494503

495504
devices.torch_gc()
496-
return Processed(p, output_images, all_seeds[0], infotext() + "".join(["\n\n" + x for x in comments]), subseed=all_subseeds[0], all_prompts=all_prompts, all_seeds=all_seeds, all_subseeds=all_subseeds, index_of_first_image=index_of_first_image, infotexts=infotexts)
505+
return Processed(p, output_images, p.all_seeds[0], infotext() + "".join(["\n\n" + x for x in comments]), subseed=p.all_subseeds[0], all_prompts=p.all_prompts, all_seeds=p.all_seeds, all_subseeds=p.all_subseeds, index_of_first_image=index_of_first_image, infotexts=infotexts)
497506

498507

499508
class StableDiffusionProcessingTxt2Img(StableDiffusionProcessing):

0 commit comments

Comments
 (0)