Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -84,7 +84,7 @@ def process_text(prompt):
|
|
84 |
@spaces.GPU
|
85 |
def generate(
|
86 |
prompt: str,
|
87 |
-
size_option: str = "竖版",
|
88 |
negative_prompt: str = "",
|
89 |
prompt_2: str = "",
|
90 |
negative_prompt_2: str = "",
|
@@ -110,14 +110,14 @@ def generate(
|
|
110 |
negative_prompt_2 = None # type: ignore
|
111 |
|
112 |
|
113 |
-
if size_option == "横版":
|
114 |
-
|
115 |
-
elif size_option == "竖版":
|
116 |
-
|
117 |
-
elif size_option == "方形":
|
118 |
-
|
119 |
-
else:
|
120 |
-
|
121 |
|
122 |
# process_text("里面做一个测试")
|
123 |
# print("prompt是:", prompt)
|
@@ -188,8 +188,8 @@ with gr.Blocks(css="style.css") as demo:
|
|
188 |
run_button = gr.Button("生成", scale=0)
|
189 |
result = gr.Image(label="生成结果", show_label=False)
|
190 |
|
191 |
-
# 使用 Radio 组件替代两个 Slider 组件
|
192 |
-
size_option = gr.Radio(choices=["横版", "竖版", "方形"], label="选择尺寸", value="竖版")
|
193 |
|
194 |
with gr.Accordion("高级选项", open=False):
|
195 |
with gr.Row():
|
@@ -224,21 +224,21 @@ with gr.Blocks(css="style.css") as demo:
|
|
224 |
)
|
225 |
randomize_seed = gr.Checkbox(label="随机种子数", value=True)
|
226 |
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
|
243 |
apply_refiner = gr.Checkbox(label="增加精炼模型(refiner)", value=False, visible=ENABLE_REFINER)
|
244 |
|
@@ -328,7 +328,7 @@ with gr.Blocks(css="style.css") as demo:
|
|
328 |
fn=generate,
|
329 |
inputs=[
|
330 |
prompt,
|
331 |
-
size_option,
|
332 |
negative_prompt,
|
333 |
prompt_2,
|
334 |
negative_prompt_2,
|
@@ -336,8 +336,8 @@ with gr.Blocks(css="style.css") as demo:
|
|
336 |
use_prompt_2,
|
337 |
use_negative_prompt_2,
|
338 |
seed,
|
339 |
-
|
340 |
-
|
341 |
guidance_scale_base,
|
342 |
guidance_scale_refiner,
|
343 |
num_inference_steps_base,
|
|
|
84 |
@spaces.GPU
|
85 |
def generate(
|
86 |
prompt: str,
|
87 |
+
# size_option: str = "竖版",
|
88 |
negative_prompt: str = "",
|
89 |
prompt_2: str = "",
|
90 |
negative_prompt_2: str = "",
|
|
|
110 |
negative_prompt_2 = None # type: ignore
|
111 |
|
112 |
|
113 |
+
# if size_option == "横版":
|
114 |
+
# width, height = 1024, 736
|
115 |
+
# elif size_option == "竖版":
|
116 |
+
# width, height = 736, 1024
|
117 |
+
# elif size_option == "方形":
|
118 |
+
# width, height = 736, 736
|
119 |
+
# else:
|
120 |
+
# width, height = 736, 1024 # 可以定义一个默认值
|
121 |
|
122 |
# process_text("里面做一个测试")
|
123 |
# print("prompt是:", prompt)
|
|
|
188 |
run_button = gr.Button("生成", scale=0)
|
189 |
result = gr.Image(label="生成结果", show_label=False)
|
190 |
|
191 |
+
# # 使用 Radio 组件替代两个 Slider 组件
|
192 |
+
# size_option = gr.Radio(choices=["横版", "竖版", "方形"], label="选择尺寸", value="竖版")
|
193 |
|
194 |
with gr.Accordion("高级选项", open=False):
|
195 |
with gr.Row():
|
|
|
224 |
)
|
225 |
randomize_seed = gr.Checkbox(label="随机种子数", value=True)
|
226 |
|
227 |
+
with gr.Row():
|
228 |
+
width = gr.Slider(
|
229 |
+
label="宽度",
|
230 |
+
minimum=256,
|
231 |
+
maximum=MAX_IMAGE_SIZE,
|
232 |
+
step=32,
|
233 |
+
value=736,
|
234 |
+
)
|
235 |
+
height = gr.Slider(
|
236 |
+
label="高度",
|
237 |
+
minimum=256,
|
238 |
+
maximum=MAX_IMAGE_SIZE,
|
239 |
+
step=32,
|
240 |
+
value=1024,
|
241 |
+
)
|
242 |
|
243 |
apply_refiner = gr.Checkbox(label="增加精炼模型(refiner)", value=False, visible=ENABLE_REFINER)
|
244 |
|
|
|
328 |
fn=generate,
|
329 |
inputs=[
|
330 |
prompt,
|
331 |
+
# size_option,
|
332 |
negative_prompt,
|
333 |
prompt_2,
|
334 |
negative_prompt_2,
|
|
|
336 |
use_prompt_2,
|
337 |
use_negative_prompt_2,
|
338 |
seed,
|
339 |
+
width,
|
340 |
+
height,
|
341 |
guidance_scale_base,
|
342 |
guidance_scale_refiner,
|
343 |
num_inference_steps_base,
|