mirror of
https://github.com/vladmandic/automatic
synced 2026-09-20 01:31:13 +02:00
add force latent sampler
This commit is contained in:
+1
-1
@@ -77,7 +77,7 @@ def torch_gc():
|
||||
torch.cuda.ipc_collect()
|
||||
except:
|
||||
pass
|
||||
shared.log.debug(f'gc: {torch.device(get_optimal_device_name())} {memstats.memory_stats()}')
|
||||
shared.log.debug(f'gc: device={torch.device(get_optimal_device_name())} {memstats.memory_stats()}')
|
||||
|
||||
|
||||
def test_fp16():
|
||||
|
||||
+6
-6
@@ -367,55 +367,55 @@ class ScriptRunner:
|
||||
return processed
|
||||
|
||||
def process(self, p, **kwargs):
|
||||
log.debug(f'Script process: {[s.title() for s in self.alwayson_scripts]}')
|
||||
for script in self.alwayson_scripts:
|
||||
try:
|
||||
args = p.per_script_args.get(script.title(), p.script_args[script.args_from:script.args_to])
|
||||
log.debug(f'Script process: {script.title()}')
|
||||
script.process(p, *args, **kwargs)
|
||||
except Exception as e:
|
||||
errors.display(e, f'Running script process: {script.filename}')
|
||||
|
||||
def before_process_batch(self, p, **kwargs):
|
||||
log.debug(f'Script before-process-batch: {[s.title() for s in self.alwayson_scripts]}')
|
||||
for script in self.alwayson_scripts:
|
||||
try:
|
||||
args = p.per_script_args.get(script.title(), p.script_args[script.args_from:script.args_to])
|
||||
log.debug(f'Script before-process-batch: {script.title()}')
|
||||
script.before_process_batch(p, *args, **kwargs)
|
||||
except Exception as e:
|
||||
errors.display(e, f'Running script before process batch: {script.filename}')
|
||||
|
||||
def process_batch(self, p, **kwargs):
|
||||
log.debug(f'Script process-batch: {[s.title() for s in self.alwayson_scripts]}')
|
||||
for script in self.alwayson_scripts:
|
||||
try:
|
||||
args = p.per_script_args.get(script.title(), p.script_args[script.args_from:script.args_to])
|
||||
log.debug(f'Script process-batch: {script.title()}')
|
||||
script.process_batch(p, *args, **kwargs)
|
||||
except Exception as e:
|
||||
errors.display(e, f'Running script process batch: {script.filename}')
|
||||
|
||||
def postprocess(self, p, processed):
|
||||
log.debug(f'Script postprocess: {[s.title() for s in self.alwayson_scripts]}')
|
||||
for script in self.alwayson_scripts:
|
||||
try:
|
||||
args = p.per_script_args.get(script.title(), p.script_args[script.args_from:script.args_to])
|
||||
log.debug(f'Script postprocess: {script.title()}')
|
||||
script.postprocess(p, processed, *args)
|
||||
except Exception as e:
|
||||
errors.display(e, f'Running script postprocess: {script.filename}')
|
||||
|
||||
def postprocess_batch(self, p, images, **kwargs):
|
||||
log.debug(f'Script postprocess-batch: {[s.title() for s in self.alwayson_scripts]}')
|
||||
for script in self.alwayson_scripts:
|
||||
try:
|
||||
args = p.per_script_args.get(script.title(), p.script_args[script.args_from:script.args_to])
|
||||
log.debug(f'Script postprocess-batch: {script.title()}')
|
||||
script.postprocess_batch(p, *args, images=images, **kwargs)
|
||||
except Exception as e:
|
||||
errors.display(e, f'Running script before postprocess batch: {script.filename}')
|
||||
|
||||
def postprocess_image(self, p, pp: PostprocessImageArgs):
|
||||
log.debug(f'Script postprocess-image: {[s.title() for s in self.alwayson_scripts]}')
|
||||
for script in self.alwayson_scripts:
|
||||
try:
|
||||
args = p.per_script_args.get(script.title(), p.script_args[script.args_from:script.args_to])
|
||||
log.debug(f'Script postprocess-image: {script.title()}')
|
||||
script.postprocess_image(p, pp, *args)
|
||||
except Exception as e:
|
||||
errors.display(e, f'Running script postprocess image: {script.filename}')
|
||||
|
||||
@@ -431,6 +431,7 @@ options_templates.update(options_section(('ui', "Live previews"), {
|
||||
options_templates.update(options_section(('sampler-params', "Sampler parameters"), {
|
||||
"show_samplers": OptionInfo(["Euler a", "UniPC", "DDIM", "DPM++ SDE", "DPM++ SDE", "DPM2 Karras", "DPM++ 2M Karras"], "Show samplers in user interface", gr.CheckboxGroup, lambda: {"choices": [x.name for x in list_samplers() if x.name != "PLMS"]}),
|
||||
"fallback_sampler": OptionInfo("Euler a", "Secondary sampler", gr.Dropdown, lambda: {"choices": ["None"] + [x.name for x in list_samplers()]}),
|
||||
"force_latent_upscaler": OptionInfo("None", "Force latent upscaler sampler", gr.Dropdown, lambda: {"choices": ["None"] + [x.name for x in list_samplers()]}),
|
||||
"eta_ancestral": OptionInfo(1.0, "Noise multiplier for ancestral samplers (eta)", gr.Slider, {"minimum": 0.0, "maximum": 1.0, "step": 0.01}),
|
||||
"eta_ddim": OptionInfo(0.0, "Noise multiplier for DDIM (eta)", gr.Slider, {"minimum": 0.0, "maximum": 1.0, "step": 0.01}),
|
||||
"ddim_discretize": OptionInfo('uniform', "DDIM discretize img2img", gr.Radio, {"choices": ['uniform', 'quad']}),
|
||||
|
||||
+3
-1
@@ -350,6 +350,7 @@ class SharedSettingsStackHelper(object):
|
||||
self.token_merging_random = shared.opts.token_merging_random
|
||||
self.sd_model_checkpoint = shared.opts.sd_model_checkpoint
|
||||
self.sd_vae_checkpoint = shared.opts.sd_vae
|
||||
self.xyz_fallback_sampler = shared.opts.data["xyz_fallback_sampler"]
|
||||
|
||||
def __exit__(self, exc_type, exc_value, tb):
|
||||
#Restore overriden settings after plot generation.
|
||||
@@ -359,6 +360,7 @@ class SharedSettingsStackHelper(object):
|
||||
shared.opts.data["token_merging_ratio_hr"] = self.token_merging_ratio_hr
|
||||
shared.opts.data["token_merging_ratio"] = self.token_merging_ratio
|
||||
shared.opts.data["token_merging_random"] = self.token_merging_random
|
||||
shared.opts.data["xyz_fallback_sampler"] = self.xyz_fallback_sampler
|
||||
if self.sd_model_checkpoint != shared.opts.sd_model_checkpoint:
|
||||
shared.opts.data["sd_model_checkpoint"] = self.sd_model_checkpoint
|
||||
sd_models.reload_model_weights()
|
||||
@@ -512,7 +514,7 @@ class Script(scripts.Script):
|
||||
else:
|
||||
valslist_ext.append(val)
|
||||
valslist = valslist_ext
|
||||
elif opt.type == str_permutations:
|
||||
elif opt.type == str_permutations: # pylint: disable=comparison-with-callable
|
||||
valslist = list(permutations(valslist))
|
||||
valslist = [opt.type(x) for x in valslist]
|
||||
# Confirm options are valid before starting
|
||||
|
||||
Reference in New Issue
Block a user