lllyasviel / stable-diffusion-webui-forge

GNU Affero General Public License v3.0
5.28k stars 519 forks source link

[Bug]: Fix TypeError: 'NoneType' object is not iterable when generating img2img with controlllite #768

Open sssdaiki opened 1 month ago

sssdaiki commented 1 month ago

Checklist

What happened?

When dealing with intermediate image sizes such as upscaling 1248×1248 by 1.5 times, Controlllite throws a NoneType object error. This issue occurs around line 234 in torch.cat within extensions-builtin/sd_forge_controlllite/lib_controllllite/lib_controllllite.py due to a mismatch in tensor sizes between cx and x. I resolved this by using padding as a simple fix. While padding may affect the performance of the generated images, it is less problematic than having Controlllite not function at all. Here is the code:

if cx.shape[1] < x.shape[1]:
    cx_pad = torch.zeros(cx.shape[0], x.shape[1]-cx.shape[1], cx.shape[2], dtype=cx.dtype, device=cx.device)
    cx = torch.cat([cx, cx_pad], dim=1)

Steps to reproduce the problem

1.5x upscaling of a 1248x1248 image using the controllllite model for img2img.

What should have happened?

controllllite should have worked.

What browsers do you use to access the UI ?

No response

Sysinfo

sysinfo-2024-05-29-09-21.json

Console logs

https://pastebin.com/gxT0wyCL

Additional information

invoking it from EasySdxlWebUi