Spaces:
Running on Zero
Running on Zero
Update pk_workflow.py
Browse files- pk_workflow.py +14 -3
pk_workflow.py
CHANGED
|
@@ -552,10 +552,21 @@ class use_schedule:
|
|
| 552 |
scheduler = getattr(self.pipe, attr_name)
|
| 553 |
sigmas_full = time_shift_sigma(base, 1.0, float(scheduler.shift))
|
| 554 |
sigmas = sigmas_full[self.stage_from : self.stage_from + self.steps + 1]
|
| 555 |
-
unbound = type(scheduler).set_timesteps
|
| 556 |
|
| 557 |
-
def forced(num_inference_steps=None, device=None, sigmas=None, _s=scheduler, _grid=sigmas
|
| 558 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 559 |
|
| 560 |
scheduler.set_timesteps = forced
|
| 561 |
|
|
|
|
| 552 |
scheduler = getattr(self.pipe, attr_name)
|
| 553 |
sigmas_full = time_shift_sigma(base, 1.0, float(scheduler.shift))
|
| 554 |
sigmas = sigmas_full[self.stage_from : self.stage_from + self.steps + 1]
|
|
|
|
| 555 |
|
| 556 |
+
def forced(num_inference_steps=None, device=None, sigmas=None, _s=scheduler, _grid=sigmas):
|
| 557 |
+
# Replicates `MiniMaxH3Scheduler.set_timesteps`'s own `sigmas=` branch exactly
|
| 558 |
+
# (`scheduling_minimax_h3.py`) rather than calling through to it — its validation requires
|
| 559 |
+
# the array to end at exactly 0.0, correct for a complete trajectory but wrong for an
|
| 560 |
+
# intermediate Staged Denoising slice, which legitimately ends at whatever sigma this stage
|
| 561 |
+
# stops at. Still requires strictly decreasing, at least two points.
|
| 562 |
+
grid = torch.as_tensor(_grid, dtype=torch.float32).flatten().cpu()
|
| 563 |
+
if grid.numel() < 2 or not bool((grid[1:] < grid[:-1]).all()):
|
| 564 |
+
raise ValueError("`sigmas` must hold at least two strictly decreasing values.")
|
| 565 |
+
_s.sigmas = grid.to(device=device)
|
| 566 |
+
_s.timesteps = (1.0 - grid[:-1]).to(device=device)
|
| 567 |
+
_s.num_inference_steps = int(_s.timesteps.numel())
|
| 568 |
+
_s._step_index = None
|
| 569 |
+
_s._begin_index = None
|
| 570 |
|
| 571 |
scheduler.set_timesteps = forced
|
| 572 |
|