sd-webui-controlnet icon indicating copy to clipboard operation
sd-webui-controlnet copied to clipboard

Inpainting masked results in different resolution

Open jonesi13 opened this issue 2 years ago • 12 comments

Using inpaint with inpaint masked and only masked options results in the output being distorted.

I'm not sure how the resize modes are supposed to work, but sometimes even with the same settings the results are different. Like one in 30 times the output will actually match the same size somehow.

Changing width and height sometimes affects it and sometimes doesn't. Every time I thought I found the settings that work the next time I load a new image the same settings don't work anymore.

Maybe it's a bug or maybe I'm doing something wrong with how I have it set up?

11 222 3333

For example, in this case the face is larger than the original.

01273-2098427154-(1guy_0 978), (artist_name_0 712), (bangs_0 355), (brown_eyes_0 622), (brown_hair_0 490), (curly_hair_0 722), (grey_background_0 01275-1049909563-(1guy_0 978), (artist_name_0 712), (bangs_0 355), (brown_eyes_0 622), (brown_hair_0 490), (curly_hair_0 722), (grey_background_0 tmp3ae71smq

jonesi13 avatar Feb 22 '23 13:02 jonesi13

I have added a clearer example of the issue. Same settings. You can see that the head is greatly enlarged.

image 01340-3690393578-(1girl_0 998), (bare_shoulders_0 412), (collarbone_0 459), (forehead_0 642), (grin_0 496), (lips_0 798), (long_hair_0 832), (loo 01348-1989368069-(1girl_0 998), (bare_shoulders_0 412), (collarbone_0 459), (forehead_0 642), (grin_0 496), (lips_0 798), (long_hair_0 832), (loo tmp44bppos5-1

jonesi13 avatar Feb 23 '23 00:02 jonesi13

And then same result but a bit better after altering the input image size. So it is somehow related to image sizes, but no idea how. The distortion seems to happen espeiakll downwards/sideways.

01349-248606434-(1girl_0 998), (bare_shoulders_0 412), (collarbone_0 459), (forehead_0 642), (grin_0 496), (lips_0 798), (long_hair_0 832), (loo tmpelffciuk-1

jonesi13 avatar Feb 23 '23 00:02 jonesi13

Also results for changing to outter fit. (never found a case where this one is decent) 01365-2619994641-(1girl_0 998), (bare_shoulders_0 412), (collarbone_0 459), (forehead_0 642), (grin_0 496), (lips_0 798), (long_hair_0 832), (loo tmpbtqto01_-1

And resize. 01366-2753028813-(1girl_0 998), (bare_shoulders_0 412), (collarbone_0 459), (forehead_0 642), (grin_0 496), (lips_0 798), (long_hair_0 832), (loo tmphg44v8ct-1

jonesi13 avatar Feb 23 '23 01:02 jonesi13

Same thing happens if you crop the image in img2img. In this case, rather than processing the cropped area, it's processing the whole image, resizing to the new resolution and applying the map over the cropped area. Thus the map and the image are completely out of sync.

image image image

So maybe rather than just resizing, there should be some cropping involved in the process?

jonesi13 avatar Feb 23 '23 14:02 jonesi13

I'm running into this same issue.

lendrick avatar Feb 26 '23 22:02 lendrick

I can now say with almost full certainty that it is related to Mask blur. A value of 0 does not distort the image, while increasing it distorts the image for each extra pixel. @Mikubill

jonesi13 avatar Feb 27 '23 03:02 jonesi13

Yep, was just looking for this issue's writeup. Looks like it is in fact the mask blur isn't offsetting properly. I'm guessing it's supposed to offset properly on the x and y axis equal to the blur, but it's definitely not factoring in the outside mask properly.

It seems to be processing the image at the larger size but then it puts it back in at the same location at the original unmasked size. image Here's an example of a bookshelf because it has the best contrast of straight lines. Used Hed and Canny for detail. You can see the zoomed shelf is higher and lower meaning the x and y aren't properly scaled but are centered properly.

It also doesn't properly center when the mask + padding is on an image border. Instead of throwing away the overflow, it pushes the image over to place it which messes with the justification. image Here it pushed the entire mask down to fit rather than centering like it does in the middle of the image.

--Edit: Ok, fixed the images. My mistake. Some of the images were fuzzy.

CraigFedynich avatar Mar 01 '23 21:03 CraigFedynich

Anyone else having issues doing inpainting with controlnet enabled these days, with all the most recent updates? The masks are getting ignored when I enable a controlnet in my latest tests.

marcsyp avatar Mar 08 '23 20:03 marcsyp

Anyone else having issues doing inpainting with controlnet enabled these days, with all the most recent updates? The masks are getting ignored when I enable a controlnet in my latest tests.

Yes, I have the same issue

jaschahuisman avatar Mar 10 '23 16:03 jaschahuisman

Same issue here! I am thinking maybe try turning off mask blur and using Poisson Blending to process the boundary?

jowangjo avatar Apr 06 '23 13:04 jowangjo

On Sat, Apr 15, 2023 at 8:36 AM Mark @.***> wrote:

Anyone else having issues doing inpainting with controlnet enabled these days, with all the most recent updates? The masks are getting ignored when I enable a controlnet in my latest tests.

+1 For me it generates whole new image with controlnet, like im using text2image

— Reply to this email directly, view it on GitHub https://github.com/Mikubill/sd-webui-controlnet/issues/288#issuecomment-1509832531, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4GG6U7SVBQ26VHK2JRI2W3XBKP47ANCNFSM6AAAAAAVELHXDU . You are receiving this because you commented.Message ID: @.***>

Ive not had that issue. Controlnet works, i just can’t do a mask blur. I always have to use mask padding instead.

CraigFedynich avatar Apr 15 '23 17:04 CraigFedynich

On Sat, Apr 15, 2023 at 8:36 AM Mark @.> wrote: Anyone else having issues doing inpainting with controlnet enabled these days, with all the most recent updates? The masks are getting ignored when I enable a controlnet in my latest tests. +1 For me it generates whole new image with controlnet, like im using text2image — Reply to this email directly, view it on GitHub <#288 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4GG6U7SVBQ26VHK2JRI2W3XBKP47ANCNFSM6AAAAAAVELHXDU . You are receiving this because you commented.Message ID: @.> Ive not had that issue. Controlnet works, i just can’t do a mask blur. I always have to use mask padding instead.

sry, I didn't mention a thing:

  • It doesn't work with open pose models (background completely changes)

MarkGree avatar Apr 15 '23 17:04 MarkGree

Huh. I’ll give it a go. What settings for inpaint and control net when it’s being run? Also, what is the preprocessor generating for your image?

On Sat, Apr 15, 2023 at 12:21 PM Mark @.***> wrote:

On Sat, Apr 15, 2023 at 8:36 AM Mark @.> wrote: Anyone else having issues doing inpainting with controlnet enabled these days, with all the most recent updates? The masks are getting ignored when I enable a controlnet in my latest tests. +1 For me it generates whole new image with controlnet, like im using text2image — Reply to this email directly, view it on GitHub <#288 (comment) https://github.com/Mikubill/sd-webui-controlnet/issues/288#issuecomment-1509832531>, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4GG6U7SVBQ26VHK2JRI2W3XBKP47ANCNFSM6AAAAAAVELHXDU https://github.com/notifications/unsubscribe-auth/A4GG6U7SVBQ26VHK2JRI2W3XBKP47ANCNFSM6AAAAAAVELHXDU . You are receiving this because you commented.Message ID: @.> Ive not had that issue. Controlnet works, i just can’t do a mask blur. I always have to use mask padding instead.

sry, I didn't mention a thing:

  • It doesn't work with open pose models (background completely changes)

— Reply to this email directly, view it on GitHub https://github.com/Mikubill/sd-webui-controlnet/issues/288#issuecomment-1509899481, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4GG6U3R7V3II7KGNHZDPWLXBLKJFANCNFSM6AAAAAAVELHXDU . You are receiving this because you commented.Message ID: @.***>

CraigFedynich avatar Apr 16 '23 23:04 CraigFedynich

Huh. I’ll give it a go. What settings for inpaint and control net when it’s being run? Also, what is the preprocessor generating for your image? On Sat, Apr 15, 2023 at 12:21 PM Mark @.> wrote: On Sat, Apr 15, 2023 at 8:36 AM Mark @.> wrote: Anyone else having issues doing inpainting with controlnet enabled these days, with all the most recent updates? The masks are getting ignored when I enable a controlnet in my latest tests. +1 For me it generates whole new image with controlnet, like im using text2image — Reply to this email directly, view it on GitHub <#288 (comment) <#288 (comment)>>, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4GG6U7SVBQ26VHK2JRI2W3XBKP47ANCNFSM6AAAAAAVELHXDU https://github.com/notifications/unsubscribe-auth/A4GG6U7SVBQ26VHK2JRI2W3XBKP47ANCNFSM6AAAAAAVELHXDU . You are receiving this because you commented.Message ID: @.> Ive not had that issue. Controlnet works, i just can’t do a mask blur. I always have to use mask padding instead. sry, I didn't mention a thing: - It doesn't work with open pose models (background completely changes) — Reply to this email directly, view it on GitHub <#288 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4GG6U3R7V3II7KGNHZDPWLXBLKJFANCNFSM6AAAAAAVELHXDU . You are receiving this because you commented.Message ID: @.**>

Default settings of img2img inpaint, but with a painted area to replace Controlnet preprocessor - openpose, model - openpose (tried t2iadapter_openpose_sd14v1 and control_v11p_sd15_openpose), same image as inpaint image set Also I tried both "Inpaint area"s: fill whole and only masked

MarkGree avatar Apr 17 '23 03:04 MarkGree