Spaces:
Paused
Paused
P01yH3dr0n
commited on
Commit
•
0933690
1
Parent(s):
54d12ba
Update app.py
Browse files
app.py
CHANGED
@@ -63,7 +63,16 @@ def control_ui():
|
|
63 |
with gr.Row():
|
64 |
dyn_threshold = gr.Checkbox(False, label="Dynamic Thresholding")
|
65 |
cfg_rescale = gr.Slider(0, 1, 0, step=0.01, label="CFG rescale")
|
66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
with gr.Column():
|
68 |
gr.Textbox(value=get_count, label='Usage count', every=10)
|
69 |
save = gr.Checkbox(value=True, label='Always save all generated images')
|
@@ -72,16 +81,17 @@ def control_ui():
|
|
72 |
rand_seed.click(fn=lambda: -1, inputs=None, outputs=seed)
|
73 |
width.change(lambda w, h: h if w*h<=1024*1024 else (1024*1024//w//64)*64, [width, height], height)
|
74 |
height.change(lambda w, h: w if w*h<=1024*1024 else (1024*1024//h//64)*64, [width, height], width)
|
75 |
-
return gen_btn,[prompt, quality_tags, neg_prompt, seed, scale, width, height, steps, sampler, scheduler, smea, dyn, dyn_threshold, cfg_rescale], [save, rand_seed, reuse_seed]
|
76 |
|
77 |
|
78 |
-
def generate(prompt, quality_tags, neg_prompt, seed, scale, width, height, steps, sampler, scheduler, smea, dyn, dyn_threshold, cfg_rescale, save):
|
79 |
global today_count
|
80 |
set_token(os.environ.get('token'))
|
81 |
img_data, payload = generate_novelai_image(
|
82 |
f"{prompt}, {quality_tags}", neg_prompt, seed, scale,
|
83 |
width, height, steps, sampler, scheduler,
|
84 |
-
smea, dyn, dyn_threshold, cfg_rescale
|
|
|
85 |
)
|
86 |
if not isinstance(img_data, bytes):
|
87 |
return None, payload
|
@@ -105,8 +115,9 @@ def main_ui():
|
|
105 |
gen_btn, paras, others = control_ui()
|
106 |
with gr.Column():
|
107 |
image, info = preview_ui()
|
108 |
-
gen_btn.click(generate, paras + [others[0]], [image, info])
|
109 |
others[2].click(lambda o, s: o if len(s) == 0 else s['parameters']['seed'], inputs=[paras[3], info], outputs=paras[3])
|
|
|
110 |
return page, paras
|
111 |
|
112 |
|
|
|
63 |
with gr.Row():
|
64 |
dyn_threshold = gr.Checkbox(False, label="Dynamic Thresholding")
|
65 |
cfg_rescale = gr.Slider(0, 1, 0, step=0.01, label="CFG rescale")
|
66 |
+
with gr.Accordion('风格迁移', open=False):
|
67 |
+
ref_image = gr.Image(label="上传图片", value=None, sources=["upload"], interactive=True, type="pil")
|
68 |
+
info_extract = gr.Slider(label='参考信息提取', value=1, minimum=0, maximum=1, step=0.1)
|
69 |
+
ref_str = gr.Slider(label='参考强度', value=0.6, minimum=0, maximum=1, step=0.1)
|
70 |
+
reuse_img = gr.Button(value='使用上一次生成的图片')
|
71 |
+
with gr.Accordion('蒙版重绘', open=False):
|
72 |
+
with gr.Row():
|
73 |
+
use_inp = gr.Checkbox(label='启用', value=False)
|
74 |
+
overlay = gr.Checkbox(label='覆盖原图', value=True)
|
75 |
+
inp_img = gr.ImageEditor(label="上传图片", value=None, sources=["upload"], interactive=True, type="pil", eraser=False, transforms=None, brush=gr.Brush(default_size=5, colors=["#000000"], color_mode="fixed"))
|
76 |
with gr.Column():
|
77 |
gr.Textbox(value=get_count, label='Usage count', every=10)
|
78 |
save = gr.Checkbox(value=True, label='Always save all generated images')
|
|
|
81 |
rand_seed.click(fn=lambda: -1, inputs=None, outputs=seed)
|
82 |
width.change(lambda w, h: h if w*h<=1024*1024 else (1024*1024//w//64)*64, [width, height], height)
|
83 |
height.change(lambda w, h: w if w*h<=1024*1024 else (1024*1024//h//64)*64, [width, height], width)
|
84 |
+
return gen_btn,[prompt, quality_tags, neg_prompt, seed, scale, width, height, steps, sampler, scheduler, smea, dyn, dyn_threshold, cfg_rescale, ref_image, info_extract, ref_str, inp_img, overlay], [save, rand_seed, reuse_seed, reuse_img, use_inp]
|
85 |
|
86 |
|
87 |
+
def generate(prompt, quality_tags, neg_prompt, seed, scale, width, height, steps, sampler, scheduler, smea, dyn, dyn_threshold, cfg_rescale, ref_image, info_extract, ref_str, inp_img, overlay, save, use_inp):
|
88 |
global today_count
|
89 |
set_token(os.environ.get('token'))
|
90 |
img_data, payload = generate_novelai_image(
|
91 |
f"{prompt}, {quality_tags}", neg_prompt, seed, scale,
|
92 |
width, height, steps, sampler, scheduler,
|
93 |
+
smea, dyn, dyn_threshold, cfg_rescale, info_extract, ref_str,
|
94 |
+
inp_img, overlay, use_inp
|
95 |
)
|
96 |
if not isinstance(img_data, bytes):
|
97 |
return None, payload
|
|
|
115 |
gen_btn, paras, others = control_ui()
|
116 |
with gr.Column():
|
117 |
image, info = preview_ui()
|
118 |
+
gen_btn.click(generate, paras + [others[0], others[4]], [image, info])
|
119 |
others[2].click(lambda o, s: o if len(s) == 0 else s['parameters']['seed'], inputs=[paras[3], info], outputs=paras[3])
|
120 |
+
others[3].click(inputs=image, outputs=paras[14])
|
121 |
return page, paras
|
122 |
|
123 |
|