lllyasviel commited on
Commit
12df4d8
·
1 Parent(s): daed9ab
Files changed (1) hide show
  1. modules/core.py +7 -1
modules/core.py CHANGED
@@ -20,6 +20,8 @@ opCLIPTextEncode = CLIPTextEncode()
20
  opEmptyLatentImage = EmptyLatentImage()
21
  opVAEDecode = VAEDecode()
22
 
 
 
23
 
24
  class StableDiffusionModel:
25
  def __init__(self, unet, vae, clip, clip_vision):
@@ -62,6 +64,7 @@ def get_previewer(device, latent_format):
62
  taesd = TAESD(None, taesd_decoder_path).to(device)
63
 
64
  def preview_function(x0, step, total_steps):
 
65
  with torch.no_grad():
66
  x_sample = taesd.decoder(x0).detach() * 255.0
67
  x_sample = einops.rearrange(x_sample, 'b c h w -> b h w c')
@@ -70,7 +73,9 @@ def get_previewer(device, latent_format):
70
  flag = f'OpenCV Diffusion Preview {i}'
71
  cv2.imshow(flag, s)
72
  cv2.setWindowTitle(flag, f'Preview Image {i} [{step}/{total_steps}]')
73
- cv2.setWindowProperty(flag, cv2.WND_PROP_TOPMOST, 1)
 
 
74
  cv2.waitKey(1)
75
 
76
  taesd.preview = preview_function
@@ -79,6 +84,7 @@ def get_previewer(device, latent_format):
79
 
80
 
81
  def close_all_preview():
 
82
  cv2.destroyAllWindows()
83
 
84
 
 
20
  opEmptyLatentImage = EmptyLatentImage()
21
  opVAEDecode = VAEDecode()
22
 
23
+ cv2_is_top = False
24
+
25
 
26
  class StableDiffusionModel:
27
  def __init__(self, unet, vae, clip, clip_vision):
 
64
  taesd = TAESD(None, taesd_decoder_path).to(device)
65
 
66
  def preview_function(x0, step, total_steps):
67
+ global cv2_is_top
68
  with torch.no_grad():
69
  x_sample = taesd.decoder(x0).detach() * 255.0
70
  x_sample = einops.rearrange(x_sample, 'b c h w -> b h w c')
 
73
  flag = f'OpenCV Diffusion Preview {i}'
74
  cv2.imshow(flag, s)
75
  cv2.setWindowTitle(flag, f'Preview Image {i} [{step}/{total_steps}]')
76
+ if not cv2_is_top:
77
+ cv2.setWindowProperty(flag, cv2.WND_PROP_TOPMOST, 1)
78
+ cv2_is_top = True
79
  cv2.waitKey(1)
80
 
81
  taesd.preview = preview_function
 
84
 
85
 
86
  def close_all_preview():
87
+ cv2_is_top = False
88
  cv2.destroyAllWindows()
89
 
90