Compare commits

..
Author SHA1 Message Date
Connum d5ecf56f8e make callback queue handling reusable and implement onUiTabChange() 2022-09-24 01:12:13 +02:00
18 changed files with 105 additions and 205 deletions

No files matched your search

+1 -1
View File
@@ -1,7 +1,7 @@
# Stable Diffusion web UI # Stable Diffusion web UI
A browser interface based on Gradio library for Stable Diffusion. A browser interface based on Gradio library for Stable Diffusion.
![](txt2img_Screenshot.png) ![](screenshot.png)
## Features ## Features
[Detailed feature showcase with images](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Features): [Detailed feature showcase with images](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Features):
+9 -15
View File
@@ -68,19 +68,13 @@ window.addEventListener('paste', e => {
if ( ! isValidImageList( files ) ) { if ( ! isValidImageList( files ) ) {
return; return;
} }
[...gradioApp().querySelectorAll('input[type=file][accept="image/x-png,image/gif,image/jpeg"]')]
const visibleImageFields = [...gradioApp().querySelectorAll('[data-testid="image"]')] .filter(input => !input.matches('.\\!hidden input[type=file]'))
.filter(el => uiElementIsVisible(el)); .forEach(input => {
if ( ! visibleImageFields.length ) { input.files = files;
return; input.dispatchEvent(new Event('change'))
} });
[...gradioApp().querySelectorAll('[data-testid="image"]')]
const firstFreeImageField = visibleImageFields .filter(imgWrap => !imgWrap.closest('.\\!hidden'))
.filter(el => el.querySelector('input[type=file]'))?.[0]; .forEach(imgWrap => dropReplaceImage( imgWrap, files ));
dropReplaceImage(
firstFreeImageField ?
firstFreeImageField :
visibleImageFields[visibleImageFields.length - 1]
, files );
}); });
+3 -2
View File
@@ -57,13 +57,14 @@ titles = {
"Interrogate": "Reconstruct prompt from existing image and put it into the prompt field.", "Interrogate": "Reconstruct prompt from existing image and put it into the prompt field.",
"Images filename pattern": "Use following tags to define how filenames for images are chosen: [steps], [cfg], [prompt], [prompt_spaces], [width], [height], [styles], [sampler], [seed], [model_hash], [prompt_words], [date], [datetime], [job_timestamp]; leave empty for default.", "Images filename pattern": "Use following tags to define how filenames for images are chosen: [steps], [cfg], [prompt], [prompt_spaces], [width], [height], [sampler], [seed], [model_hash], [prompt_words], [date]; leave empty for default.",
"Directory name pattern": "Use following tags to define how subdirectories for images and grids are chosen: [steps], [cfg], [prompt], [prompt_spaces], [width], [height], [styles], [sampler], [seed], [model_hash], [prompt_words], [date], [datetime], [job_timestamp]; leave empty for default.", "Directory name pattern": "Use following tags to define how subdirectories for images and grids are chosen: [steps], [cfg], [prompt], [prompt_spaces], [width], [height], [sampler], [seed], [model_hash], [prompt_words], [date]; leave empty for default.",
"Max prompt words": "Set the maximum number of words to be used in the [prompt_words] option; ATTENTION: If the words are too long, they may exceed the maximum length of the file path that the system can handle", "Max prompt words": "Set the maximum number of words to be used in the [prompt_words] option; ATTENTION: If the words are too long, they may exceed the maximum length of the file path that the system can handle",
"Loopback": "Process an image, use it as an input, repeat.", "Loopback": "Process an image, use it as an input, repeat.",
"Loops": "How many times to repeat processing an image and using it as input for the next iteration", "Loops": "How many times to repeat processing an image and using it as input for the next iteration",
"Style 1": "Style to apply; styles have components for both positive and negative prompts and apply to both", "Style 1": "Style to apply; styles have components for both positive and negative prompts and apply to both",
"Style 2": "Style to apply; styles have components for both positive and negative prompts and apply to both", "Style 2": "Style to apply; styles have components for both positive and negative prompts and apply to both",
"Apply style": "Insert selected styles into prompt fields", "Apply style": "Insert selected styles into prompt fields",
+15 -19
View File
@@ -1,11 +1,9 @@
from collections import namedtuple
import re import re
import gradio as gr import gradio as gr
re_param_code = r"\s*([\w ]+):\s*([^,]+)(?:,|$)" re_param = re.compile(r"\s*([\w ]+):\s*([^,]+)(?:,|$)")
re_param = re.compile(re_param_code)
re_params = re.compile(r"^(?:" + re_param_code + "){3,}$")
re_imagesize = re.compile(r"^(\d+)x(\d+)$") re_imagesize = re.compile(r"^(\d+)x(\d+)$")
type_of_gr_update = type(gr.update())
def parse_generation_parameters(x: str): def parse_generation_parameters(x: str):
@@ -27,10 +25,6 @@ Steps: 20, Sampler: Euler a, CFG scale: 7, Seed: 965400086, Size: 512x512, Model
done_with_prompt = False done_with_prompt = False
*lines, lastline = x.strip().split("\n") *lines, lastline = x.strip().split("\n")
if not re_params.match(lastline):
lines.append(lastline)
lastline = ''
for i, line in enumerate(lines): for i, line in enumerate(lines):
line = line.strip() line = line.strip()
if line.startswith("Negative prompt:"): if line.startswith("Negative prompt:"):
@@ -38,9 +32,9 @@ Steps: 20, Sampler: Euler a, CFG scale: 7, Seed: 965400086, Size: 512x512, Model
line = line[16:].strip() line = line[16:].strip()
if done_with_prompt: if done_with_prompt:
negative_prompt += ("" if negative_prompt == "" else "\n") + line negative_prompt += line
else: else:
prompt += ("" if prompt == "" else "\n") + line prompt += line
if len(prompt) > 0: if len(prompt) > 0:
res["Prompt"] = prompt res["Prompt"] = prompt
@@ -59,21 +53,19 @@ Steps: 20, Sampler: Euler a, CFG scale: 7, Seed: 965400086, Size: 512x512, Model
return res return res
def connect_paste(button, paste_fields, input_comp, js=None): def connect_paste(button, d, input_comp, js=None):
items = []
outputs = []
def paste_func(prompt): def paste_func(prompt):
params = parse_generation_parameters(prompt) params = parse_generation_parameters(prompt)
res = [] res = []
for output, key in paste_fields: for key, output in zip(items, outputs):
if callable(key): v = params.get(key, None)
v = key(params)
else:
v = params.get(key, None)
if v is None: if v is None:
res.append(gr.update()) res.append(gr.update())
elif isinstance(v, type_of_gr_update):
res.append(v)
else: else:
try: try:
valtype = type(output.value) valtype = type(output.value)
@@ -84,9 +76,13 @@ def connect_paste(button, paste_fields, input_comp, js=None):
return res return res
for k, v in d.items():
items.append(k)
outputs.append(v)
button.click( button.click(
fn=paste_func, fn=paste_func,
_js=js, _js=js,
inputs=[input_comp], inputs=[input_comp],
outputs=[x[0] for x in paste_fields], outputs=outputs,
) )
-3
View File
@@ -290,13 +290,10 @@ def apply_filename_pattern(x, p, seed, prompt):
x = x.replace("[cfg]", str(p.cfg_scale)) x = x.replace("[cfg]", str(p.cfg_scale))
x = x.replace("[width]", str(p.width)) x = x.replace("[width]", str(p.width))
x = x.replace("[height]", str(p.height)) x = x.replace("[height]", str(p.height))
x = x.replace("[styles]", sanitize_filename_part(", ".join(p.styles), replace_spaces=False))
x = x.replace("[sampler]", sanitize_filename_part(sd_samplers.samplers[p.sampler_index].name, replace_spaces=False)) x = x.replace("[sampler]", sanitize_filename_part(sd_samplers.samplers[p.sampler_index].name, replace_spaces=False))
x = x.replace("[model_hash]", shared.sd_model.sd_model_hash) x = x.replace("[model_hash]", shared.sd_model.sd_model_hash)
x = x.replace("[date]", datetime.date.today().isoformat()) x = x.replace("[date]", datetime.date.today().isoformat())
x = x.replace("[datetime]", datetime.datetime.now().strftime("%Y%m%d%H%M%S"))
x = x.replace("[job_timestamp]", shared.state.job_timestamp)
if cmd_opts.hide_ui_dir_config: if cmd_opts.hide_ui_dir_config:
x = re.sub(r'^[\\/]+|\.{2,}[\\/]+|[\\/]+\.{2,}', '', x) x = re.sub(r'^[\\/]+|\.{2,}[\\/]+|[\\/]+\.{2,}', '', x)
-2
View File
@@ -108,8 +108,6 @@ def img2img(mode: int, prompt: str, negative_prompt: str, prompt_style: str, pro
p.extra_generation_params["Mask blur"] = mask_blur p.extra_generation_params["Mask blur"] = mask_blur
if is_batch: if is_batch:
assert not shared.cmd_opts.hide_ui_dir_config, "Launched with --hide-ui-dir-config, batch img2img disabled"
process_batch(p, img2img_batch_input_dir, img2img_batch_output_dir, args) process_batch(p, img2img_batch_input_dir, img2img_batch_output_dir, args)
processed = Processed(p, [], p.seed, "") processed = Processed(p, [], p.seed, "")
-5
View File
@@ -488,11 +488,6 @@ class StableDiffusionProcessingTxt2Img(StableDiffusionProcessing):
self.sampler = samplers[self.sampler_index].constructor(self.sd_model) self.sampler = samplers[self.sampler_index].constructor(self.sd_model)
noise = create_random_tensors(samples.shape[1:], seeds=seeds, subseeds=subseeds, subseed_strength=subseed_strength, seed_resize_from_h=self.seed_resize_from_h, seed_resize_from_w=self.seed_resize_from_w, p=self) noise = create_random_tensors(samples.shape[1:], seeds=seeds, subseeds=subseeds, subseed_strength=subseed_strength, seed_resize_from_h=self.seed_resize_from_h, seed_resize_from_w=self.seed_resize_from_w, p=self)
# GC now before running the next img2img to prevent running out of memory
x = None
devices.torch_gc()
samples = self.sampler.sample_img2img(self, samples, noise, conditioning, unconditional_conditioning, steps=self.steps) samples = self.sampler.sample_img2img(self, samples, noise, conditioning, unconditional_conditioning, steps=self.steps)
return samples return samples
-1
View File
@@ -119,7 +119,6 @@ class ScriptRunner:
continue continue
for control in controls: for control in controls:
control.custom_script_source = os.path.basename(script.filename)
control.visible = False control.visible = False
inputs += controls inputs += controls
+3 -3
View File
@@ -201,7 +201,7 @@ class StableDiffusionModelHijack:
def process_file(path, filename): def process_file(path, filename):
name = os.path.splitext(filename)[0] name = os.path.splitext(filename)[0]
data = torch.load(path, map_location="cpu") data = torch.load(path)
# textual inversion embeddings # textual inversion embeddings
if 'string_to_param' in data: if 'string_to_param' in data:
@@ -217,7 +217,7 @@ class StableDiffusionModelHijack:
if len(emb.shape) == 1: if len(emb.shape) == 1:
emb = emb.unsqueeze(0) emb = emb.unsqueeze(0)
self.word_embeddings[name] = emb.detach().to(device) self.word_embeddings[name] = emb.detach()
self.word_embeddings_checksums[name] = f'{const_hash(emb.reshape(-1)*100)&0xffff:04x}' self.word_embeddings_checksums[name] = f'{const_hash(emb.reshape(-1)*100)&0xffff:04x}'
ids = tokenizer([name], add_special_tokens=False)['input_ids'][0] ids = tokenizer([name], add_special_tokens=False)['input_ids'][0]
@@ -300,7 +300,7 @@ class FrozenCLIPEmbedderWithCustomWords(torch.nn.Module):
remade_batch_tokens = [] remade_batch_tokens = []
id_start = self.wrapped.tokenizer.bos_token_id id_start = self.wrapped.tokenizer.bos_token_id
id_end = self.wrapped.tokenizer.eos_token_id id_end = self.wrapped.tokenizer.eos_token_id
maxlen = self.wrapped.max_length maxlen = self.wrapped.max_length - 2
used_custom_terms = [] used_custom_terms = []
cache = {} cache = {}
+1 -12
View File
@@ -4,7 +4,6 @@ import json
import os import os
import gradio as gr import gradio as gr
import tqdm import tqdm
import datetime
import modules.artists import modules.artists
from modules.paths import script_path, sd_path from modules.paths import script_path, sd_path
@@ -66,7 +65,6 @@ class State:
job = "" job = ""
job_no = 0 job_no = 0
job_count = 0 job_count = 0
job_timestamp = 0
sampling_step = 0 sampling_step = 0
sampling_steps = 0 sampling_steps = 0
current_latent = None current_latent = None
@@ -80,8 +78,6 @@ class State:
self.job_no += 1 self.job_no += 1
self.sampling_step = 0 self.sampling_step = 0
self.current_image_sampling_step = 0 self.current_image_sampling_step = 0
def get_job_timestamp(self):
return datetime.datetime.now().strftime("%Y%m%d%H%M%S")
state = State() state = State()
@@ -120,7 +116,7 @@ def options_section(section_identifer, options_dict):
return options_dict return options_dict
hide_dirs = {"visible": not cmd_opts.hide_ui_dir_config} hide_dirs = {"visible": False} if cmd_opts.hide_ui_dir_config else None
options_templates = {} options_templates = {}
@@ -311,13 +307,6 @@ class TotalTQDM:
self.reset() self.reset()
self._tqdm.update() self._tqdm.update()
def updateTotal(self, new_total):
if not opts.multiple_tqdm:
return
if self._tqdm is None:
self.reset()
self._tqdm.total=new_total
def clear(self): def clear(self):
if self._tqdm is not None: if self._tqdm is not None:
self._tqdm.close() self._tqdm.close()
+55 -78
View File
@@ -49,6 +49,7 @@ sample_img2img = sample_img2img if os.path.exists(sample_img2img) else None
css_hide_progressbar = """ css_hide_progressbar = """
.wrap .m-12 svg { display:none!important; } .wrap .m-12 svg { display:none!important; }
.wrap .m-12::before { content:"Loading..." }
.progress-bar { display:none!important; } .progress-bar { display:none!important; }
.meta-text { display:none!important; } .meta-text { display:none!important; }
""" """
@@ -197,7 +198,7 @@ def check_progress_call(id_part):
image = shared.state.current_image image = shared.state.current_image
if image is None: if image is None or progress >= 1:
image = gr.update(value=None) image = gr.update(value=None)
else: else:
preview_visibility = gr_show(True) preview_visibility = gr_show(True)
@@ -412,10 +413,6 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo):
steps = gr.Slider(minimum=1, maximum=150, step=1, label="Sampling Steps", value=20) steps = gr.Slider(minimum=1, maximum=150, step=1, label="Sampling Steps", value=20)
sampler_index = gr.Radio(label='Sampling method', elem_id="txt2img_sampling", choices=[x.name for x in samplers], value=samplers[0].name, type="index") sampler_index = gr.Radio(label='Sampling method', elem_id="txt2img_sampling", choices=[x.name for x in samplers], value=samplers[0].name, type="index")
with gr.Group():
width = gr.Slider(minimum=64, maximum=2048, step=64, label="Width", value=512)
height = gr.Slider(minimum=64, maximum=2048, step=64, label="Height", value=512)
with gr.Row(): with gr.Row():
restore_faces = gr.Checkbox(label='Restore faces', value=False, visible=len(shared.face_restorers) > 1) restore_faces = gr.Checkbox(label='Restore faces', value=False, visible=len(shared.face_restorers) > 1)
tiling = gr.Checkbox(label='Tiling', value=False) tiling = gr.Checkbox(label='Tiling', value=False)
@@ -431,6 +428,10 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo):
cfg_scale = gr.Slider(minimum=1.0, maximum=30.0, step=0.5, label='CFG Scale', value=7.0) cfg_scale = gr.Slider(minimum=1.0, maximum=30.0, step=0.5, label='CFG Scale', value=7.0)
with gr.Group():
width = gr.Slider(minimum=64, maximum=2048, step=64, label="Width", value=512)
height = gr.Slider(minimum=64, maximum=2048, step=64, label="Height", value=512)
seed, reuse_seed, subseed, reuse_subseed, subseed_strength, seed_resize_from_h, seed_resize_from_w, seed_checkbox = create_seed_inputs() seed, reuse_seed, subseed, reuse_subseed, subseed_strength, seed_resize_from_h, seed_resize_from_w, seed_checkbox = create_seed_inputs()
with gr.Group(): with gr.Group():
@@ -521,25 +522,23 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo):
] ]
) )
txt2img_paste_fields = [ txt2img_paste_fields = {
(txt2img_prompt, "Prompt"), "Prompt": txt2img_prompt,
(txt2img_negative_prompt, "Negative prompt"), "Negative prompt": txt2img_negative_prompt,
(steps, "Steps"), "Steps": steps,
(sampler_index, "Sampler"), "Sampler": sampler_index,
(restore_faces, "Face restoration"), "Face restoration": restore_faces,
(cfg_scale, "CFG scale"), "CFG scale": cfg_scale,
(seed, "Seed"), "Seed": seed,
(width, "Size-1"), "Size-1": width,
(height, "Size-2"), "Size-2": height,
(batch_size, "Batch size"), "Batch size": batch_size,
(subseed, "Variation seed"), "Variation seed": subseed,
(subseed_strength, "Variation seed strength"), "Variation seed strength": subseed_strength,
(seed_resize_from_w, "Seed resize from-1"), "Seed resize from-1": seed_resize_from_w,
(seed_resize_from_h, "Seed resize from-2"), "Seed resize from-2": seed_resize_from_h,
(denoising_strength, "Denoising strength"), "Denoising strength": denoising_strength,
(enable_hr, lambda d: "Denoising strength" in d), }
(hr_options, lambda d: gr.Row.update(visible="Denoising strength" in d)),
]
modules.generation_parameters_copypaste.connect_paste(paste, txt2img_paste_fields, txt2img_prompt) modules.generation_parameters_copypaste.connect_paste(paste, txt2img_paste_fields, txt2img_prompt)
with gr.Blocks(analytics_enabled=False) as img2img_interface: with gr.Blocks(analytics_enabled=False) as img2img_interface:
@@ -580,10 +579,9 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo):
inpaint_full_res_padding = gr.Slider(label='Inpaint at full resolution padding, pixels', minimum=0, maximum=256, step=4, value=32) inpaint_full_res_padding = gr.Slider(label='Inpaint at full resolution padding, pixels', minimum=0, maximum=256, step=4, value=32)
with gr.TabItem('Batch img2img', id='batch'): with gr.TabItem('Batch img2img', id='batch'):
hidden = '<br>Disabled when launched with --hide-ui-dir-config.' if shared.cmd_opts.hide_ui_dir_config else '' gr.HTML("<p class=\"text-gray-500\">Process images in a directory on the same machine where the server is running.</p>")
gr.HTML(f"<p class=\"text-gray-500\">Process images in a directory on the same machine where the server is running.{hidden}</p>") img2img_batch_input_dir = gr.Textbox(label="Input directory")
img2img_batch_input_dir = gr.Textbox(label="Input directory", **shared.hide_dirs) img2img_batch_output_dir = gr.Textbox(label="Output directory")
img2img_batch_output_dir = gr.Textbox(label="Output directory", **shared.hide_dirs)
with gr.Row(): with gr.Row():
resize_mode = gr.Radio(label="Resize mode", elem_id="resize_mode", show_label=False, choices=["Just resize", "Crop and resize", "Resize and fill"], type="index", value="Just resize") resize_mode = gr.Radio(label="Resize mode", elem_id="resize_mode", show_label=False, choices=["Just resize", "Crop and resize", "Resize and fill"], type="index", value="Just resize")
@@ -591,10 +589,6 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo):
steps = gr.Slider(minimum=1, maximum=150, step=1, label="Sampling Steps", value=20) steps = gr.Slider(minimum=1, maximum=150, step=1, label="Sampling Steps", value=20)
sampler_index = gr.Radio(label='Sampling method', choices=[x.name for x in samplers_for_img2img], value=samplers_for_img2img[0].name, type="index") sampler_index = gr.Radio(label='Sampling method', choices=[x.name for x in samplers_for_img2img], value=samplers_for_img2img[0].name, type="index")
with gr.Group():
width = gr.Slider(minimum=64, maximum=2048, step=64, label="Width", value=512)
height = gr.Slider(minimum=64, maximum=2048, step=64, label="Height", value=512)
with gr.Row(): with gr.Row():
restore_faces = gr.Checkbox(label='Restore faces', value=False, visible=len(shared.face_restorers) > 1) restore_faces = gr.Checkbox(label='Restore faces', value=False, visible=len(shared.face_restorers) > 1)
tiling = gr.Checkbox(label='Tiling', value=False) tiling = gr.Checkbox(label='Tiling', value=False)
@@ -607,6 +601,10 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo):
cfg_scale = gr.Slider(minimum=1.0, maximum=30.0, step=0.5, label='CFG Scale', value=7.0) cfg_scale = gr.Slider(minimum=1.0, maximum=30.0, step=0.5, label='CFG Scale', value=7.0)
denoising_strength = gr.Slider(minimum=0.0, maximum=1.0, step=0.01, label='Denoising strength', value=0.75) denoising_strength = gr.Slider(minimum=0.0, maximum=1.0, step=0.01, label='Denoising strength', value=0.75)
with gr.Group():
width = gr.Slider(minimum=64, maximum=2048, step=64, label="Width", value=512)
height = gr.Slider(minimum=64, maximum=2048, step=64, label="Height", value=512)
seed, reuse_seed, subseed, reuse_subseed, subseed_strength, seed_resize_from_h, seed_resize_from_w, seed_checkbox = create_seed_inputs() seed, reuse_seed, subseed, reuse_subseed, subseed_strength, seed_resize_from_h, seed_resize_from_w, seed_checkbox = create_seed_inputs()
with gr.Group(): with gr.Group():
@@ -743,23 +741,23 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo):
outputs=[prompt, negative_prompt, style1, style2], outputs=[prompt, negative_prompt, style1, style2],
) )
img2img_paste_fields = [ img2img_paste_fields = {
(img2img_prompt, "Prompt"), "Prompt": img2img_prompt,
(img2img_negative_prompt, "Negative prompt"), "Negative prompt": img2img_negative_prompt,
(steps, "Steps"), "Steps": steps,
(sampler_index, "Sampler"), "Sampler": sampler_index,
(restore_faces, "Face restoration"), "Face restoration": restore_faces,
(cfg_scale, "CFG scale"), "CFG scale": cfg_scale,
(seed, "Seed"), "Seed": seed,
(width, "Size-1"), "Size-1": width,
(height, "Size-2"), "Size-2": height,
(batch_size, "Batch size"), "Batch size": batch_size,
(subseed, "Variation seed"), "Variation seed": subseed,
(subseed_strength, "Variation seed strength"), "Variation seed strength": subseed_strength,
(seed_resize_from_w, "Seed resize from-1"), "Seed resize from-1": seed_resize_from_w,
(seed_resize_from_h, "Seed resize from-2"), "Seed resize from-2": seed_resize_from_h,
(denoising_strength, "Denoising strength"), "Denoising strength": denoising_strength,
] }
modules.generation_parameters_copypaste.connect_paste(paste, img2img_paste_fields, img2img_prompt) modules.generation_parameters_copypaste.connect_paste(paste, img2img_paste_fields, img2img_prompt)
with gr.Blocks(analytics_enabled=False) as extras_interface: with gr.Blocks(analytics_enabled=False) as extras_interface:
@@ -978,21 +976,18 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo):
outputs=[result, text_settings], outputs=[result, text_settings],
) )
paste_field_names = ['Prompt', 'Negative prompt', 'Steps', 'Face restoration', 'Seed', 'Size-1', 'Size-2']
txt2img_fields = [field for field,name in txt2img_paste_fields if name in paste_field_names]
img2img_fields = [field for field,name in img2img_paste_fields if name in paste_field_names]
send_to_img2img.click( send_to_img2img.click(
fn=lambda img, *args: (image_from_url_text(img),*args), fn=lambda x: (image_from_url_text(x)),
_js="(gallery, ...args) => [extract_image_from_gallery_img2img(gallery), ...args]", _js="extract_image_from_gallery_img2img",
inputs=[txt2img_gallery] + txt2img_fields, inputs=[txt2img_gallery],
outputs=[init_img] + img2img_fields, outputs=[init_img],
) )
send_to_inpaint.click( send_to_inpaint.click(
fn=lambda x, *args: (image_from_url_text(x), *args), fn=lambda x: (image_from_url_text(x)),
_js="(gallery, ...args) => [extract_image_from_gallery_inpaint(gallery), ...args]", _js="extract_image_from_gallery_inpaint",
inputs=[txt2img_gallery] + txt2img_fields, inputs=[txt2img_gallery],
outputs=[init_img_with_mask] + img2img_fields, outputs=[init_img_with_mask],
) )
img2img_send_to_img2img.click( img2img_send_to_img2img.click(
@@ -1044,21 +1039,12 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo):
def apply_field(obj, field, condition=None): def apply_field(obj, field, condition=None):
key = path + "/" + field key = path + "/" + field
if getattr(obj,'custom_script_source',None) is not None:
key = 'customscript/' + obj.custom_script_source + '/' + key
if getattr(obj, 'do_not_save_to_config', False):
return
saved_value = ui_settings.get(key, None) saved_value = ui_settings.get(key, None)
if saved_value is None: if saved_value is None:
ui_settings[key] = getattr(obj, field) ui_settings[key] = getattr(obj, field)
elif condition is None or condition(saved_value): elif condition is None or condition(saved_value):
setattr(obj, field, saved_value) setattr(obj, field, saved_value)
if type(x) in [gr.Slider, gr.Radio, gr.Checkbox, gr.Textbox, gr.Number] and x.visible:
apply_field(x, 'visible')
if type(x) == gr.Slider: if type(x) == gr.Slider:
apply_field(x, 'value') apply_field(x, 'value')
apply_field(x, 'minimum') apply_field(x, 'minimum')
@@ -1068,15 +1054,6 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo):
if type(x) == gr.Radio: if type(x) == gr.Radio:
apply_field(x, 'value', lambda val: val in x.choices) apply_field(x, 'value', lambda val: val in x.choices)
if type(x) == gr.Checkbox:
apply_field(x, 'value')
if type(x) == gr.Textbox:
apply_field(x, 'value')
if type(x) == gr.Number:
apply_field(x, 'value')
visit(txt2img_interface, loadsave, "txt2img") visit(txt2img_interface, loadsave, "txt2img")
visit(img2img_interface, loadsave, "img2img") visit(img2img_interface, loadsave, "img2img")
visit(extras_interface, loadsave, "extras") visit(extras_interface, loadsave, "extras")
+13 -11
View File
@@ -1,20 +1,22 @@
basicsr transformers
diffusers diffusers
fairscale==0.4.4 basicsr
fonts
font-roboto
gfpgan gfpgan
gradio gradio
invisible-watermark
git+https://github.com/crowsonkb/k-diffusion.git
numpy numpy
omegaconf
piexif
Pillow Pillow
pytorch_lightning
realesrgan realesrgan
torch
transformers
omegaconf
pytorch_lightning
diffusers
invisible-watermark
scikit-image>=0.19 scikit-image>=0.19
fonts
font-roboto
git+https://github.com/crowsonkb/k-diffusion.git
git+https://github.com/TencentARC/GFPGAN.git@8d2447a2d918f8eba5a4a01463fd48e45126a379 git+https://github.com/TencentARC/GFPGAN.git@8d2447a2d918f8eba5a4a01463fd48e45126a379
timm==0.4.12 timm==0.4.12
transformers fairscale==0.4.4
torch piexif
-21
View File
@@ -39,24 +39,3 @@ document.addEventListener("DOMContentLoaded", function() {
}); });
mutationObserver.observe( gradioApp(), { childList:true, subtree:true }) mutationObserver.observe( gradioApp(), { childList:true, subtree:true })
}); });
/**
* checks that a UI element is not in another hidden element or tab content
*/
function uiElementIsVisible(el) {
let isVisible = !el.closest('.\\!hidden');
if ( ! isVisible ) {
return false;
}
while( isVisible = el.closest('.tabitem')?.style.display !== 'none' ) {
if ( ! isVisible ) {
return false;
} else if ( el.parentElement ) {
el = el.parentElement
} else {
break;
}
}
return isVisible;
}
+5 -26
View File
@@ -141,11 +141,10 @@ class Script(scripts.Script):
y_values = gr.Textbox(label="Y values", visible=False, lines=1) y_values = gr.Textbox(label="Y values", visible=False, lines=1)
draw_legend = gr.Checkbox(label='Draw legend', value=True) draw_legend = gr.Checkbox(label='Draw legend', value=True)
no_fixed_seeds = gr.Checkbox(label='Keep -1 for seeds', value=False)
return [x_type, x_values, y_type, y_values, draw_legend]
return [x_type, x_values, y_type, y_values, draw_legend, no_fixed_seeds] def run(self, p, x_type, x_values, y_type, y_values, draw_legend):
def run(self, p, x_type, x_values, y_type, y_values, draw_legend, no_fixed_seeds):
modules.processing.fix_seed(p) modules.processing.fix_seed(p)
p.batch_size = 1 p.batch_size = 1
@@ -170,7 +169,7 @@ class Script(scripts.Script):
end = int(mc.group(2)) end = int(mc.group(2))
num = int(mc.group(3)) if mc.group(3) is not None else 1 num = int(mc.group(3)) if mc.group(3) is not None else 1
valslist_ext += [int(x) for x in np.linspace(start=start, stop=end, num=num).tolist()] valslist_ext += [int(x) for x in np.linspace(start = start, stop = end, num = num).tolist()]
else: else:
valslist_ext.append(val) valslist_ext.append(val)
@@ -192,7 +191,7 @@ class Script(scripts.Script):
end = float(mc.group(2)) end = float(mc.group(2))
num = int(mc.group(3)) if mc.group(3) is not None else 1 num = int(mc.group(3)) if mc.group(3) is not None else 1
valslist_ext += np.linspace(start=start, stop=end, num=num).tolist() valslist_ext += np.linspace(start = start, stop = end, num = num).tolist()
else: else:
valslist_ext.append(val) valslist_ext.append(val)
@@ -208,26 +207,6 @@ class Script(scripts.Script):
y_opt = axis_options[y_type] y_opt = axis_options[y_type]
ys = process_axis(y_opt, y_values) ys = process_axis(y_opt, y_values)
def fix_axis_seeds(axis_opt, axis_list):
if axis_opt.label == 'Seed':
return [int(random.randrange(4294967294)) if val is None or val == '' or val == -1 else val for val in axis_list]
else:
return axis_list
if not no_fixed_seeds:
xs = fix_axis_seeds(x_opt, xs)
ys = fix_axis_seeds(y_opt, ys)
if x_opt.label == 'Steps':
total_steps = sum(xs) * len(ys)
elif y_opt.label == 'Steps':
total_steps = sum(ys) * len(xs)
else:
total_steps = p.steps * len(xs) * len(ys)
print(f"X/Y plot will create {len(xs) * len(ys) * p.n_iter} images on a {len(xs)}x{len(ys)} grid. (Total steps to process: {total_steps * p.n_iter})")
shared.total_tqdm.updateTotal(total_steps * p.n_iter)
def cell(x, y): def cell(x, y):
pc = copy(p) pc = copy(p)
x_opt.apply(pc, x, xs) x_opt.apply(pc, x, xs)
Binary file not shown.

Before

Width:  |  Height:  |  Size: 526 KiB

-2
View File
@@ -3,8 +3,6 @@
if not defined PYTHON (set PYTHON=python) if not defined PYTHON (set PYTHON=python)
if not defined VENV_DIR (set VENV_DIR=venv) if not defined VENV_DIR (set VENV_DIR=venv)
set ERROR_REPORTING=FALSE
mkdir tmp 2>NUL mkdir tmp 2>NUL
%PYTHON% -c "" >tmp/stdout.txt 2>tmp/stderr.txt %PYTHON% -c "" >tmp/stdout.txt 2>tmp/stderr.txt
-1
View File
@@ -50,7 +50,6 @@ def wrap_gradio_gpu_call(func):
shared.state.sampling_step = 0 shared.state.sampling_step = 0
shared.state.job_count = -1 shared.state.job_count = -1
shared.state.job_no = 0 shared.state.job_no = 0
shared.state.job_timestamp = shared.state.get_job_timestamp()
shared.state.current_latent = None shared.state.current_latent = None
shared.state.current_image = None shared.state.current_image = None
shared.state.current_image_sampling_step = 0 shared.state.current_image_sampling_step = 0
-3
View File
@@ -41,9 +41,6 @@ then
venv_dir="venv" venv_dir="venv"
fi fi
# Disable sentry logging
export ERROR_REPORTING=FALSE
# Do not reinstall existing pip packages on Debian/Ubuntu # Do not reinstall existing pip packages on Debian/Ubuntu
export PIP_IGNORE_INSTALLED=0 export PIP_IGNORE_INSTALLED=0