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

它的还原方式是个很大的问题 #16

Closed LAOGOU-666 closed 5 months ago

LAOGOU-666 commented 5 months ago

image 即使我重绘做的很好,但是还原的时候图像边缘仍然出现色差 如果这个问题能解决,我相信会有更多人爱上这个节点

lquesada commented 5 months ago

Five ways to improve this. I'm sorting them from most likely to help to more exploratory:

With any or several of these, you'll get it to work flawlessly.

LAOGOU-666 commented 5 months ago

我发现其实他还原时定位是准确的,只是重绘的时候整个图片产生了色差,导致还原部分颜色有差别,我会试试你说的方式,感谢回复!

lquesada commented 5 months ago

It's not about the positioning. When there's more context area, the model is more likely to match the colors around. Let me know how it works!

LAOGOU-666 commented 5 months ago

我发现问题了 采样器会对剪裁的整张图片进行处理,导致重绘后的整张裁剪部分图片的颜色发生细微的改变,这种改变无法跟原图保持百分百一致的,所以导致还原的时候会有色差, 增加遮罩扩展数值可以让边缘不那么明显,但是细心点还是能看到点区别, 所以直接覆盖还原的方式并不能解决色差问题,和模型和遮罩处理无关,因为我前面得出的再好,到还原这一步还是会失败, stitch节点工作原理应该是直接覆盖,还原时不能对遮罩再进行处理,这就导致了边缘部分过渡很生硬 我通过下面这种方式能够完美解决这个问题 image

lquesada commented 5 months ago

That would work in some cases but it may decrease the resolution of the cropped image (e.g. if the node has to do downscaling as part of cropping). It will also pass that cropped image through VAE encode/decode which can introduce artifacts.

I'd advise you to try the other mechanisms I proposed above.

LAOGOU-666 commented 5 months ago

image 其他方式我都试过了,只有在图像和crop之间连接一个模糊遮罩,并适当调高上下文区域,这样得出来的图像遮罩边缘能平滑过渡 因为直接涂抹的遮罩边缘很粗糙,在还原的过程中使用粗糙的遮罩会使边缘融合效果变得很差,而stitch还原时使用的遮罩是我们的输入遮罩,而不是裁剪后的遮罩,所以在crop和samples之间增加模糊并不会改善边缘的融合度 image 这是我使用缩小的结果

lquesada commented 5 months ago

Excellent!

LAOGOU-666 commented 5 months ago

这是个很棒的节点,能够大大的提高效率,我很喜欢它,感谢你的工作!

lquesada commented 5 months ago

glad you like it :) thank you!!

lquesada commented 5 months ago

hi! please update the node. Then, you'll have to recreate the node to get the new default settings and avoid errors.

the crop node now supports "blur" and "blend". Try them for example at a value of 16, you'll achieve seamless results with them. Please let me know!

LAOGOU-666 commented 5 months ago

刚才测试了,我测试了特定形状的遮罩和手涂遮罩,结果是特定形状的遮罩条件下,效果比grow mask要好,虽然不知道那个blend pixels怎么做到的,但是感觉好厉害,别的节点似乎都没有这样的技术,有了这项功能这个节点就非常的棒了,可以应用到很多环境中,再次感谢你的辛苦贡献!

LAOGOU-666 commented 5 months ago

image 我又发现了这样的问题,这个位置如果添加了反转遮罩,stitch没有可以反转的选项, 这个设定就是限定在某个区域内重绘遮罩的部分,但是如果我并不是重绘遮罩部分,而是选择重绘这个区域内的背景,这样就没办法弄了,因为stitch不支持反转 有的时候会需要先定位到物体那里,然后更改物体那里的背景, 当然这种情况很少见

lquesada commented 5 months ago

Have you tried the "invert mask" option in the Crop node? It will reverse the mask just as you want!

Hsu-Chia commented 5 months ago

"Hello, I have a small question. Can the Inpaint Crop node mask connect to another PNG image as a mask? I got a poor-quality image."

image

lquesada commented 5 months ago

It can, but it must be the exact format and specifications of a mask. Otherwise it won't work. Not sure what is the easiest way to do this

LAOGOU-666 commented 5 months ago

可能是我说的不太清楚,您的crop节点里面的invert键是输入端反转,开启后我就无法定位到指定的物体上,我想对物体定位的方框内反转,我想要更改部分区域的背景,而不是整张图的背景

lquesada commented 5 months ago

Ah I see. This is not supported and will not be supported because it's not a standard use case and would cause confusion among other users.

LAOGOU-666 commented 5 months ago

好的,谢谢,这确实是个比较小众的功能,感谢回复!