fix(backend): fix controlnet zip len

Do not use `strict=True` when scaling controlnet conditioning.

When using `guess_mode` (e.g. `more_control` or `more_prompt`), `down_block_res_samples` and `scales` are zipped.

These two objects are of different lengths, so using zip's strict mode raises an error.

In testing, `len(scales) === len(down_block_res_samples) + 1`.

It appears this behaviour is intentional, as the final "extra" item in `scales` is used immediately afterwards.
This commit is contained in:
psychedelicious 2023-11-13 15:06:04 +11:00
parent 355d4cf4e2
commit 04d8f2dfea

View File

@ -748,7 +748,7 @@ class ControlNetModel(ModelMixin, ConfigMixin, FromOriginalControlnetMixin):
scales = scales * conditioning_scale
down_block_res_samples = [
sample * scale for sample, scale in zip(down_block_res_samples, scales, strict=True)
sample * scale for sample, scale in zip(down_block_res_samples, scales, strict=False)
]
mid_block_res_sample = mid_block_res_sample * scales[-1] # last one
else: