Skip to content

Commit

Permalink
Invert the expected denoise_mask parameter to the FLUX Denoise node t…
Browse files Browse the repository at this point in the history
…o match the behaviour of Denoise Latents node used for SD.
  • Loading branch information
RyanJDick committed Sep 13, 2024
1 parent 865f419 commit 680b8c0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
5 changes: 4 additions & 1 deletion invokeai/app/invocations/create_gradient_mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@
class GradientMaskOutput(BaseInvocationOutput):
"""Outputs a denoise mask and an image representing the total gradient of the mask."""

denoise_mask: DenoiseMaskField = OutputField(description="Mask for denoise model run")
denoise_mask: DenoiseMaskField = OutputField(
description="Mask for denoise model run. Values of 0.0 represent the regions to be fully denoised, and 1.0 "
+ "represent the regions to be preserved."
)
expanded_mask_area: ImageField = OutputField(
description="Image representing the total gradient area of the mask. For paste-back purposes."
)
Expand Down
2 changes: 1 addition & 1 deletion invokeai/app/invocations/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class FieldDescriptions:
)
num_1 = "The first number"
num_2 = "The second number"
denoise_mask = "A mask of the region to apply the denoising process to."
denoise_mask = "A mask of the region to apply the denoising process to. Values of 0.0 represent the regions to be fully denoised, and 1.0 represent the regions to be preserved."
board = "The board to save the image to"
image = "The image to process"
tile_size = "Tile size"
Expand Down
10 changes: 8 additions & 2 deletions invokeai/app/invocations/flux_denoise.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
title="FLUX Denoise",
tags=["image", "flux"],
category="image",
version="1.0.0",
version="2.0.0",
classification=Classification.Prototype,
)
class FluxDenoiseInvocation(BaseInvocation, WithMetadata, WithBoard):
Expand Down Expand Up @@ -220,13 +220,19 @@ def _prep_inpaint_mask(self, context: InvocationContext, latents: torch.Tensor)
device, and dtype for the inpaint mask.
Returns:
torch.Tensor | None: Inpaint mask.
torch.Tensor | None: Inpaint mask. Values of 0.0 represent the regions to be fully denoised, and 1.0
represent the regions to be preserved.
"""
if self.denoise_mask is None:
return None

mask = context.tensors.load(self.denoise_mask.mask_name)

# The input denoise_mask contains values in [0, 1], where 0.0 represents the regions to be fully denoised, and
# 1.0 represents the regions to be preserved.
# We invert the mask so that the regions to be preserved are 0.0 and the regions to be denoised are 1.0.
mask = 1.0 - mask

_, _, latent_height, latent_width = latents.shape
mask = tv_resize(
img=mask,
Expand Down

0 comments on commit 680b8c0

Please sign in to comment.