Spaces:
Runtime error
Runtime error
root
commited on
Commit
•
0e82b94
1
Parent(s):
34628fc
Adjust the layout
Browse files- app.py +87 -88
- ui_functions.py +1 -1
app.py
CHANGED
@@ -256,20 +256,21 @@ if __name__ == "__main__":
|
|
256 |
show_label=True,
|
257 |
)
|
258 |
with gr.Row().style(mobile_collapse=False, equal_height=True):
|
259 |
-
sample_size = gr.Slider(minimum=1,
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
|
|
266 |
with gr.Row(visible=False).style(mobile_collapse=False, equal_height=True):
|
267 |
sr_option = gr.Checkbox(value=False, label="是否使用超分(Whether to use super-resolution)")
|
268 |
|
269 |
gallery = gr.Gallery(
|
270 |
label="Generated images", show_label=False, elem_id="gallery"
|
271 |
).style(grid=[2,2])
|
272 |
-
|
273 |
with gr.Row().style(mobile_collapse=False, equal_height=True):
|
274 |
img_choices = gr.Dropdown(["图片1(img1)"],label='请选择一张图片发送到图生图或者超分',show_label=True,value="图片1(img1)")
|
275 |
with gr.Row().style(mobile_collapse=False, equal_height=True):
|
@@ -284,7 +285,7 @@ if __name__ == "__main__":
|
|
284 |
|
285 |
sr_gallery = gr.Gallery(
|
286 |
label="SR images", show_label=True, elem_id="sr_gallery"
|
287 |
-
).style(grid=[
|
288 |
|
289 |
with gr.Row():
|
290 |
prompt = gr.Markdown("提示(Prompt):", visible=False)
|
@@ -301,10 +302,8 @@ if __name__ == "__main__":
|
|
301 |
# rounded=(True, True, True, True),
|
302 |
# )
|
303 |
|
304 |
-
|
305 |
-
|
306 |
-
text.submit(request_images, inputs=[text, class_draw, style_draw, sample_size, sr_option], outputs=gallery)
|
307 |
-
btn.click(request_images, inputs=[text, class_draw, style_draw, sample_size, sr_option], outputs=gallery)
|
308 |
# to do here
|
309 |
output_txt2img_sr_btn.click(sr_request_images, inputs=[gallery, img_choices], outputs=[sr_gallery])
|
310 |
|
@@ -328,83 +327,83 @@ if __name__ == "__main__":
|
|
328 |
elem_id="img2img_mask_btn")
|
329 |
img2img_btn_editor = gr.Button("Generate", variant="primary", elem_id="img2img_edit_btn")
|
330 |
with gr.Row().style(equal_height=False):
|
331 |
-
with gr.Column():
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
354 |
with gr.Row():
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
label="编辑模式",
|
359 |
-
value="Mask", elem_id='edit_mode_select',
|
360 |
-
visible=True)
|
361 |
-
img2img_mask = gr.Radio(choices=["保留mask区域", "生成mask区域"],
|
362 |
-
label="Mask 方式",
|
363 |
-
#value=img2img_mask_modes[img2img_defaults['mask_mode']],
|
364 |
-
value = "生成mask区域",
|
365 |
-
visible=True)
|
366 |
-
|
367 |
-
img2img_mask_blur_strength = gr.Slider(minimum=1, maximum=10, step=1,
|
368 |
-
label="How much blurry should the mask be? (to avoid hard edges)",
|
369 |
-
value=3, visible=False)
|
370 |
-
|
371 |
-
img2img_resize = gr.Radio(label="Resize mode",
|
372 |
-
choices=["Just resize", "Crop and resize",
|
373 |
-
"Resize and fill"],
|
374 |
-
value=img2img_resize_modes[
|
375 |
-
img2img_defaults['resize_mode']], visible=False)
|
376 |
-
|
377 |
-
img2img_painterro_btn = gr.Button("Advanced Editor",visible=False)
|
378 |
-
# with gr.TabItem("Hints",visible=False):
|
379 |
-
# img2img_help = gr.Markdown(visible=False, value=uifn.help_text)
|
380 |
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
gr.
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
gr.Markdown("Warning: This will clear your current image and mask settings!")
|
396 |
-
with gr.TabItem("", id="img2img_output_info_tab",visible=False):
|
397 |
-
output_img2img_params = gr.Textbox(label="Generation parameters")
|
398 |
-
with gr.Row():
|
399 |
-
output_img2img_copy_params = gr.Button("Copy full parameters").click(
|
400 |
-
inputs=output_img2img_params, outputs=[],
|
401 |
-
_js='(x) => {navigator.clipboard.writeText(x.replace(": ",":"))}', fn=None,
|
402 |
-
show_progress=False)
|
403 |
-
output_img2img_seed = gr.Number(label='Seed', interactive=False, visible=False)
|
404 |
-
output_img2img_copy_seed = gr.Button("Copy only seed").click(
|
405 |
-
inputs=output_img2img_seed, outputs=[],
|
406 |
-
_js=call_JS("gradioInputToClipboard"), fn=None, show_progress=False)
|
407 |
-
output_img2img_stats = gr.HTML(label='Stats')
|
408 |
|
409 |
with gr.Row():
|
410 |
gr.Markdown('请选择一张图像掩盖掉一部分区域,并输入文本描述')
|
|
|
256 |
show_label=True,
|
257 |
)
|
258 |
with gr.Row().style(mobile_collapse=False, equal_height=True):
|
259 |
+
# sample_size = gr.Slider(minimum=1,
|
260 |
+
# maximum=4,
|
261 |
+
# step=1,
|
262 |
+
# label="生成数量(number)",
|
263 |
+
# show_label=True,
|
264 |
+
# interactive=True,
|
265 |
+
# )
|
266 |
+
sample_size = gr.Radio(choices=["1","2","3","4"], value="1", show_label=True, )
|
267 |
with gr.Row(visible=False).style(mobile_collapse=False, equal_height=True):
|
268 |
sr_option = gr.Checkbox(value=False, label="是否使用超分(Whether to use super-resolution)")
|
269 |
|
270 |
gallery = gr.Gallery(
|
271 |
label="Generated images", show_label=False, elem_id="gallery"
|
272 |
).style(grid=[2,2])
|
273 |
+
gr.Examples(examples=examples, fn=request_images, inputs=text, outputs=gallery, examples_per_page=100)
|
274 |
with gr.Row().style(mobile_collapse=False, equal_height=True):
|
275 |
img_choices = gr.Dropdown(["图片1(img1)"],label='请选择一张图片发送到图生图或者超分',show_label=True,value="图片1(img1)")
|
276 |
with gr.Row().style(mobile_collapse=False, equal_height=True):
|
|
|
285 |
|
286 |
sr_gallery = gr.Gallery(
|
287 |
label="SR images", show_label=True, elem_id="sr_gallery"
|
288 |
+
).style(grid=[1,1])
|
289 |
|
290 |
with gr.Row():
|
291 |
prompt = gr.Markdown("提示(Prompt):", visible=False)
|
|
|
302 |
# rounded=(True, True, True, True),
|
303 |
# )
|
304 |
|
305 |
+
text.submit(request_images, inputs=[text, class_draw, style_draw, int(sample_size), sr_option], outputs=gallery)
|
306 |
+
btn.click(request_images, inputs=[text, class_draw, style_draw, int(sample_size), sr_option], outputs=gallery)
|
|
|
|
|
307 |
# to do here
|
308 |
output_txt2img_sr_btn.click(sr_request_images, inputs=[gallery, img_choices], outputs=[sr_gallery])
|
309 |
|
|
|
327 |
elem_id="img2img_mask_btn")
|
328 |
img2img_btn_editor = gr.Button("Generate", variant="primary", elem_id="img2img_edit_btn")
|
329 |
with gr.Row().style(equal_height=False):
|
330 |
+
#with gr.Column():
|
331 |
+
gr.Markdown('#### 输入图像')
|
332 |
+
img2img_image_mask = gr.Image(
|
333 |
+
value=sample_img2img,
|
334 |
+
source="upload",
|
335 |
+
interactive=True,
|
336 |
+
tool="sketch",
|
337 |
+
type='pil',
|
338 |
+
elem_id="img2img_mask",
|
339 |
+
image_mode="RGBA"
|
340 |
+
)
|
341 |
+
img2img_image_editor = gr.Image(
|
342 |
+
value=sample_img2img,
|
343 |
+
source="upload",
|
344 |
+
interactive=True,
|
345 |
+
tool="select",
|
346 |
+
type='pil',
|
347 |
+
visible=False,
|
348 |
+
image_mode="RGBA",
|
349 |
+
elem_id="img2img_editor"
|
350 |
+
)
|
351 |
+
with gr.Tabs(visible=True):
|
352 |
+
with gr.TabItem("编辑设置"):
|
353 |
+
with gr.Row():
|
354 |
+
# disable Uncrop for now
|
355 |
+
choices=["Mask", "Crop", "Uncrop"]
|
356 |
+
img2img_image_editor_mode = gr.Radio(choices=["Mask"],
|
357 |
+
label="编辑模式",
|
358 |
+
value="Mask", elem_id='edit_mode_select',
|
359 |
+
visible=True)
|
360 |
+
img2img_mask = gr.Radio(choices=["保留mask区域", "生成mask区域"],
|
361 |
+
label="Mask 方式",
|
362 |
+
#value=img2img_mask_modes[img2img_defaults['mask_mode']],
|
363 |
+
value = "生成mask区域",
|
364 |
+
visible=True)
|
365 |
+
|
366 |
+
img2img_mask_blur_strength = gr.Slider(minimum=1, maximum=10, step=1,
|
367 |
+
label="How much blurry should the mask be? (to avoid hard edges)",
|
368 |
+
value=3, visible=False)
|
369 |
+
|
370 |
+
img2img_resize = gr.Radio(label="Resize mode",
|
371 |
+
choices=["Just resize", "Crop and resize",
|
372 |
+
"Resize and fill"],
|
373 |
+
value=img2img_resize_modes[
|
374 |
+
img2img_defaults['resize_mode']], visible=False)
|
375 |
+
|
376 |
+
img2img_painterro_btn = gr.Button("Advanced Editor",visible=False)
|
377 |
+
# with gr.TabItem("Hints",visible=False):
|
378 |
+
# img2img_help = gr.Markdown(visible=False, value=uifn.help_text)
|
379 |
+
|
380 |
+
with gr.Row():
|
381 |
+
gr.Markdown('#### 编辑后的图片')
|
382 |
+
output_img2img_gallery = gr.Gallery(label="Images", elem_id="img2img_gallery_output").style(
|
383 |
+
grid=[4, 4, 4])
|
384 |
+
img2img_job_ui = job_manager.draw_gradio_ui() if job_manager else None
|
385 |
+
with gr.Column(visible=False):
|
386 |
+
with gr.Tabs(visible=False):
|
387 |
+
with gr.TabItem("", id="img2img_actions_tab",visible=False):
|
388 |
+
gr.Markdown("Select an image, then press one of the buttons below")
|
389 |
with gr.Row():
|
390 |
+
output_img2img_copy_to_clipboard_btn = gr.Button("Copy to clipboard")
|
391 |
+
output_img2img_copy_to_input_btn = gr.Button("Push to img2img input")
|
392 |
+
output_img2img_copy_to_mask_btn = gr.Button("Push to img2img input mask")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
393 |
|
394 |
+
gr.Markdown("Warning: This will clear your current image and mask settings!")
|
395 |
+
with gr.TabItem("", id="img2img_output_info_tab",visible=False):
|
396 |
+
output_img2img_params = gr.Textbox(label="Generation parameters")
|
397 |
+
with gr.Row():
|
398 |
+
output_img2img_copy_params = gr.Button("Copy full parameters").click(
|
399 |
+
inputs=output_img2img_params, outputs=[],
|
400 |
+
_js='(x) => {navigator.clipboard.writeText(x.replace(": ",":"))}', fn=None,
|
401 |
+
show_progress=False)
|
402 |
+
output_img2img_seed = gr.Number(label='Seed', interactive=False, visible=False)
|
403 |
+
output_img2img_copy_seed = gr.Button("Copy only seed").click(
|
404 |
+
inputs=output_img2img_seed, outputs=[],
|
405 |
+
_js=call_JS("gradioInputToClipboard"), fn=None, show_progress=False)
|
406 |
+
output_img2img_stats = gr.HTML(label='Stats')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
407 |
|
408 |
with gr.Row():
|
409 |
gr.Markdown('请选择一张图像掩盖掉一部分区域,并输入文本描述')
|
ui_functions.py
CHANGED
@@ -7,7 +7,7 @@ import re
|
|
7 |
|
8 |
def change_img_choices(sample_size):
|
9 |
choices = []
|
10 |
-
for i in range(sample_size):
|
11 |
choices.append(
|
12 |
'图片{}(img{})'.format(i+1,i+1)
|
13 |
)
|
|
|
7 |
|
8 |
def change_img_choices(sample_size):
|
9 |
choices = []
|
10 |
+
for i in range(int(sample_size)):
|
11 |
choices.append(
|
12 |
'图片{}(img{})'.format(i+1,i+1)
|
13 |
)
|