Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -81,21 +81,10 @@ def process_text(prompt):
|
|
81 |
print("prompt: \n", prompt_trans)
|
82 |
return prompt_trans
|
83 |
|
84 |
-
# 定义一个函数来处理图片尺寸的选择
|
85 |
-
def set_size(option):
|
86 |
-
if option == "横版":
|
87 |
-
width, height = 1024, 736
|
88 |
-
elif option == "竖版":
|
89 |
-
width, height = 736, 1024
|
90 |
-
elif option == "方形":
|
91 |
-
width, height = 736, 736
|
92 |
-
else:
|
93 |
-
width, height = 736, 1024 # 可以定义一个默认值
|
94 |
-
return width, height
|
95 |
-
|
96 |
@spaces.GPU
|
97 |
def generate(
|
98 |
prompt: str,
|
|
|
99 |
negative_prompt: str = "",
|
100 |
prompt_2: str = "",
|
101 |
negative_prompt_2: str = "",
|
@@ -120,6 +109,16 @@ def generate(
|
|
120 |
if not use_negative_prompt_2:
|
121 |
negative_prompt_2 = None # type: ignore
|
122 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
# process_text("里面做一个测试")
|
124 |
# print("prompt是:", prompt)
|
125 |
# print("negative_prompt是:", negative_prompt)
|
@@ -189,6 +188,8 @@ with gr.Blocks(css="style.css") as demo:
|
|
189 |
run_button = gr.Button("生成", scale=0)
|
190 |
result = gr.Image(label="生成结果", show_label=False)
|
191 |
|
|
|
|
|
192 |
|
193 |
with gr.Accordion("高级选项", open=False):
|
194 |
with gr.Row():
|
@@ -222,9 +223,6 @@ with gr.Blocks(css="style.css") as demo:
|
|
222 |
value=0,
|
223 |
)
|
224 |
randomize_seed = gr.Checkbox(label="随机种子数", value=True)
|
225 |
-
|
226 |
-
# 使用 Radio 组件替代两个 Slider 组件
|
227 |
-
size_option = gr.Radio(choices=["横版", "竖版", "方形"], label="选择尺寸", value="竖版")
|
228 |
|
229 |
# with gr.Row():
|
230 |
# width = gr.Slider(
|
@@ -333,6 +331,7 @@ with gr.Blocks(css="style.css") as demo:
|
|
333 |
fn=generate,
|
334 |
inputs=[
|
335 |
prompt,
|
|
|
336 |
negative_prompt,
|
337 |
prompt_2,
|
338 |
negative_prompt_2,
|
|
|
81 |
print("prompt: \n", prompt_trans)
|
82 |
return prompt_trans
|
83 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 = "",
|
|
|
109 |
if not use_negative_prompt_2:
|
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)
|
124 |
# print("negative_prompt是:", negative_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():
|
|
|
223 |
value=0,
|
224 |
)
|
225 |
randomize_seed = gr.Checkbox(label="随机种子数", value=True)
|
|
|
|
|
|
|
226 |
|
227 |
# with gr.Row():
|
228 |
# width = gr.Slider(
|
|
|
331 |
fn=generate,
|
332 |
inputs=[
|
333 |
prompt,
|
334 |
+
size_option,
|
335 |
negative_prompt,
|
336 |
prompt_2,
|
337 |
negative_prompt_2,
|