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

[Feature]: Add a 'Mask' input image parameter #429

Open
altoiddealer opened this issue Apr 23, 2024 · 1 comment
Open

[Feature]: Add a 'Mask' input image parameter #429

altoiddealer opened this issue Apr 23, 2024 · 1 comment
Labels
enhancement New feature or request 🔬 research

Comments

@altoiddealer
Copy link

Feature description

Related to #292 which I'm guessing is perhaps too heavy handed or overly technical.

I'm suggesting to add an API param and UI input for a 'mask' image (B+W map).

In regards to the UI, it would only be practical with controlnet, or lightly denoised img2img, or Extras - so such an addition may only be applicable to the Img2Img and Extras tab.

Ideally, the UI would include a "Create mask canvas" thing like the newer versions of ControlNet have, where user can quickly paint their mask.

@altoiddealer altoiddealer added enhancement New feature or request new labels Apr 23, 2024
@altoiddealer
Copy link
Author

Just following up that I've added this to my discord bot and it is working.

async def apply_reactor_mask(temp_dir, images, pnginfo, reactor_mask):
    try:
        reactor_mask = Image.open(io.BytesIO(base64.b64decode(reactor_mask))).convert('L')
        orig_image = images[0]                                          # Open original image
        face_image = images.pop(1)                                      # Open image with faceswap applied
        face_image.putalpha(reactor_mask)                               # Apply reactor mask as alpha to faceswap image
        orig_image.paste(face_image, (0, 0), face_image)                # Paste the masked faceswap image onto the original
        orig_image.save(f'{temp_dir}/temp_img_0.png', pnginfo=pnginfo)  # Save the image with correct pnginfo
        images[0] = orig_image                                          # Replace first image in images list
        return images
    except Exception as e:
        logging.error(f'Error masking ReActor output images: {e}')

In case that's half the work towards implementing such a feature...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request 🔬 research
Projects
None yet
Development

No branches or pull requests

2 participants