Spaces:
Paused
Paused
lllyasviel
commited on
Commit
·
df0d128
1
Parent(s):
529b967
- modules/core.py +2 -2
- modules/cv2win32.py +30 -8
modules/core.py
CHANGED
@@ -82,9 +82,9 @@ def get_previewer(device, latent_format):
|
|
82 |
x_sample = x_sample.cpu().numpy().clip(0, 255).astype(np.uint8)
|
83 |
for i, s in enumerate(x_sample):
|
84 |
if i > 0:
|
85 |
-
show_preview(
|
86 |
else:
|
87 |
-
show_preview(
|
88 |
|
89 |
taesd.preview = preview_function
|
90 |
|
|
|
82 |
x_sample = x_sample.cpu().numpy().clip(0, 255).astype(np.uint8)
|
83 |
for i, s in enumerate(x_sample):
|
84 |
if i > 0:
|
85 |
+
show_preview(s, title=f'Preview Image {i}, step = [{step}/{total_steps}')
|
86 |
else:
|
87 |
+
show_preview(s, title=f'Preview Image, step = {step}/{total_steps}')
|
88 |
|
89 |
taesd.preview = preview_function
|
90 |
|
modules/cv2win32.py
CHANGED
@@ -1,14 +1,36 @@
|
|
|
|
1 |
import cv2
|
2 |
|
3 |
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
|
13 |
def close_all_preview():
|
14 |
-
|
|
|
|
|
|
|
|
1 |
+
import threading
|
2 |
import cv2
|
3 |
|
4 |
|
5 |
+
flag = 'fooocus_cv2win32'
|
6 |
+
buffer = []
|
7 |
+
|
8 |
+
|
9 |
+
def worker():
|
10 |
+
global buffer, flag
|
11 |
+
while True:
|
12 |
+
cv2.waitKey(50)
|
13 |
+
try:
|
14 |
+
if len(buffer) > 0:
|
15 |
+
task = buffer.pop(0)
|
16 |
+
if task is None:
|
17 |
+
cv2.destroyAllWindows()
|
18 |
+
else:
|
19 |
+
img, title = task
|
20 |
+
cv2.imshow(flag, img)
|
21 |
+
cv2.setWindowTitle(flag, title)
|
22 |
+
cv2.setWindowProperty(flag, cv2.WND_PROP_TOPMOST, 1)
|
23 |
+
except Exception as e:
|
24 |
+
print(e)
|
25 |
+
pass
|
26 |
+
|
27 |
+
|
28 |
+
def show_preview(img, title='preview'):
|
29 |
+
buffer.append((img, title))
|
30 |
|
31 |
|
32 |
def close_all_preview():
|
33 |
+
buffer.append(None)
|
34 |
+
|
35 |
+
|
36 |
+
threading.Thread(target=worker, daemon=True).start()
|