Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Txt2mask padding dilate #38

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

credman0
Copy link

(This is on top of my previous pr that fixes the rgba txt2mask error, otherwise I can't run anything)

I tried for a bit to fix the padding in txt2mask, but conceptually I don't think that the way that it was working (a resize and a crop) is actually how you need it to work to properly pad the mask. Since we have opencv anyway, this pr changes it to a dilate on the mask, which is closer to padding pixels around the alpha areas.

It isn't perfect, since a dilate loses a lot of the definition of the mask. Probably what we actually want is to threshold a distance map which I believe will give us a better result, but it's at the very least more than I want to get into tonight.

@credman0
Copy link
Author

Oh and this effectively addresses #37

@ThereforeGames
Copy link
Owner

conceptually I don't think that the way that it was working (a resize and a crop) is actually how you need it to work to properly pad the mask.

Yeah, no kidding! I must have been pretty tired when I implemented padding. :) It resizes the canvas from the center, rather than from the origin of the masked area(s).

It sounds like dilate is a much better approach. I'll give your code a spin and probably merge it in the next update. A bit of quality loss is likely okay--at least for the time being--as the A1111 inpainting feature is pretty forgiving when it comes to mask imperfections.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants