Spaces:
Running
Running
root
commited on
Commit
·
613635e
1
Parent(s):
139414f
fix the sr_option error
Browse files
app.py
CHANGED
|
@@ -95,7 +95,7 @@ def filter_content(raw_style: str):
|
|
| 95 |
else :
|
| 96 |
return raw_style[:i]
|
| 97 |
|
| 98 |
-
def request_images(raw_text, class_draw, style_draw, batch_size):
|
| 99 |
if filter_content(class_draw) != "国画":
|
| 100 |
if filter_content(class_draw) != "通用":
|
| 101 |
raw_text = raw_text + f",{filter_content(class_draw)}"
|
|
@@ -111,7 +111,7 @@ def request_images(raw_text, class_draw, style_draw, batch_size):
|
|
| 111 |
raw_text = raw_text + ",国画"
|
| 112 |
url = "http://flagart.baai.ac.cn/api/guohua/"
|
| 113 |
|
| 114 |
-
d = {"data":[raw_text, batch_size]}
|
| 115 |
r = requests.post(url, json=d, headers={"Content-Type": "application/json", "Accept": "*/*", "Accept-Encoding": "gzip, deflate, br", "Connection": "keep-alive"})
|
| 116 |
result_text = r.text
|
| 117 |
content = json.loads(result_text)["data"][0]
|
|
@@ -239,6 +239,8 @@ if __name__ == "__main__":
|
|
| 239 |
show_label=True,
|
| 240 |
interactive=True,
|
| 241 |
)
|
|
|
|
|
|
|
| 242 |
|
| 243 |
gallery = gr.Gallery(
|
| 244 |
label="Generated images", show_label=False, elem_id="gallery"
|
|
@@ -246,8 +248,8 @@ if __name__ == "__main__":
|
|
| 246 |
output_txt2img_copy_to_input_btn = gr.Button("Go to img2img")
|
| 247 |
|
| 248 |
gr.Examples(examples=examples, fn=request_images, inputs=text, outputs=gallery, examples_per_page=100)
|
| 249 |
-
text.submit(request_images, inputs=[text, class_draw, style_draw, sample_size], outputs=gallery)
|
| 250 |
-
btn.click(request_images, inputs=[text, class_draw, style_draw, sample_size], outputs=gallery)
|
| 251 |
|
| 252 |
with gr.TabItem("图生图(Img-to-Img)", id="img2img_tab"):
|
| 253 |
with gr.Row(elem_id="prompt_row"):
|
|
|
|
| 95 |
else :
|
| 96 |
return raw_style[:i]
|
| 97 |
|
| 98 |
+
def request_images(raw_text, class_draw, style_draw, batch_size, sr_option):
|
| 99 |
if filter_content(class_draw) != "国画":
|
| 100 |
if filter_content(class_draw) != "通用":
|
| 101 |
raw_text = raw_text + f",{filter_content(class_draw)}"
|
|
|
|
| 111 |
raw_text = raw_text + ",国画"
|
| 112 |
url = "http://flagart.baai.ac.cn/api/guohua/"
|
| 113 |
|
| 114 |
+
d = {"data":[raw_text, batch_size, sr_option]}
|
| 115 |
r = requests.post(url, json=d, headers={"Content-Type": "application/json", "Accept": "*/*", "Accept-Encoding": "gzip, deflate, br", "Connection": "keep-alive"})
|
| 116 |
result_text = r.text
|
| 117 |
content = json.loads(result_text)["data"][0]
|
|
|
|
| 239 |
show_label=True,
|
| 240 |
interactive=True,
|
| 241 |
)
|
| 242 |
+
with gr.Row().style(mobile_collapse=False, equal_height=True):
|
| 243 |
+
sr_option = gr.Checkbox(value=False, label="是否使用超分(Whether to use super-resolution)")
|
| 244 |
|
| 245 |
gallery = gr.Gallery(
|
| 246 |
label="Generated images", show_label=False, elem_id="gallery"
|
|
|
|
| 248 |
output_txt2img_copy_to_input_btn = gr.Button("Go to img2img")
|
| 249 |
|
| 250 |
gr.Examples(examples=examples, fn=request_images, inputs=text, outputs=gallery, examples_per_page=100)
|
| 251 |
+
text.submit(request_images, inputs=[text, class_draw, style_draw, sample_size, sr_option], outputs=gallery)
|
| 252 |
+
btn.click(request_images, inputs=[text, class_draw, style_draw, sample_size, sr_option], outputs=gallery)
|
| 253 |
|
| 254 |
with gr.TabItem("图生图(Img-to-Img)", id="img2img_tab"):
|
| 255 |
with gr.Row(elem_id="prompt_row"):
|