This commit is contained in:
lvmin
2023-08-10 18:45:06 -07:00
parent a08a7f254c
commit 336493292b
3 changed files with 17 additions and 17 deletions
+2 -16
View File
@@ -15,6 +15,7 @@ from nodes import VAEDecode, EmptyLatentImage, CLIPTextEncode
from comfy.sample import prepare_mask, broadcast_cond, load_additional_models, cleanup_additional_models
from modules.samplers_advanced import KSampler, KSamplerWithRefiner
from modules.adm_patch import patch_negative_adm
from modules.cv2win32 import show_preview
patch_negative_adm()
@@ -22,8 +23,6 @@ opCLIPTextEncode = CLIPTextEncode()
opEmptyLatentImage = EmptyLatentImage()
opVAEDecode = VAEDecode()
cv2_is_top = False
class StableDiffusionModel:
def __init__(self, unet, vae, clip, clip_vision):
@@ -82,26 +81,13 @@ def get_previewer(device, latent_format):
x_sample = einops.rearrange(x_sample, 'b c h w -> b h w c')
x_sample = x_sample.cpu().numpy()[..., ::-1].copy().clip(0, 255).astype(np.uint8)
for i, s in enumerate(x_sample):
flag = f'OpenCV Diffusion Preview {i}'
cv2.imshow(flag, s)
cv2.setWindowTitle(flag, f'Preview Image {i} [{step}/{total_steps}]')
if not cv2_is_top:
cv2.setWindowProperty(flag, cv2.WND_PROP_TOPMOST, 1)
cv2_is_top = True
else:
cv2.setWindowProperty(flag, cv2.WND_PROP_TOPMOST, 0)
cv2.waitKey(1)
show_preview(f'OpenCV Diffusion Preview {i}', s, title=f'Preview Image {i} [{step}/{total_steps}]')
taesd.preview = preview_function
return taesd
def close_all_preview():
cv2_is_top = False
cv2.destroyAllWindows()
@torch.no_grad()
def ksampler(model, positive, negative, latent, seed=None, steps=30, cfg=7.0, sampler_name='dpmpp_2m_sde_gpu',
scheduler='karras', denoise=1.0, disable_noise=False, start_step=None, last_step=None,