mirror of
https://github.com/lllyasviel/Fooocus.git
synced 2026-08-16 13:13:16 +02:00
1.0.16 (#19)
### 1.0.16 * Implemented "output" folder for saving user results. * Ignored cv2 errors when preview fails. * Mentioned future AMD support in Readme. * Created this log.
This commit is contained in:
+13
-5
@@ -1,5 +1,6 @@
|
||||
import threading
|
||||
import cv2
|
||||
import os
|
||||
|
||||
|
||||
buffer = []
|
||||
@@ -7,9 +8,9 @@ buffer = []
|
||||
|
||||
def worker():
|
||||
global buffer
|
||||
while True:
|
||||
cv2.waitKey(50)
|
||||
try:
|
||||
try:
|
||||
while True:
|
||||
cv2.waitKey(50)
|
||||
if len(buffer) > 0:
|
||||
task = buffer.pop(0)
|
||||
if task is None:
|
||||
@@ -19,11 +20,18 @@ def worker():
|
||||
cv2.imshow(flag, img)
|
||||
cv2.setWindowTitle(flag, title)
|
||||
cv2.setWindowProperty(flag, cv2.WND_PROP_TOPMOST, 1)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
except Exception as e:
|
||||
print('Failed to open preview window. You are not using a local device with GUI support.')
|
||||
print(e)
|
||||
pass
|
||||
|
||||
|
||||
def save_image(path, img):
|
||||
os.makedirs(os.path.dirname(path), exist_ok=True)
|
||||
cv2.imwrite(path, img[..., ::-1].copy())
|
||||
print(f'Image saved: {path}')
|
||||
|
||||
|
||||
def show_preview(flag, img, title='preview'):
|
||||
buffer.append((flag, img[..., ::-1].copy(), title))
|
||||
|
||||
|
||||
@@ -2,3 +2,6 @@ import os
|
||||
|
||||
modelfile_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '../models/checkpoints/'))
|
||||
lorafile_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '../models/loras/'))
|
||||
temp_outputs_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '../outputs/'))
|
||||
|
||||
os.makedirs(temp_outputs_path, exist_ok=True)
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import datetime
|
||||
import random
|
||||
import os
|
||||
|
||||
|
||||
def generate_temp_filename(folder='./outputs/', extension='png'):
|
||||
current_time = datetime.datetime.now()
|
||||
date_string = current_time.strftime("%Y-%m-%d")
|
||||
time_string = current_time.strftime("%Y-%m-%d_%H-%M-%S")
|
||||
random_number = random.randint(1000, 9999)
|
||||
filename = f"{time_string}_{random_number}.{extension}"
|
||||
result = os.path.join(folder, date_string, filename)
|
||||
return os.path.abspath(os.path.realpath(result))
|
||||
Reference in New Issue
Block a user