Spaces:
Paused
Paused
Commit
·
a8aa05c
1
Parent(s):
2491f48
- modules/core.py +12 -8
modules/core.py
CHANGED
|
@@ -58,6 +58,17 @@ def get_previewer(device, latent_format):
|
|
| 58 |
|
| 59 |
taesd = TAESD(None, taesd_decoder_path).to(device)
|
| 60 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
return taesd
|
| 62 |
|
| 63 |
|
|
@@ -84,14 +95,7 @@ def ksampler(model, positive, negative, latent, seed=None, steps=30, cfg=9.0, sa
|
|
| 84 |
|
| 85 |
def callback(step, x0, x, total_steps):
|
| 86 |
if previewer and step % 3 == 0:
|
| 87 |
-
|
| 88 |
-
x_sample = previewer.decoder(x0).detach() * 255.0
|
| 89 |
-
x_sample = einops.rearrange(x_sample, 'b c h w -> b h w c')
|
| 90 |
-
x_sample = x_sample.cpu().numpy()[..., ::-1].copy().clip(0, 255).astype(np.uint8)
|
| 91 |
-
|
| 92 |
-
for i, s in enumerate(x_sample):
|
| 93 |
-
cv2.imshow(f'Preview {i}', s)
|
| 94 |
-
cv2.waitKey(1)
|
| 95 |
pbar.update_absolute(step + 1, total_steps, None)
|
| 96 |
|
| 97 |
samples = comfy.sample.sample(model, noise, steps, cfg, sampler_name, scheduler, positive, negative, latent_image,
|
|
|
|
| 58 |
|
| 59 |
taesd = TAESD(None, taesd_decoder_path).to(device)
|
| 60 |
|
| 61 |
+
def preview_function(x0):
|
| 62 |
+
with torch.no_grad():
|
| 63 |
+
x_sample = taesd.decoder(x0).detach() * 255.0
|
| 64 |
+
x_sample = einops.rearrange(x_sample, 'b c h w -> b h w c')
|
| 65 |
+
x_sample = x_sample.cpu().numpy()[..., ::-1].copy().clip(0, 255).astype(np.uint8)
|
| 66 |
+
for i, s in enumerate(x_sample):
|
| 67 |
+
cv2.imshow(f'Preview {i}', s)
|
| 68 |
+
cv2.waitKey(1)
|
| 69 |
+
|
| 70 |
+
taesd.preview = preview_function
|
| 71 |
+
|
| 72 |
return taesd
|
| 73 |
|
| 74 |
|
|
|
|
| 95 |
|
| 96 |
def callback(step, x0, x, total_steps):
|
| 97 |
if previewer and step % 3 == 0:
|
| 98 |
+
previewer.preview(x0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
pbar.update_absolute(step + 1, total_steps, None)
|
| 100 |
|
| 101 |
samples = comfy.sample.sample(model, noise, steps, cfg, sampler_name, scheduler, positive, negative, latent_image,
|