From 70811d0bd0dc83b4b914e8ed33f74d941881ed6e Mon Sep 17 00:00:00 2001 From: Brandon Rising Date: Fri, 13 Dec 2024 23:53:22 -0500 Subject: [PATCH] Remove unexpected artifacts in output images --- invokeai/backend/flux/flux_tools_sampling_utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/invokeai/backend/flux/flux_tools_sampling_utils.py b/invokeai/backend/flux/flux_tools_sampling_utils.py index 4bd72f3db9..fd44de3e3d 100644 --- a/invokeai/backend/flux/flux_tools_sampling_utils.py +++ b/invokeai/backend/flux/flux_tools_sampling_utils.py @@ -15,14 +15,14 @@ def prepare_control( ) -> torch.Tensor: # load and encode the conditioning image img_cond = cond_image.convert("RGB") - img_cond = img_cond.resize((width, height), Image.Resampling.LANCZOS) + img_cond = img_cond.resize((width, height), Image.Resampling.BICUBIC) img_cond = np.array(img_cond) - img_cond = torch.from_numpy(img_cond).float() + img_cond = torch.from_numpy(img_cond).float() / 127.5 - 1.0 img_cond = rearrange(img_cond, "h w c -> 1 c h w") ae_dtype = next(iter(ae.parameters())).dtype ae_device = next(iter(ae.parameters())).device img_cond = img_cond.to(device=ae_device, dtype=ae_dtype) generator = torch.Generator(device=ae_device).manual_seed(seed) - img_cond = ae.encode(img_cond, sample=True, generator=generator) + img_cond = ae.encode(img_cond, sample=False, generator=generator) img_cond = rearrange(img_cond, "b c (h ph) (w pw) -> b (h w) (c ph pw)", ph=2, pw=2) return img_cond