Haoming02 / sd-forge-couple

An Extension for Forge Webui that implements Attention Couple
GNU General Public License v3.0
160 stars 8 forks source link

Fix mask mapping validation #28

Closed ramyma closed 2 months ago

ramyma commented 2 months ago

I found that after the last update that the mask mapping validation is not correct. Mask mapping will always have a background, so I took the liberty to distill down the checks with the expected values.

Fixes #29

Haoming02 commented 2 months ago

Hmm. I modified it so that background is not necessary for Mask mode. In the example provided in Wiki, I simply used 2 masks that occupy half of the image each, and it worked for me.

In theory, it should also work if you specify it to use background.

ramyma commented 2 months ago

It didn't work for me when I passed background First Line, mode Mask, a background weight and a prompt with GLOBAL <SEP> REGION 1 <SEP> REGION 2

ramyma commented 2 months ago

AssertionError: [Couple] Masks contain non-filled areas...

{
    "args": [
        true,
        "Mask",
        "<SEP>",
        "Horizontal",
        "None",
        0.3,
        [
            {
                "mask": MASK,
                "weight": 1
            }
        ]
    ]
}

prompt: test

ramyma commented 2 months ago

In my previous tests, the code used to fail if the there's no background (global) prompt

ramyma commented 2 months ago

Keep in mind that the masks most likely won't cover all the image space, so, without a global prompt the attention math won't work properly here: https://github.com/Haoming02/sd-forge-couple/blob/main/scripts/attention_couple.py#L25

I believe the changes in this PR solves the issue, I tested it with my integration and it's looking good.

Haoming02 commented 2 months ago

Keep in mind that the masks most likely won't cover all the image space

It's up to the user to fill the entire image, or just use background. But yes, the validation logics were wrong.