mirror of
https://github.com/vladmandic/automatic
synced 2026-09-18 16:54:33 +02:00
timesteps with hires
This commit is contained in:
@@ -488,7 +488,7 @@ def process_diffusers(p: processing.StableDiffusionProcessing):
|
||||
desc='Base',
|
||||
)
|
||||
update_sampler(shared.sd_model)
|
||||
shared.state.sampling_steps = base_args.get('num_inference_steps', p.steps)
|
||||
shared.state.sampling_steps = base_args.get('num_inference_steps', None) or p.steps
|
||||
p.extra_generation_params['Pipeline'] = shared.sd_model.__class__.__name__
|
||||
if shared.opts.scheduler_eta is not None and shared.opts.scheduler_eta > 0 and shared.opts.scheduler_eta < 1:
|
||||
p.extra_generation_params["Sampler Eta"] = shared.opts.scheduler_eta
|
||||
@@ -594,7 +594,7 @@ def process_diffusers(p: processing.StableDiffusionProcessing):
|
||||
)
|
||||
update_sampler(shared.sd_model, second_pass=True)
|
||||
shared.state.job = 'hires'
|
||||
shared.state.sampling_steps = hires_args['num_inference_steps']
|
||||
shared.state.sampling_steps = hires_args.get('num_inference_steps', None) or p.steps
|
||||
try:
|
||||
sd_models_compile.check_deepcache(enable=True)
|
||||
output = shared.sd_model(**hires_args) # pylint: disable=not-callable
|
||||
@@ -658,7 +658,7 @@ def process_diffusers(p: processing.StableDiffusionProcessing):
|
||||
desc='Refiner',
|
||||
)
|
||||
update_sampler(shared.sd_refiner, second_pass=True)
|
||||
shared.state.sampling_steps = refiner_args['num_inference_steps']
|
||||
shared.state.sampling_steps = refiner_args.get('num_inference_steps', None) or p.steps
|
||||
try:
|
||||
if 'requires_aesthetics_score' in shared.sd_refiner.config: # sdxl-model needs false and sdxl-refiner needs true
|
||||
shared.sd_refiner.register_to_config(requires_aesthetics_score = getattr(shared.sd_refiner, 'tokenizer', None) is None)
|
||||
|
||||
@@ -438,8 +438,8 @@ def calculate_base_steps(p, use_denoise_start, use_refiner_start):
|
||||
return max(1, int(steps))
|
||||
|
||||
def calculate_hires_steps(p):
|
||||
if len(getattr(p, 'timesteps', [])) > 0:
|
||||
return None
|
||||
# if len(getattr(p, 'timesteps', [])) > 0:
|
||||
# return None
|
||||
if p.hr_second_pass_steps > 0:
|
||||
steps = (p.hr_second_pass_steps // p.denoising_strength) + 1
|
||||
elif p.denoising_strength > 0:
|
||||
@@ -450,8 +450,8 @@ def calculate_hires_steps(p):
|
||||
return max(1, int(steps))
|
||||
|
||||
def calculate_refiner_steps(p):
|
||||
if len(getattr(p, 'timesteps', [])) > 0:
|
||||
return None
|
||||
# if len(getattr(p, 'timesteps', [])) > 0:
|
||||
# return None
|
||||
if "StableDiffusionXL" in shared.sd_refiner.__class__.__name__:
|
||||
if p.refiner_start > 0 and p.refiner_start < 1:
|
||||
#steps = p.refiner_steps // (1 - p.refiner_start) # SDXL with denoise strenght
|
||||
|
||||
+15
-9
@@ -80,19 +80,25 @@ def apply_wildcards_to_prompt(prompt, all_wildcards):
|
||||
if len(prompt) == 0:
|
||||
return prompt
|
||||
replaced = {}
|
||||
t0 = time.time()
|
||||
for style_wildcards in all_wildcards:
|
||||
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
|
||||
t0 = time.time()
|
||||
prompt, replaced, not_found = apply_file_wildcards(prompt, [], [])
|
||||
try:
|
||||
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
|
||||
except Exception as e:
|
||||
shared.log.error(f'Wildcards: wildcard="{wildcard}" error={e}')
|
||||
t1 = time.time()
|
||||
if len(replaced) > 0 or len(not_found) > 0:
|
||||
shared.log.info(f'Wildcards applied: {replaced} missing: {not_found} path="{shared.opts.wildcards_dir}" time={t1-t0:.2f}')
|
||||
prompt, replaced_file, not_found = apply_file_wildcards(prompt, [], [])
|
||||
t2 = time.time()
|
||||
if replaced:
|
||||
shared.log.info(f'Wildcards applied: {replaced} path="{shared.opts.wildcards_dir}" type=style time={t1-t0:.2f}')
|
||||
if len(replaced_file) > 0 or len(not_found) > 0:
|
||||
shared.log.info(f'Wildcards applied: {replaced_file} missing: {not_found} path="{shared.opts.wildcards_dir}" type=file time={t2-t2:.2f} ')
|
||||
return prompt
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user