lquesada / ComfyUI-Inpaint-CropAndStitch

ComfyUI nodes to crop before sampling and stitch back after sampling that speed up inpainting
GNU General Public License v3.0
402 stars 23 forks source link

When the Mask is near the edges, the extended mask usually produce unwanted result, Can User disable that manually? #41

Closed LiJT closed 3 weeks ago

LiJT commented 3 weeks ago

Hi Devs! Please check my workflow here. I listed two different method for this inpainting case Explain Problem for CropAndStitch.json

WF overview show3

Show1 mask1 Check these two image shows, CropAndStitch forced to created a mask that extended the image somehow, I really really woult not like to do outpiant here!

mask2 show2 As you can see, the CropAndStitch method image is so wierd, because it is trying to make the "unseen" mirrored part of image coherent!!!

The end result looks terrible when my mask is near the edge, I know, I know, I know I can shrink the "Context expand factor", so inpaint area is much smaller. But then the inpaint model cannot look at the whole picture to make more coherent inpaint.

I really really like this node a lot. It is so elegant and require few node to run. Layerstyle on the other hand is very versatile and powerful. But, this method would not allow me to Shrink image size! Like Inpaint Crop does! So it is usually not ideal, plus Layerstyle node is huge

All in all. I just want User be able to toggle between the following mask by ourselves. I really really dont need to outpaint that extra stuff and ruining my image image

I hope you can catch me. Thank you so much for making this awesome node

lquesada commented 3 weeks ago

hi! one of the features of the crop and stitch nodes is that it allows overflowing out of the image with the purpose of ensuring that the target size is perfectly met. this of course has side effects in some particular setups.

Unfortunately you can't get the best of the two worlds :)

You could easily mitigate the issue by plugging in a second mask (optional_context_mask) to the crop node and drawing a bit more at the left than your mask. This will pull the context area towards the left.

LiJT commented 3 weeks ago

hi! one of the features of the crop and stitch nodes is that it allows overflowing out of the image with the purpose of ensuring that the target size is perfectly met. this of course has side effects in some particular setups.

Unfortunately you can't get the best of the two worlds :)

You could easily mitigate the issue by plugging in a second mask (optional_context_mask) to the crop node and drawing a bit more at the left than your mask. This will pull the context area towards the left.

Thank for the fast response!

I just wish there is function that allow us just make the Mask perfectly stuck along the edge of image? like the image shown here?. Because as we know, Flux AliMama controlNet is trained for that, It will create way better generation. Like the left one image below. image I am creating a fully automatic workflow for inpainting and outpainting, currently stuck at this issue. I know user can draw the addition mask but it is not that elegant dont you think?

Thank you once again, its just a feature suggestion. Please consider it!!!

lquesada commented 5 days ago

yeah... as said, while this would work for some use cases, it would break the flow of other use cases. The main point of the nodes is that they keep resolution a constant and they resize (upscale, downscale) before inpainting.

If I were to change the behavior, it would work for many other use cases (mostly manual inpainting) and lots of the semantics in the node (e.g. keeping the resolution).