Fix: Handle edge case for img2img
This commit is contained in:
parent
74173f543e
commit
821238284a
@ -53,14 +53,16 @@ class RuntimeConfig:
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def init_time_step(self) -> int:
|
def init_time_step(self) -> int:
|
||||||
if self.config.init_image_path is None:
|
is_txt2img = self.config.init_image_path is None or self.config.init_image_strength == 0.0
|
||||||
# For text-to-image, always begin at time step 0.
|
|
||||||
|
if is_txt2img:
|
||||||
return 0
|
return 0
|
||||||
else:
|
else:
|
||||||
# For image-to-image: higher strength means we skip more steps.
|
# 1. Clamp strength to [0, 1]
|
||||||
strength = max(0.0, min(1.0, self.config.init_image_strength))
|
strength = max(0.0, min(1.0, self.config.init_image_strength))
|
||||||
t = max(1, int(self.num_inference_steps * strength))
|
|
||||||
return t
|
# 2. Return start time in [1, floor(num_steps * strength)]
|
||||||
|
return max(1, int(self.num_inference_steps * strength))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def controlnet_strength(self) -> float | None:
|
def controlnet_strength(self) -> float | None:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user