mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 01:04:32 +02:00
styles apply wildcard to params
This commit is contained in:
+5
-2
@@ -2,11 +2,14 @@
|
||||
|
||||
## TODO
|
||||
|
||||
- reference styles
|
||||
- quick apply style
|
||||
- Include reference styles
|
||||
- Quick apply style
|
||||
- Add refine workflow in img2img
|
||||
- New image browser
|
||||
|
||||
## Update for 2024-03-20
|
||||
|
||||
- Styles apply wildcards to params
|
||||
- Make metadata in full screen viewer optional
|
||||
|
||||
## Update for 2024-03-19
|
||||
|
||||
@@ -68,7 +68,7 @@ def p_sample_ddim(self, x, c, t, index, repeat_noise=False, use_original_steps=F
|
||||
pred_x0, _, *_ = self.model.first_stage_model.quantize(pred_x0)
|
||||
|
||||
if dynamic_threshold is not None:
|
||||
raise NotImplementedError()
|
||||
raise NotImplementedError
|
||||
|
||||
# direction pointing to x_t
|
||||
dir_xt = (1. - a_prev - sigma_t**2).sqrt() * e_t
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from typing import Type
|
||||
import torch
|
||||
import tomesd
|
||||
from typing import Type
|
||||
from modules.dml.hijack.utils import catch_nan
|
||||
|
||||
def make_tome_block(block_class: Type[torch.nn.Module]) -> Type[torch.nn.Module]:
|
||||
@@ -17,6 +17,6 @@ def make_tome_block(block_class: Type[torch.nn.Module]) -> Type[torch.nn.Module]
|
||||
x = u_m(self.ff(m_m(self.norm3(x)))) + x
|
||||
|
||||
return x
|
||||
|
||||
|
||||
return ToMeBlock
|
||||
tomesd.patch.make_tome_block = make_tome_block
|
||||
|
||||
@@ -96,6 +96,8 @@ def add_paste_fields(tabname, init_img, fields, override_settings_component=None
|
||||
modules.ui.txt2img_paste_fields = fields
|
||||
elif tabname == 'img2img':
|
||||
modules.ui.img2img_paste_fields = fields
|
||||
elif tabname == 'control':
|
||||
modules.ui.control_paste_fields = fields
|
||||
|
||||
|
||||
def create_buttons(tabs_list):
|
||||
|
||||
+13
-4
@@ -46,15 +46,15 @@ def apply_styles_to_prompt(prompt, styles):
|
||||
def apply_wildcards_to_prompt(prompt, all_wildcards):
|
||||
replaced = {}
|
||||
for style_wildcards in all_wildcards:
|
||||
wildcards = [x.strip() for x in style_wildcards.split(";") if len(x.strip()) > 0]
|
||||
wildcards = [x.strip() for x in style_wildcards.replace('\n', ' ').split(";") if len(x.strip()) > 0]
|
||||
for wildcard in wildcards:
|
||||
what, words = wildcard.split("=", 1)
|
||||
words = [x.strip() for x in words.split(",") if len(x.strip()) > 0]
|
||||
word = random.choice(words)
|
||||
prompt = prompt.replace(what, word)
|
||||
replaced[what] = word
|
||||
if replaced:
|
||||
shared.log.debug(f'Applying style wildcards: {replaced}')
|
||||
# if replaced:
|
||||
# shared.log.debug(f'Applying style wildcards: {replaced}')
|
||||
return prompt
|
||||
|
||||
|
||||
@@ -73,11 +73,18 @@ def apply_styles_to_extra(p, style: Style):
|
||||
return
|
||||
name_map = {
|
||||
'sampler': 'sampler_name',
|
||||
'size-1': 'width',
|
||||
'size-2': 'height',
|
||||
}
|
||||
name_exclude = [
|
||||
'size',
|
||||
]
|
||||
from modules.generation_parameters_copypaste import parse_generation_parameters
|
||||
reference_style = get_reference_style()
|
||||
extra = parse_generation_parameters(reference_style) if shared.opts.extra_network_reference else {}
|
||||
extra.update(parse_generation_parameters(style.extra))
|
||||
|
||||
style_extra = apply_wildcards_to_prompt(style.extra, [style.wildcards])
|
||||
extra.update(parse_generation_parameters(style_extra))
|
||||
extra.pop('Prompt', None)
|
||||
extra.pop('Negative prompt', None)
|
||||
fields = []
|
||||
@@ -85,6 +92,8 @@ def apply_styles_to_extra(p, style: Style):
|
||||
for k, v in extra.items():
|
||||
k = k.lower()
|
||||
k = k.replace(' ', '_')
|
||||
if k in name_exclude: # exclude some fields
|
||||
continue
|
||||
if k in name_map: # rename some fields
|
||||
k = name_map[k]
|
||||
if hasattr(p, k):
|
||||
|
||||
Reference in New Issue
Block a user