Spaces:
Sleeping
Sleeping
P01yH3dr0n
commited on
Commit
•
a7f7261
1
Parent(s):
046c320
anlas fix and director tools optimize
Browse files- director_tools.py +6 -2
- utils.py +1 -1
director_tools.py
CHANGED
@@ -54,6 +54,7 @@ def director_ui():
|
|
54 |
with gr.Tab("自由调整") as resize:
|
55 |
width = gr.Slider(label="调整宽度", value=1024, minimum=1, maximum=2048, step=1)
|
56 |
height = gr.Slider(label="调整高度", value=1024, minimum=1, maximum=2048, step=1)
|
|
|
57 |
with gr.Tab("等比例缩放") as scale:
|
58 |
hint = gr.HTML('', show_label=False)
|
59 |
factor = gr.Slider(label="缩放比例", minimum=0.1, maximum=2, step=0.1)
|
@@ -85,11 +86,14 @@ def director_ui():
|
|
85 |
req_type.change(lambda r: "neutral;;" if r == "更改表情" else '', inputs=req_type, outputs=prompt)
|
86 |
input_image.change(getWH, inputs=[input_image, width, height, factor], outputs=[width, height, hint])
|
87 |
factor.change(refresh_hint, inputs=[hint, factor], outputs=[hint])
|
88 |
-
tool_btn = gr.Button(value="生成", variant="primary")
|
89 |
dtool_stop = gr.Button(value="取消", variant="stop", visible=False)
|
90 |
-
|
|
|
91 |
dtool_gen = tool_btn.click(augment_image, inputs=[input_image, width, height, req_type, selection, factor, defry, prompt], outputs=output_image, concurrency_id="generate")
|
92 |
dtool_stop.click(lambda: (gr.Button(visible=True), gr.Button(visible=False)), inputs=None, outputs=[tool_btn, dtool_stop], cancels=[dtool_gen])
|
|
|
|
|
93 |
width.change(update_btn_cost, inputs=[width, height, req_type, selection, hint], outputs=tool_btn)
|
94 |
height.change(update_btn_cost, inputs=[width, height, req_type, selection, hint], outputs=tool_btn)
|
95 |
req_type.change(update_btn_cost, inputs=[width, height, req_type, selection, hint], outputs=tool_btn)
|
|
|
54 |
with gr.Tab("自由调整") as resize:
|
55 |
width = gr.Slider(label="调整宽度", value=1024, minimum=1, maximum=2048, step=1)
|
56 |
height = gr.Slider(label="调整高度", value=1024, minimum=1, maximum=2048, step=1)
|
57 |
+
reset = gr.Button("重置")
|
58 |
with gr.Tab("等比例缩放") as scale:
|
59 |
hint = gr.HTML('', show_label=False)
|
60 |
factor = gr.Slider(label="缩放比例", minimum=0.1, maximum=2, step=0.1)
|
|
|
86 |
req_type.change(lambda r: "neutral;;" if r == "更改表情" else '', inputs=req_type, outputs=prompt)
|
87 |
input_image.change(getWH, inputs=[input_image, width, height, factor], outputs=[width, height, hint])
|
88 |
factor.change(refresh_hint, inputs=[hint, factor], outputs=[hint])
|
89 |
+
tool_btn = gr.Button(value="生成", variant="primary", visible=False)
|
90 |
dtool_stop = gr.Button(value="取消", variant="stop", visible=False)
|
91 |
+
input_image.change(lambda i: gr.Button(visible=False) if i is None else gr.Button(visible=True), inputs=input_image, outputs=tool_btn)
|
92 |
+
tool_btn.click(lambda: (gr.Button(visible=False), gr.Button(visible=True), gr.Gallery(selected_index=None)), inputs=None, outputs=[tool_btn, dtool_stop, output_image])
|
93 |
dtool_gen = tool_btn.click(augment_image, inputs=[input_image, width, height, req_type, selection, factor, defry, prompt], outputs=output_image, concurrency_id="generate")
|
94 |
dtool_stop.click(lambda: (gr.Button(visible=True), gr.Button(visible=False)), inputs=None, outputs=[tool_btn, dtool_stop], cancels=[dtool_gen])
|
95 |
+
output_image.change(lambda: (gr.Button(visible=True), gr.Button(visible=False)), inputs=None, outputs=[tool_btn, dtool_stop])
|
96 |
+
reset.click(getWH, inputs=[input_image, width, height, factor], outputs=[width, height, hint])
|
97 |
width.change(update_btn_cost, inputs=[width, height, req_type, selection, hint], outputs=tool_btn)
|
98 |
height.change(update_btn_cost, inputs=[width, height, req_type, selection, hint], outputs=tool_btn)
|
99 |
req_type.change(update_btn_cost, inputs=[width, height, req_type, selection, hint], outputs=tool_btn)
|
utils.py
CHANGED
@@ -40,7 +40,7 @@ def calculate_cost(width, height, steps=28, sm=False, dyn=False, strength=1, rmb
|
|
40 |
dyn = sm and dyn
|
41 |
L = math.ceil(2951823174884865e-21 * pixels + 5.753298233447344e-7 * pixels * steps)
|
42 |
L *= 1.4 if dyn else (1.2 if sm else 1)
|
43 |
-
L =
|
44 |
return L * 3 + 5 if rmbg else L
|
45 |
|
46 |
def generate_novelai_image(
|
|
|
40 |
dyn = sm and dyn
|
41 |
L = math.ceil(2951823174884865e-21 * pixels + 5.753298233447344e-7 * pixels * steps)
|
42 |
L *= 1.4 if dyn else (1.2 if sm else 1)
|
43 |
+
L = math.ceil(L * strength)
|
44 |
return L * 3 + 5 if rmbg else L
|
45 |
|
46 |
def generate_novelai_image(
|