From 480c62320ccf58dd3dccd579ef1dced5a35cc65c Mon Sep 17 00:00:00 2001 From: Ryan Dick Date: Fri, 30 Aug 2024 15:09:55 +0000 Subject: [PATCH] Use the existence of initial latents to decide whether we are doing image-to-image in the FLUX denoising node. Previously we were using the denoising_start value, but in some cases with an inpaintin mask you may want to run image-to-image from densoising_start=0. --- invokeai/app/invocations/flux_text_to_image.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/invokeai/app/invocations/flux_text_to_image.py b/invokeai/app/invocations/flux_text_to_image.py index 68b46b11a7..613145b5b2 100644 --- a/invokeai/app/invocations/flux_text_to_image.py +++ b/invokeai/app/invocations/flux_text_to_image.py @@ -131,10 +131,14 @@ class FluxTextToImageInvocation(BaseInvocation, WithMetadata, WithBoard): ) # Prepare input latent image. - if self.denoising_start > 1e-5: - # If denoising_start > 0, we are doing image-to-image. - if init_latents is None: - raise ValueError("latents must be provided if denoising_start > 0.") + if init_latents is not None: + # If init_latents is provided, we are doing image-to-image. + + if is_schnell: + context.logger.warning( + "Running image-to-image with a FLUX schnell model. This is not recommended. The results are likely " + "to be poor. Consider using a FLUX dev model instead." + ) # Clip the timesteps schedule based on denoising_start. # TODO(ryand): Should we apply denoising_start in timestep-space rather than timestep-index-space? @@ -145,7 +149,10 @@ class FluxTextToImageInvocation(BaseInvocation, WithMetadata, WithBoard): t_0 = timesteps[0] x = t_0 * noise + (1.0 - t_0) * init_latents else: - # We are not doing image-to-image, so start from noise. + # init_latents are not provided, so we are not doing image-to-image (i.e. we are starting from pure noise). + if self.denoising_start > 1e-5: + raise ValueError("denoising_start should be 0 when initial latents are not provided.") + x = noise inpaint_mask = self._prep_inpaint_mask(context, x)