Add tiling on vae decode for qwen image models when low vram flag is on
This commit is contained in:
@@ -284,6 +284,11 @@ class QwenImageModel(BaseModel):
|
|||||||
sc = self.get_bucket_divisibility()
|
sc = self.get_bucket_divisibility()
|
||||||
gen_config.width = int(gen_config.width // sc * sc)
|
gen_config.width = int(gen_config.width // sc * sc)
|
||||||
gen_config.height = int(gen_config.height // sc * sc)
|
gen_config.height = int(gen_config.height // sc * sc)
|
||||||
|
|
||||||
|
if self.model_config.low_vram:
|
||||||
|
# set vae to tile decode
|
||||||
|
pipeline.vae.enable_tiling()
|
||||||
|
|
||||||
img = pipeline(
|
img = pipeline(
|
||||||
prompt_embeds=conditional_embeds.text_embeds,
|
prompt_embeds=conditional_embeds.text_embeds,
|
||||||
prompt_embeds_mask=conditional_embeds.attention_mask.to(
|
prompt_embeds_mask=conditional_embeds.attention_mask.to(
|
||||||
@@ -302,6 +307,11 @@ class QwenImageModel(BaseModel):
|
|||||||
callback_on_step_end=callback_on_step_end,
|
callback_on_step_end=callback_on_step_end,
|
||||||
**extra,
|
**extra,
|
||||||
).images[0]
|
).images[0]
|
||||||
|
|
||||||
|
if self.model_config.low_vram:
|
||||||
|
# restore no tiling
|
||||||
|
pipeline.vae.disable_tiling()
|
||||||
|
|
||||||
return img
|
return img
|
||||||
|
|
||||||
def get_noise_prediction(
|
def get_noise_prediction(
|
||||||
|
|||||||
@@ -115,6 +115,10 @@ class QwenImageEditModel(QwenImageModel):
|
|||||||
|
|
||||||
return {"latents": latents}
|
return {"latents": latents}
|
||||||
|
|
||||||
|
if self.model_config.low_vram:
|
||||||
|
# set vae to tile decode
|
||||||
|
pipeline.vae.enable_tiling()
|
||||||
|
|
||||||
img = pipeline(
|
img = pipeline(
|
||||||
image=control_img,
|
image=control_img,
|
||||||
prompt_embeds=conditional_embeds.text_embeds,
|
prompt_embeds=conditional_embeds.text_embeds,
|
||||||
@@ -134,6 +138,11 @@ class QwenImageEditModel(QwenImageModel):
|
|||||||
callback_on_step_end=callback_on_step_end,
|
callback_on_step_end=callback_on_step_end,
|
||||||
**extra,
|
**extra,
|
||||||
).images[0]
|
).images[0]
|
||||||
|
|
||||||
|
if self.model_config.low_vram:
|
||||||
|
# restore no tiling
|
||||||
|
pipeline.vae.disable_tiling()
|
||||||
|
|
||||||
return img
|
return img
|
||||||
|
|
||||||
def condition_noisy_latents(
|
def condition_noisy_latents(
|
||||||
|
|||||||
@@ -133,6 +133,10 @@ class QwenImageEditPlusModel(QwenImageModel):
|
|||||||
|
|
||||||
return {"latents": latents}
|
return {"latents": latents}
|
||||||
|
|
||||||
|
if self.model_config.low_vram:
|
||||||
|
# set vae to tile decode
|
||||||
|
pipeline.vae.enable_tiling()
|
||||||
|
|
||||||
img = pipeline(
|
img = pipeline(
|
||||||
image=control_img_list,
|
image=control_img_list,
|
||||||
prompt_embeds=conditional_embeds.text_embeds,
|
prompt_embeds=conditional_embeds.text_embeds,
|
||||||
@@ -153,6 +157,11 @@ class QwenImageEditPlusModel(QwenImageModel):
|
|||||||
do_cfg_norm=gen_config.do_cfg_norm,
|
do_cfg_norm=gen_config.do_cfg_norm,
|
||||||
**extra,
|
**extra,
|
||||||
).images[0]
|
).images[0]
|
||||||
|
|
||||||
|
if self.model_config.low_vram:
|
||||||
|
# restore no tiling
|
||||||
|
pipeline.vae.disable_tiling()
|
||||||
|
|
||||||
return img
|
return img
|
||||||
|
|
||||||
def condition_noisy_latents(
|
def condition_noisy_latents(
|
||||||
|
|||||||
Reference in New Issue
Block a user