fix sd35 with batch

Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
Vladimir Mandic
2025-03-19 10:49:45 -04:00
parent 9c0846ba4f
commit d5cfd61e50
3 changed files with 15 additions and 9 deletions
+3 -1
View File
@@ -3,8 +3,9 @@
## Update for 2025-03-17
### TODO
- Gemma3 requires `git+https://github.com/huggingface/transformers@v4.49.0-Gemma-3`
- Gemma3 requires `transformers==git+https://github.com/huggingface/transformers@v4.49.0-Gemma-3`
- Remote VAE encode for SD15 and Flux.1: <https://github.com/huggingface/diffusers/issues/11069>
- HunyuanVideo-I2V: <https://github.com/huggingface/diffusers/issues/11118>
### Highlights for 2025-03-17
@@ -50,6 +51,7 @@ Support for [CogView 4](https://huggingface.co/THUDM/CogView4-6B), new CLiP mode
- add quantization support to **CogView-3Plus**
- update `diffusers` and other requirements
- rename vae, unet and text-encoder settings *None* to *Default* to avoid confusion
- **CLI**: add `cli/api-grid.py` which can generate grids using params-from-file for x/y axis
- **IPEX**
- add `--upgrade` to torch_command when using `--use-nightly`
- add xpu to profiler
-3
View File
@@ -293,9 +293,6 @@ def vae_decode(latents, model, output_type='np', vae_type='Full', width=None, he
latents = model._unpack_latents(latents, height, width, model.vae_scale_factor) # pylint: disable=protected-access
if len(latents.shape) == 3: # lost a batch dim in hires
latents = latents.unsqueeze(0)
if latents.shape[0] == 4 and latents.shape[1] != 4: # likely animatediff latent
latents = latents.permute(1, 0, 2, 3)
if latents.shape[-1] <= 4: # not a latent, likely an image
decoded = latents.float().cpu().numpy()
elif vae_type == 'Full' and hasattr(model, "vae"):
+12 -5
View File
@@ -63,6 +63,12 @@ def hijack_encode_prompt(*args, **kwargs):
return res
def get_quant(args):
if args is not None and "quantization_config" in args:
return args['quantization_config'].__class__.__name__
return None
def load(selected):
if selected is None:
return
@@ -75,7 +81,7 @@ def load(selected):
quant_args = model_quant.create_config(module='Model')
cls = diffusers.HunyuanVideoTransformer3DModel
try:
debug(f'Video load: module=transofrmer repo="{selected.dit}" subfolder="{selected.subfolder}" cls={cls.__name__} quant={quant_args is not None}')
debug(f'Video load: module=transofrmer repo="{selected.dit}" subfolder="{selected.subfolder}" cls={cls.__name__} quant={get_quant(quant_args)}')
transformer = cls.from_pretrained(
pretrained_model_name_or_path=selected.dit,
subfolder=selected.subfolder,
@@ -92,7 +98,7 @@ def load(selected):
else:
cls = transformers.LlamaModel
try:
debug(f'Video load: module=te repo="{selected.repo}" cls={cls.__name__} quant={quant_args is not None}')
debug(f'Video load: module=te repo="{selected.repo}" cls={cls.__name__} quant={get_quant(quant_args)}')
text_encoder = cls.from_pretrained(
pretrained_model_name_or_path=selected.repo,
subfolder="text_encoder",
@@ -107,7 +113,7 @@ def load(selected):
cls = transformers.CLIPTextModel
try:
debug(f'Video load: module=clip repo="{selected.repo}" cls={cls.__name__} quant=False')
debug(f'Video load: module=clip repo="{selected.repo}" cls={cls.__name__} quant=None')
text_encoder_2 = transformers.CLIPTextModel.from_pretrained(
pretrained_model_name_or_path=selected.repo,
subfolder="text_encoder_2",
@@ -119,7 +125,7 @@ def load(selected):
cls = diffusers.AutoencoderKLHunyuanVideo
try:
debug(f'Video load: module=vae repo="{selected.repo}" cls={cls.__name__} quant=False')
debug(f'Video load: module=vae repo="{selected.repo}" cls={cls.__name__} quant=None')
vae = diffusers.AutoencoderKLHunyuanVideo.from_pretrained(
pretrained_model_name_or_path=selected.repo,
subfolder="vae",
@@ -136,7 +142,7 @@ def load(selected):
else:
cls = diffusers.HunyuanVideoPipeline
try:
debug(f'Video load: module=pipe repo="{selected.repo}" cls={cls.__name__} quant=False')
debug(f'Video load: module=pipe repo="{selected.repo}" cls={cls.__name__} quant=None')
shared.sd_model = cls.from_pretrained(
pretrained_model_name_or_path=selected.repo,
transformer=transformer,
@@ -205,6 +211,7 @@ def generate(*args, **kwargs):
shared.log.error('Video: init image not set')
return [], None, '', '', 'Error: init image not set'
p.task_args['image'] = init_image
# from PIL import Image
# p.task_args['image'] = init_image.resize((336, 336), Image.Resampling.LANCZOS)
shared.sd_model = sd_models.apply_balanced_offload(shared.sd_model)