This commit is contained in:
lvmin 2023-08-11 05:21:40 -07:00
parent 6bd69367aa
commit bc4b420071
2 changed files with 6 additions and 7 deletions

View File

@ -82,9 +82,9 @@ def get_previewer(device, latent_format):
x_sample = x_sample.cpu().numpy().clip(0, 255).astype(np.uint8) x_sample = x_sample.cpu().numpy().clip(0, 255).astype(np.uint8)
for i, s in enumerate(x_sample): for i, s in enumerate(x_sample):
if i > 0: if i > 0:
show_preview(s, title=f'Preview Image {i}, step = [{step}/{total_steps}') show_preview(f'cv2_preview_{i}', s, title=f'Preview Image {i}, step = [{step}/{total_steps}')
else: else:
show_preview(s, title=f'Preview Image, step = {step}/{total_steps}') show_preview(f'cv2_preview_{i}', s, title=f'Preview Image, step = {step}/{total_steps}')
taesd.preview = preview_function taesd.preview = preview_function

View File

@ -2,12 +2,11 @@ import threading
import cv2 import cv2
flag = 'fooocus_cv2win32'
buffer = [] buffer = []
def worker(): def worker():
global buffer, flag global buffer
while True: while True:
cv2.waitKey(50) cv2.waitKey(50)
try: try:
@ -16,7 +15,7 @@ def worker():
if task is None: if task is None:
cv2.destroyAllWindows() cv2.destroyAllWindows()
else: else:
img, title = task flag, img, title = task
cv2.imshow(flag, img) cv2.imshow(flag, img)
cv2.setWindowTitle(flag, title) cv2.setWindowTitle(flag, title)
cv2.setWindowProperty(flag, cv2.WND_PROP_TOPMOST, 1) cv2.setWindowProperty(flag, cv2.WND_PROP_TOPMOST, 1)
@ -25,8 +24,8 @@ def worker():
pass pass
def show_preview(img, title='preview'): def show_preview(flag, img, title='preview'):
buffer.append((img, title)) buffer.append((flag, img.copy(), title))
def close_all_preview(): def close_all_preview():