Skip to content

Commit d94fd54

Browse files
authored
Merge pull request #5 from blepping/fix_avoid_forced_workflow_rerun
Change step state handling to avoid having to force a workflow rerun
2 parents 3ce5438 + b143f4e commit d94fd54

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

__init__.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@ def randn_like(cond, generator=None):
1212

1313
class CADS:
1414
current_step = 0
15-
16-
@classmethod
17-
def IS_CHANGED(*args, **kwargs):
18-
return float("nan")
15+
last_sigma = None
1916

2017
@classmethod
2118
def INPUT_TYPES(s):
@@ -44,7 +41,8 @@ def do(self, model, noise_scale, t1, t2, rescale=0.0, start_step=-1, total_steps
4441
previous_wrapper = model.model_options.get("model_function_wrapper")
4542

4643
im = model.model.model_sampling
47-
CADS.current_step = start_step
44+
self.current_step = start_step
45+
self.last_sigma = None
4846

4947
skip = None
5048
if apply_to == "cond":
@@ -57,8 +55,12 @@ def cads_gamma(sigma):
5755
ts = im.timestep(sigma[0])
5856
t = round(ts.item() / 999.0, 2)
5957
else:
60-
t = 1.0 - min(1.0, max(CADS.current_step / total_steps, 0.0))
61-
CADS.current_step += 1
58+
sigma_max = sigma.max().item()
59+
if self.last_sigma is not None and sigma_max > self.last_sigma:
60+
self.current_step = start_step
61+
t = 1.0 - min(1.0, max(self.current_step / total_steps, 0.0))
62+
self.current_step += 1
63+
self.last_sigma = sigma_max
6264

6365
if t <= t1:
6466
r = 1.0

0 commit comments

Comments
 (0)