Skip to content

FluxInpaintPipeline overrides pixels outside the maskΒ #9867

@Clement-Lelievre

Description

@Clement-Lelievre

Describe the bug

When inpainting (with diffusers==0.31.0 and torch==2.4.1) using FluxInpaintPipeline, I get some pixels outside the mask (and pretty far away from the mask border) that are overrided whereas the mask at their indices was black.
With either flux schnell or dev.

Is this expected?

I could paste the input image on the output image using the mask to get rid of this, but I'd like to check first if this is a bug or not.

Here is my input image and mask:

vampire_input_rgb
vampire_mask

Here is the kind of diff I get:

diff

Reproduction

I am using a small, square (224*224) image (see above), and a non-rectangular mask that has values only in {0, 255}.

from diffusers import FluxInpaintPipeline

pipe = FluxInpaintPipeline.from_pretrained("black-forest-labs/FLUX.1-schnell", torch_dtype=torch.bfloat16, device='cuda')
prompt = "skull"
image= # above, convert it to RGB
mask = # above,  convert it to RGB
image = pipe(prompt=prompt, image=source, mask_image=mask, height=224, width=224, num_inference_steps=2, guidance_scale=3.5, strength=0.76).images[0]  # the latter params are probably not necessary to reproduce the issue
image.save("flux_inpainting.png")

# now visualize the pixel diff between the output you get and the input image, you should see non-zero pixels outside the mask, particularly on the right part

Logs

No response

System Info

  • πŸ€— Diffusers version: 0.31.0.dev0 or 0.31.0
  • Platform: Linux-5.15.0-1048-aws-x86_64-with-glibc2.31
  • Running on Google Colab?: No
  • Python version: 3.12.0
  • PyTorch version (GPU?): 2.4.1+cu121 (True)
  • Flax version (CPU?/GPU?/TPU?): not installed (NA)
  • Jax version: not installed
  • JaxLib version: not installed
  • Huggingface_hub version: 0.25.0
  • Transformers version: 4.44.2
  • Accelerate version: 0.34.2
  • PEFT version: 0.12.0
  • Bitsandbytes version: not installed
  • Safetensors version: 0.4.5
  • xFormers version: not installed
  • Accelerator: NVIDIA A10G, 23028 MiB

Who can help?

@asomoza @sayakpaul

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstaleIssues that haven't received updates

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions