fix tgate apply/unapply

This commit is contained in:
Vladimir Mandic
2024-06-04 07:12:12 -04:00
parent 901784f3b5
commit f84705d079
3 changed files with 10 additions and 7 deletions
+4 -2
View File
@@ -21,6 +21,7 @@ class Script(scripts.Script):
return [enabled, gate_step]
def run(self, p: processing.StableDiffusionProcessing, enabled, gate_step): # pylint: disable=arguments-differ
p.gate_step = min(gate_step, p.steps) if enabled else -1
if not enabled:
return None
install('tgate')
@@ -33,11 +34,12 @@ class Script(scripts.Script):
shared.log.warning(f'T-Gate: pipeline={shared.sd_model_type} required=sd or sdxl')
return None
old_pipe = shared.sd_model
shared.sd_model = cls(shared.sd_model, gate_step=min(gate_step, p.steps))
shared.sd_model = cls(shared.sd_model, gate_step=p.gate_step)
sd_models.copy_diffuser_options(shared.sd_model, old_pipe)
sd_models.move_model(shared.sd_model, devices.device) # move pipeline to device
sd_models.set_diffuser_options(shared.sd_model, vae=None, op='model')
shared.log.debug(f'T-Gate: pipeline={shared.sd_model.__class__.__name__} steps={gate_step}')
shared.log.debug(f'T-Gate: pipeline={shared.sd_model.__class__.__name__} steps={p.gate_step}')
processed = processing.process_images(p)
shared.sd_model = old_pipe
del shared.sd_model.tgate
return processed