lllyasviel commited on
Commit
1e9ebb3
1 Parent(s): 945f5f1

1.0.16 (#19)

Browse files

### 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.

Files changed (7) hide show
  1. fooocus_version.py +1 -1
  2. modules/cv2win32.py +13 -5
  3. modules/path.py +3 -0
  4. modules/util.py +13 -0
  5. readme.md +5 -1
  6. update_log.md +14 -0
  7. webui.py +8 -1
fooocus_version.py CHANGED
@@ -1,2 +1,2 @@
1
- version = '1.0.15'
2
 
 
1
+ version = '1.0.16'
2
 
modules/cv2win32.py CHANGED
@@ -1,5 +1,6 @@
1
  import threading
2
  import cv2
 
3
 
4
 
5
  buffer = []
@@ -7,9 +8,9 @@ buffer = []
7
 
8
  def worker():
9
  global buffer
10
- while True:
11
- cv2.waitKey(50)
12
- try:
13
  if len(buffer) > 0:
14
  task = buffer.pop(0)
15
  if task is None:
@@ -19,11 +20,18 @@ def worker():
19
  cv2.imshow(flag, img)
20
  cv2.setWindowTitle(flag, title)
21
  cv2.setWindowProperty(flag, cv2.WND_PROP_TOPMOST, 1)
22
- except Exception as e:
23
- print(e)
 
24
  pass
25
 
26
 
 
 
 
 
 
 
27
  def show_preview(flag, img, title='preview'):
28
  buffer.append((flag, img[..., ::-1].copy(), title))
29
 
 
1
  import threading
2
  import cv2
3
+ import os
4
 
5
 
6
  buffer = []
 
8
 
9
  def worker():
10
  global buffer
11
+ try:
12
+ while True:
13
+ cv2.waitKey(50)
14
  if len(buffer) > 0:
15
  task = buffer.pop(0)
16
  if task is None:
 
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('Failed to open preview window. You are not using a local device with GUI support.')
25
+ print(e)
26
  pass
27
 
28
 
29
+ def save_image(path, img):
30
+ os.makedirs(os.path.dirname(path), exist_ok=True)
31
+ cv2.imwrite(path, img[..., ::-1].copy())
32
+ print(f'Image saved: {path}')
33
+
34
+
35
  def show_preview(flag, img, title='preview'):
36
  buffer.append((flag, img[..., ::-1].copy(), title))
37
 
modules/path.py CHANGED
@@ -2,3 +2,6 @@ import os
2
 
3
  modelfile_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '../models/checkpoints/'))
4
  lorafile_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '../models/loras/'))
 
 
 
 
2
 
3
  modelfile_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '../models/checkpoints/'))
4
  lorafile_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '../models/loras/'))
5
+ temp_outputs_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '../outputs/'))
6
+
7
+ os.makedirs(temp_outputs_path, exist_ok=True)
modules/util.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import datetime
2
+ import random
3
+ import os
4
+
5
+
6
+ def generate_temp_filename(folder='./outputs/', extension='png'):
7
+ current_time = datetime.datetime.now()
8
+ date_string = current_time.strftime("%Y-%m-%d")
9
+ time_string = current_time.strftime("%Y-%m-%d_%H-%M-%S")
10
+ random_number = random.randint(1000, 9999)
11
+ filename = f"{time_string}_{random_number}.{extension}"
12
+ result = os.path.join(folder, date_string, filename)
13
+ return os.path.abspath(os.path.realpath(result))
readme.md CHANGED
@@ -34,7 +34,7 @@ In the first time you launch the software, it will automatically download models
34
 
35
  If you already have these files, you can copy them to the above locations to speed up installation.
36
 
37
- ### Linux and Mac
38
 
39
  Coming soon ...
40
 
@@ -57,3 +57,7 @@ Note that some of these tricks are currently (2023 Aug 11) impossible to reprodu
57
  ## Thanks
58
 
59
  The codebase starts from an odd mixture of [Automatic1111](https://github.com/AUTOMATIC1111/stable-diffusion-webui) and [ComfyUI](https://github.com/comfyanonymous/ComfyUI). (And they both use GPL license.)
 
 
 
 
 
34
 
35
  If you already have these files, you can copy them to the above locations to speed up installation.
36
 
37
+ ### Linux/Mac/Windows(AMD GPUs)
38
 
39
  Coming soon ...
40
 
 
57
  ## Thanks
58
 
59
  The codebase starts from an odd mixture of [Automatic1111](https://github.com/AUTOMATIC1111/stable-diffusion-webui) and [ComfyUI](https://github.com/comfyanonymous/ComfyUI). (And they both use GPL license.)
60
+
61
+ ## Update Log
62
+
63
+ The log is [here](update_log.md).
update_log.md ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### 1.0.16
2
+
3
+ * Implemented "output" folder for saving user results.
4
+ * Ignored cv2 errors when preview fails.
5
+ * Mentioned future AMD support in Readme.
6
+ * Created this log.
7
+
8
+ ### 1.0.15
9
+
10
+ Publicly available.
11
+
12
+ ### 1.0.0
13
+
14
+ Initial Version.
webui.py CHANGED
@@ -4,7 +4,9 @@ import fooocus_version
4
 
5
  from modules.sdxl_styles import apply_style, style_keys, aspect_ratios
6
  from modules.default_pipeline import process
7
- from modules.cv2win32 import close_all_preview
 
 
8
 
9
 
10
  def generate_clicked(prompt, negative_prompt, style_selction, performance_selction,
@@ -34,6 +36,11 @@ def generate_clicked(prompt, negative_prompt, style_selction, performance_selcti
34
 
35
  for i in range(image_number):
36
  imgs = process(p_txt, n_txt, steps, switch, width, height, seed, callback=callback)
 
 
 
 
 
37
  seed += 1
38
  results += imgs
39
 
 
4
 
5
  from modules.sdxl_styles import apply_style, style_keys, aspect_ratios
6
  from modules.default_pipeline import process
7
+ from modules.cv2win32 import close_all_preview, save_image
8
+ from modules.util import generate_temp_filename
9
+ from modules.path import temp_outputs_path
10
 
11
 
12
  def generate_clicked(prompt, negative_prompt, style_selction, performance_selction,
 
36
 
37
  for i in range(image_number):
38
  imgs = process(p_txt, n_txt, steps, switch, width, height, seed, callback=callback)
39
+
40
+ for x in imgs:
41
+ local_temp_filename = generate_temp_filename(folder=temp_outputs_path, extension='png')
42
+ save_image(local_temp_filename, x)
43
+
44
  seed += 1
45
  results += imgs
46