Acly / comfyui-inpaint-nodes

Nodes for better inpainting with ComfyUI: Fooocus inpaint model for SDXL, LaMa, MAT, and various other tools for pre-filling inpaint & outpaint areas.
GNU General Public License v3.0
490 stars 35 forks source link

Naive implementation of batch support #59

Closed vojtajina closed 2 weeks ago

vojtajina commented 1 month ago

Iterate over all images and call the fill functionality for each image sequentially and then stack the results back together.

It’s probably gonna be much faster to do it with single tensor, but I don’t have time to figure that out. If someone knows how to do that, please feel free to send a patch, or tell me how to do it.

vojtajina commented 1 month ago

This is naive implementation of #20

vojtajina commented 1 month ago

Actually, it's not solving all the issues. This only fixes MaskedFill node, but there are other hooks/patches that fail during more complex workflows.

Acly commented 3 weeks ago

I think the issue in MaskedFill was mostly this line:

mask.expand(1, *mask.shape[-2:])

and the rest already work for batches. So there's no need to put another loop.

Acly commented 3 weeks ago

I pushed a minimal version: https://github.com/Acly/comfyui-inpaint-nodes/commit/59af54b72d70d28ae49c07cf56e89899e81a3397

As for adapting the inapint node, I think your code works.

Maybe simplify it to:

inpaint = inpaint_head_feature.to(h)
h = h + inpaint.repeat(h.shape[0] // inpaint.shape[0], 1, 1, 1)

?