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

Fix handling of conditioning masks #40

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

keilladraconis
Copy link

Allow me to preface: I don't know a thing about PyTorch, Diffusion, Arrays, Tensors, or any of this nonsense. I'm just a girl who wants to mask and tile. 😷

First problem. In slice_cond the branches that handle areas expect cond to be a tuple. cond is not a tuple. Removed the indexing which clears the error in #36

Second problem, the tensor is not the size the sampler expects it to be later on in the process. I did a lots of debugger and eventually glazed that mask tensors are 3-dimensional with no color information, while other tensors are 4-dimensional. But some functions here are turning a nice mask tensor into a full-color tensor.

See, comfy.sample.prepare_mask fluffs up the tensor from a typical mask tensor of mask X x-pos X y-pos to a mask X rgba X x-pos X y-pos size. Not a problem for a while until it is.

So I lifted that function and did a little squeeze to remove the baby dimension that gets injected when the reshape interpolates the tensor into the size which interpolate can handle (for whatever reason it requires a 4-dimensional array or it dies (pytorch is a dumpster fire of raccoons who are also on fire)).

Is this correct? I don't know. Is it right? Who knows. Does it stop the crashes when your condies have maskeys? Yes. It stops those.

Someone with maths please just take this PR and make it beautiful. And write some tests.

Also I don't know squat about Python.

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.

1 participant