mirror of
https://github.com/lllyasviel/stable-diffusion-webui-forge.git
synced 2026-02-07 08:29:58 +00:00
Update forge_reference.py
This commit is contained in:
@@ -18,6 +18,8 @@ class PreprocessorReference(Preprocessor):
|
||||
self.corp_image_with_a1111_mask_when_in_img2img_inpaint_tab = False
|
||||
self.do_not_need_model = True
|
||||
|
||||
self.is_recording_style = False
|
||||
|
||||
def process_before_every_sampling(self, process, cond, *args, **kwargs):
|
||||
unit = kwargs['unit']
|
||||
weight = float(unit.weight)
|
||||
@@ -25,6 +27,12 @@ class PreprocessorReference(Preprocessor):
|
||||
start_percent = float(unit.guidance_start)
|
||||
end_percent = float(unit.guidance_end)
|
||||
|
||||
vae = process.sd_model.forge_objects.vae
|
||||
# This is a powerful VAE with integrated memory management, bf16, and tiled fallback.
|
||||
|
||||
latent_image = vae.encode(cond.movedim(1, -1))
|
||||
latent_image = process.sd_model.forge_objects.unet.model.latent_format.process_in(latent_image)
|
||||
|
||||
unet = process.sd_model.forge_objects.unet.clone()
|
||||
sigma_max = unet.model.model_sampling.percent_to_sigma(start_percent)
|
||||
sigma_min = unet.model.model_sampling.percent_to_sigma(end_percent)
|
||||
@@ -34,7 +42,9 @@ class PreprocessorReference(Preprocessor):
|
||||
if not (sigma_min <= sigma <= sigma_max):
|
||||
return model, x, timestep, uncond, cond, cond_scale, model_options, seed
|
||||
|
||||
a = 0
|
||||
self.is_recording_style = True
|
||||
|
||||
self.is_recording_style = False
|
||||
|
||||
return model, x, timestep, uncond, cond, cond_scale, model_options, seed
|
||||
|
||||
|
||||
Reference in New Issue
Block a user