"docs/git@developer.sourcefind.cn:OpenDAS/vision.git" did not exist on "47834820e549a9295126a89c27ce399296a1490d"
Unverified Commit bbf70c87 authored by Aryan's avatar Aryan Committed by GitHub
Browse files

Fix truthy-ness condition in pipelines that use denoising_start (#6912)

* fix denoising start

* fix tests

* remove debug
parent 738c9869
...@@ -1766,7 +1766,7 @@ class SDXLLongPromptWeightingPipeline( ...@@ -1766,7 +1766,7 @@ class SDXLLongPromptWeightingPipeline(
# 4. Prepare timesteps # 4. Prepare timesteps
def denoising_value_valid(dnv): def denoising_value_valid(dnv):
return isinstance(self.denoising_end, float) and 0 < dnv < 1 return isinstance(dnv, float) and 0 < dnv < 1
timesteps, num_inference_steps = retrieve_timesteps(self.scheduler, num_inference_steps, device, timesteps) timesteps, num_inference_steps = retrieve_timesteps(self.scheduler, num_inference_steps, device, timesteps)
if image is not None: if image is not None:
...@@ -1774,7 +1774,7 @@ class SDXLLongPromptWeightingPipeline( ...@@ -1774,7 +1774,7 @@ class SDXLLongPromptWeightingPipeline(
num_inference_steps, num_inference_steps,
strength, strength,
device, device,
denoising_start=self.denoising_start if denoising_value_valid else None, denoising_start=self.denoising_start if denoising_value_valid(self.denoising_start) else None,
) )
# check that number of inference steps is not < 1 - as this doesn't make sense # check that number of inference steps is not < 1 - as this doesn't make sense
......
...@@ -1769,7 +1769,7 @@ class StyleAlignedSDXLPipeline( ...@@ -1769,7 +1769,7 @@ class StyleAlignedSDXLPipeline(
# 4. Prepare timesteps # 4. Prepare timesteps
def denoising_value_valid(dnv): def denoising_value_valid(dnv):
return isinstance(self.denoising_end, float) and 0 < dnv < 1 return isinstance(dnv, float) and 0 < dnv < 1
timesteps, num_inference_steps = retrieve_timesteps(self.scheduler, num_inference_steps, device, timesteps) timesteps, num_inference_steps = retrieve_timesteps(self.scheduler, num_inference_steps, device, timesteps)
...@@ -1778,7 +1778,7 @@ class StyleAlignedSDXLPipeline( ...@@ -1778,7 +1778,7 @@ class StyleAlignedSDXLPipeline(
num_inference_steps, num_inference_steps,
strength, strength,
device, device,
denoising_start=self.denoising_start if denoising_value_valid else None, denoising_start=self.denoising_start if denoising_value_valid(self.denoising_start) else None,
) )
# check that number of inference steps is not < 1 - as this doesn't make sense # check that number of inference steps is not < 1 - as this doesn't make sense
......
...@@ -1563,14 +1563,14 @@ class StableDiffusionXLControlNetAdapterInpaintPipeline(DiffusionPipeline, FromS ...@@ -1563,14 +1563,14 @@ class StableDiffusionXLControlNetAdapterInpaintPipeline(DiffusionPipeline, FromS
# 4. set timesteps # 4. set timesteps
def denoising_value_valid(dnv): def denoising_value_valid(dnv):
return isinstance(denoising_end, float) and 0 < dnv < 1 return isinstance(dnv, float) and 0 < dnv < 1
self.scheduler.set_timesteps(num_inference_steps, device=device) self.scheduler.set_timesteps(num_inference_steps, device=device)
timesteps, num_inference_steps = self.get_timesteps( timesteps, num_inference_steps = self.get_timesteps(
num_inference_steps, num_inference_steps,
strength, strength,
device, device,
denoising_start=denoising_start if denoising_value_valid else None, denoising_start=denoising_start if denoising_value_valid(denoising_start) else None,
) )
# check that number of inference steps is not < 1 - as this doesn't make sense # check that number of inference steps is not < 1 - as this doesn't make sense
if num_inference_steps < 1: if num_inference_steps < 1:
......
...@@ -1477,11 +1477,14 @@ class StableDiffusionXLControlNetInpaintPipeline( ...@@ -1477,11 +1477,14 @@ class StableDiffusionXLControlNetInpaintPipeline(
# 4. set timesteps # 4. set timesteps
def denoising_value_valid(dnv): def denoising_value_valid(dnv):
return isinstance(denoising_end, float) and 0 < dnv < 1 return isinstance(dnv, float) and 0 < dnv < 1
self.scheduler.set_timesteps(num_inference_steps, device=device) self.scheduler.set_timesteps(num_inference_steps, device=device)
timesteps, num_inference_steps = self.get_timesteps( timesteps, num_inference_steps = self.get_timesteps(
num_inference_steps, strength, device, denoising_start=denoising_start if denoising_value_valid else None num_inference_steps,
strength,
device,
denoising_start=denoising_start if denoising_value_valid(denoising_start) else None,
) )
# check that number of inference steps is not < 1 - as this doesn't make sense # check that number of inference steps is not < 1 - as this doesn't make sense
if num_inference_steps < 1: if num_inference_steps < 1:
......
...@@ -1315,14 +1315,14 @@ class StableDiffusionXLImg2ImgPipeline( ...@@ -1315,14 +1315,14 @@ class StableDiffusionXLImg2ImgPipeline(
# 5. Prepare timesteps # 5. Prepare timesteps
def denoising_value_valid(dnv): def denoising_value_valid(dnv):
return isinstance(self.denoising_end, float) and 0 < dnv < 1 return isinstance(dnv, float) and 0 < dnv < 1
timesteps, num_inference_steps = retrieve_timesteps(self.scheduler, num_inference_steps, device, timesteps) timesteps, num_inference_steps = retrieve_timesteps(self.scheduler, num_inference_steps, device, timesteps)
timesteps, num_inference_steps = self.get_timesteps( timesteps, num_inference_steps = self.get_timesteps(
num_inference_steps, num_inference_steps,
strength, strength,
device, device,
denoising_start=self.denoising_start if denoising_value_valid else None, denoising_start=self.denoising_start if denoising_value_valid(self.denoising_start) else None,
) )
latent_timestep = timesteps[:1].repeat(batch_size * num_images_per_prompt) latent_timestep = timesteps[:1].repeat(batch_size * num_images_per_prompt)
......
...@@ -1581,14 +1581,14 @@ class StableDiffusionXLInpaintPipeline( ...@@ -1581,14 +1581,14 @@ class StableDiffusionXLInpaintPipeline(
# 4. set timesteps # 4. set timesteps
def denoising_value_valid(dnv): def denoising_value_valid(dnv):
return isinstance(self.denoising_end, float) and 0 < dnv < 1 return isinstance(dnv, float) and 0 < dnv < 1
timesteps, num_inference_steps = retrieve_timesteps(self.scheduler, num_inference_steps, device, timesteps) timesteps, num_inference_steps = retrieve_timesteps(self.scheduler, num_inference_steps, device, timesteps)
timesteps, num_inference_steps = self.get_timesteps( timesteps, num_inference_steps = self.get_timesteps(
num_inference_steps, num_inference_steps,
strength, strength,
device, device,
denoising_start=self.denoising_start if denoising_value_valid else None, denoising_start=self.denoising_start if denoising_value_valid(self.denoising_start) else None,
) )
# check that number of inference steps is not < 1 - as this doesn't make sense # check that number of inference steps is not < 1 - as this doesn't make sense
if num_inference_steps < 1: if num_inference_steps < 1:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment