Spaces:
Runtime error
Runtime error
root
commited on
Commit
·
b743b0f
1
Parent(s):
6906c28
add width,height,seed
Browse files
app.py
CHANGED
@@ -98,7 +98,7 @@ def filter_content(raw_style: str):
|
|
98 |
else :
|
99 |
return raw_style[:i]
|
100 |
|
101 |
-
def request_images(raw_text, class_draw, style_draw, batch_size, sr_option):
|
102 |
if filter_content(class_draw) != "国画":
|
103 |
if filter_content(class_draw) != "通用":
|
104 |
raw_text = raw_text + f",{filter_content(class_draw)}"
|
@@ -114,7 +114,7 @@ def request_images(raw_text, class_draw, style_draw, batch_size, sr_option):
|
|
114 |
raw_text = raw_text + ",国画"
|
115 |
url = "http://flagart.baai.ac.cn/api/guohua/"
|
116 |
|
117 |
-
d = {"data":[raw_text, int(batch_size), sr_option]}
|
118 |
r = requests.post(url, json=d, headers={"Content-Type": "application/json", "Accept": "*/*", "Accept-Encoding": "gzip, deflate, br", "Connection": "keep-alive"})
|
119 |
result_text = r.text
|
120 |
content = json.loads(result_text)["data"][0]
|
@@ -270,6 +270,10 @@ if __name__ == "__main__":
|
|
270 |
# interactive=True,
|
271 |
# )
|
272 |
sample_size = gr.Radio(choices=["1","2","3","4"], value="1", show_label=True, label='生成数量(number)')
|
|
|
|
|
|
|
|
|
273 |
with gr.Row(visible=False).style(mobile_collapse=False, equal_height=True):
|
274 |
sr_option = gr.Checkbox(value=False, label="是否使用超分(Whether to use super-resolution)")
|
275 |
|
@@ -308,7 +312,7 @@ if __name__ == "__main__":
|
|
308 |
# rounded=(True, True, True, True),
|
309 |
# )
|
310 |
|
311 |
-
text.submit(request_images, inputs=[text, class_draw, style_draw, sample_size, sr_option], outputs=gallery)
|
312 |
btn.click(request_images, inputs=[text, class_draw, style_draw, sample_size, sr_option], outputs=gallery)
|
313 |
# to do here
|
314 |
output_txt2img_sr_btn.click(sr_request_images, inputs=[gallery, img_choices], outputs=[sr_gallery])
|
|
|
98 |
else :
|
99 |
return raw_style[:i]
|
100 |
|
101 |
+
def request_images(raw_text, class_draw, style_draw, batch_size, sr_option, w, h, seed):
|
102 |
if filter_content(class_draw) != "国画":
|
103 |
if filter_content(class_draw) != "通用":
|
104 |
raw_text = raw_text + f",{filter_content(class_draw)}"
|
|
|
114 |
raw_text = raw_text + ",国画"
|
115 |
url = "http://flagart.baai.ac.cn/api/guohua/"
|
116 |
|
117 |
+
d = {"data":[raw_text, int(batch_size), sr_option, w, h, seed]}
|
118 |
r = requests.post(url, json=d, headers={"Content-Type": "application/json", "Accept": "*/*", "Accept-Encoding": "gzip, deflate, br", "Connection": "keep-alive"})
|
119 |
result_text = r.text
|
120 |
content = json.loads(result_text)["data"][0]
|
|
|
270 |
# interactive=True,
|
271 |
# )
|
272 |
sample_size = gr.Radio(choices=["1","2","3","4"], value="1", show_label=True, label='生成数量(number)')
|
273 |
+
seed = gr.Number(-1, label='seed', interactive=True)
|
274 |
+
with gr.Row().style(mobile_collapse=False, equal_height=True):
|
275 |
+
w = gr.Slider(512,1024,value=512, step=64, label="width")
|
276 |
+
h = gr.Slider(512,1024,value=512, step=64, label="height")
|
277 |
with gr.Row(visible=False).style(mobile_collapse=False, equal_height=True):
|
278 |
sr_option = gr.Checkbox(value=False, label="是否使用超分(Whether to use super-resolution)")
|
279 |
|
|
|
312 |
# rounded=(True, True, True, True),
|
313 |
# )
|
314 |
|
315 |
+
text.submit(request_images, inputs=[text, class_draw, style_draw, sample_size, sr_option, w, h, seed], outputs=gallery)
|
316 |
btn.click(request_images, inputs=[text, class_draw, style_draw, sample_size, sr_option], outputs=gallery)
|
317 |
# to do here
|
318 |
output_txt2img_sr_btn.click(sr_request_images, inputs=[gallery, img_choices], outputs=[sr_gallery])
|