Spaces:
Paused
Paused
P01yH3dr0n
commited on
Commit
•
1e9ddc5
1
Parent(s):
2af6387
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
import os
|
2 |
import datetime
|
3 |
|
4 |
-
import toml
|
5 |
import gradio as gr
|
6 |
from pnginfo import read_info_from_image, send_paras
|
7 |
from images_history import img_history_ui
|
@@ -9,8 +8,6 @@ from images_history import img_history_ui
|
|
9 |
from utils import set_token, generate_novelai_image, image_from_bytes
|
10 |
from PIL import PngImagePlugin
|
11 |
|
12 |
-
|
13 |
-
client_config = toml.load("config.toml")['client']
|
14 |
today_count = 0
|
15 |
today = datetime.date.today().strftime('%Y-%m-%d')
|
16 |
|
@@ -82,7 +79,7 @@ def control_ui():
|
|
82 |
|
83 |
def generate(prompt, quality_tags, neg_prompt, seed, scale, width, height, steps, sampler, scheduler, smea, dyn, dyn_threshold, cfg_rescale, save):
|
84 |
global today_count
|
85 |
-
set_token(
|
86 |
img_data, payload = generate_novelai_image(
|
87 |
f"{prompt}, {quality_tags}", neg_prompt, seed, scale,
|
88 |
width, height, steps, sampler, scheduler,
|
@@ -93,17 +90,6 @@ def generate(prompt, quality_tags, neg_prompt, seed, scale, width, height, steps
|
|
93 |
today_count += 1
|
94 |
img = image_from_bytes(img_data)
|
95 |
|
96 |
-
if save:
|
97 |
-
save_path = client_config['save_path']
|
98 |
-
today = datetime.date.today().strftime('%Y-%m-%d')
|
99 |
-
today_path = os.path.join(save_path, today)
|
100 |
-
if not os.path.exists(today_path):
|
101 |
-
os.makedirs(today_path, mode=777, exist_ok=True)
|
102 |
-
filename = str(today_count).rjust(5, '0') + '-' + str(payload['parameters']['seed']) + '.png'
|
103 |
-
pnginfo_data = PngImagePlugin.PngInfo()
|
104 |
-
for k, v in img.info.items():
|
105 |
-
pnginfo_data.add_text(k, str(v))
|
106 |
-
img.save(os.path.join(today_path, filename), pnginfo=pnginfo_data)
|
107 |
|
108 |
return img, payload
|
109 |
|
|
|
1 |
import os
|
2 |
import datetime
|
3 |
|
|
|
4 |
import gradio as gr
|
5 |
from pnginfo import read_info_from_image, send_paras
|
6 |
from images_history import img_history_ui
|
|
|
8 |
from utils import set_token, generate_novelai_image, image_from_bytes
|
9 |
from PIL import PngImagePlugin
|
10 |
|
|
|
|
|
11 |
today_count = 0
|
12 |
today = datetime.date.today().strftime('%Y-%m-%d')
|
13 |
|
|
|
79 |
|
80 |
def generate(prompt, quality_tags, neg_prompt, seed, scale, width, height, steps, sampler, scheduler, smea, dyn, dyn_threshold, cfg_rescale, save):
|
81 |
global today_count
|
82 |
+
set_token(os.environ.get('token'))
|
83 |
img_data, payload = generate_novelai_image(
|
84 |
f"{prompt}, {quality_tags}", neg_prompt, seed, scale,
|
85 |
width, height, steps, sampler, scheduler,
|
|
|
90 |
today_count += 1
|
91 |
img = image_from_bytes(img_data)
|
92 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
|
94 |
return img, payload
|
95 |
|