mirror of
https://github.com/lllyasviel/Fooocus.git
synced 2026-08-16 13:13:16 +02:00
i
This commit is contained in:
+2
-2
@@ -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(f'OpenCV Diffusion Preview {i}', s, title=f'Preview Image {i} [{step}/{total_steps}]')
|
show_preview(s, title=f'Preview Image {i}, step = [{step}/{total_steps}')
|
||||||
else:
|
else:
|
||||||
show_preview(f'OpenCV Diffusion Preview {i}', s, title=f'Preview Image [{step}/{total_steps}]')
|
show_preview(s, title=f'Preview Image, step = {step}/{total_steps}')
|
||||||
|
|
||||||
taesd.preview = preview_function
|
taesd.preview = preview_function
|
||||||
|
|
||||||
|
|||||||
+30
-8
@@ -1,14 +1,36 @@
|
|||||||
|
import threading
|
||||||
import cv2
|
import cv2
|
||||||
|
|
||||||
|
|
||||||
def show_preview(flag, img, title=None):
|
flag = 'fooocus_cv2win32'
|
||||||
if title is None:
|
buffer = []
|
||||||
title = flag
|
|
||||||
cv2.imshow(flag, img[:, :, ::-1].copy())
|
|
||||||
cv2.setWindowTitle(flag, title)
|
def worker():
|
||||||
cv2.setWindowProperty(flag, cv2.WND_PROP_TOPMOST, 1)
|
global buffer, flag
|
||||||
cv2.waitKey(1)
|
while True:
|
||||||
|
cv2.waitKey(50)
|
||||||
|
try:
|
||||||
|
if len(buffer) > 0:
|
||||||
|
task = buffer.pop(0)
|
||||||
|
if task is None:
|
||||||
|
cv2.destroyAllWindows()
|
||||||
|
else:
|
||||||
|
img, title = task
|
||||||
|
cv2.imshow(flag, img)
|
||||||
|
cv2.setWindowTitle(flag, title)
|
||||||
|
cv2.setWindowProperty(flag, cv2.WND_PROP_TOPMOST, 1)
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def show_preview(img, title='preview'):
|
||||||
|
buffer.append((img, title))
|
||||||
|
|
||||||
|
|
||||||
def close_all_preview():
|
def close_all_preview():
|
||||||
cv2.destroyAllWindows()
|
buffer.append(None)
|
||||||
|
|
||||||
|
|
||||||
|
threading.Thread(target=worker, daemon=True).start()
|
||||||
|
|||||||
Reference in New Issue
Block a user