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 -4
View File
@@ -16,9 +16,9 @@
write your prompts forin ~110 auto-detected languages!
compatible with SD15 and SDXL
enable in scripts -> MuLan and set encoder to `InternVL-14B-224px` encoder
*Note*: right now this is more of a proof-of-concept before smaller and/or quantized models are released
*note*: right now this is more of a proof-of-concept before smaller and/or quantized models are released
model will be auto-downloaded on first use: note its huge size of 27GB
even executing it in FP16 context will require ~16GB of VRAM for text encoder alone
even executing it in FP16 will require ~16GB of VRAM for text encoder alone
examples:
- English: photo of a beautiful woman wearing a white bikini on a beach with a city skyline in the background
- Croatian: fotografija lijepe žene u bijelom bikiniju na plaži s gradskim obzorom u pozadini
@@ -35,8 +35,8 @@
download from <https://huggingface.co/Kijai/converted_pcm_loras_fp16/tree/main>
- **Kohya HiRes Fix** allows for higher resolution generation using standard sd15 models
enable via scripts -> kohya-hires-fix
*note*: this alternative to regular hidiffusion method, but with different approach to scaling
- additional built-in controlnet models: TODO
*note*: alternative to regular hidiffusion method, but with different approach to scaling
- additional built-in **ControlNet** models: TODO
- lower overhead on generate calls
- cumulative fixes since the last release
+2 -1
View File
@@ -116,7 +116,8 @@ def process_diffusers(p: processing.StableDiffusionProcessing):
hidiffusion.apply_hidiffusion(p, shared.sd_model_type)
# if 'image' in base_args:
# base_args['image'] = set_latents(p)
if hasattr(shared.sd_model, 'tgate'):
if hasattr(shared.sd_model, 'tgate') and getattr(p, 'gate_step', -1) > 0:
base_args['gate_step'] = p.gate_step
output = shared.sd_model.tgate(**base_args) # pylint: disable=not-callable
else:
output = shared.sd_model(**base_args)
+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