Update app.py
Browse files
app.py
CHANGED
|
@@ -44,22 +44,18 @@ def zero_background(image, new_bgr=None):
|
|
| 44 |
return make_flatten_background(image, img_cut, mask)
|
| 45 |
|
| 46 |
|
| 47 |
-
|
| 48 |
def parse_face(image):
|
| 49 |
return clients["FaceParser"].predict(image, api_name="/predict")
|
| 50 |
|
| 51 |
|
| 52 |
-
def mirror(x):
|
| 53 |
-
return x
|
| 54 |
|
| 55 |
|
| 56 |
def active_first():
|
| 57 |
return gr.Tabs.update(selected=0)
|
| 58 |
|
| 59 |
|
| 60 |
-
def clear():
|
| 61 |
-
return None, None
|
| 62 |
-
|
| 63 |
|
| 64 |
footer = r"""
|
| 65 |
<center>
|
|
@@ -94,14 +90,12 @@ with gr.Blocks(title="Face Shine") as app:
|
|
| 94 |
|
| 95 |
with gr.Column(scale=2):
|
| 96 |
with gr.Row():
|
| 97 |
-
img_input = gr.Image(label="
|
| 98 |
-
with gr.Row():
|
| 99 |
-
btn_reset = gr.Button(value="Reset", variant="stop")
|
| 100 |
-
btn_swap = gr.Button(value="Ok", variant="primary")
|
| 101 |
-
|
| 102 |
with gr.Column(scale=2):
|
| 103 |
with gr.Row():
|
| 104 |
-
img_output = gr.Image(label="
|
|
|
|
|
|
|
| 105 |
|
| 106 |
with gr.TabItem("Examples", id=1):
|
| 107 |
gr.Examples(examples=glob("lowres/*"), inputs=[img_input], label="Low resolution")
|
|
@@ -126,11 +120,10 @@ with gr.Blocks(title="Face Shine") as app:
|
|
| 126 |
btn_color.click(colorize_photo, inputs=[img_input], outputs=[img_output])
|
| 127 |
btn_light.click(enhance_light, inputs=[img_input], outputs=[img_output])
|
| 128 |
btn_clear.click(zero_background, inputs=[img_input], outputs=[img_output])
|
| 129 |
-
btn_swap.click(mirror, inputs=[img_output], outputs=[img_input])
|
| 130 |
-
btn_reset.click(clear, outputs=[img_input, img_output])
|
| 131 |
|
| 132 |
with gr.Row():
|
| 133 |
gr.HTML(footer)
|
| 134 |
|
| 135 |
app.launch(share=False, debug=True, show_error=True)
|
| 136 |
-
app.queue()
|
|
|
|
| 44 |
return make_flatten_background(image, img_cut, mask)
|
| 45 |
|
| 46 |
|
|
|
|
| 47 |
def parse_face(image):
|
| 48 |
return clients["FaceParser"].predict(image, api_name="/predict")
|
| 49 |
|
| 50 |
|
| 51 |
+
def mirror(x, y):
|
| 52 |
+
return x, y
|
| 53 |
|
| 54 |
|
| 55 |
def active_first():
|
| 56 |
return gr.Tabs.update(selected=0)
|
| 57 |
|
| 58 |
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
footer = r"""
|
| 61 |
<center>
|
|
|
|
| 90 |
|
| 91 |
with gr.Column(scale=2):
|
| 92 |
with gr.Row():
|
| 93 |
+
img_input = gr.Image(label="Image workspace", type="filepath")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
with gr.Column(scale=2):
|
| 95 |
with gr.Row():
|
| 96 |
+
img_output = gr.Image(label="Image result", type="filepath", interactive=False)
|
| 97 |
+
with gr.Row():
|
| 98 |
+
btn_swap = gr.Button(value="<= Swap =>", variant="primary")
|
| 99 |
|
| 100 |
with gr.TabItem("Examples", id=1):
|
| 101 |
gr.Examples(examples=glob("lowres/*"), inputs=[img_input], label="Low resolution")
|
|
|
|
| 120 |
btn_color.click(colorize_photo, inputs=[img_input], outputs=[img_output])
|
| 121 |
btn_light.click(enhance_light, inputs=[img_input], outputs=[img_output])
|
| 122 |
btn_clear.click(zero_background, inputs=[img_input], outputs=[img_output])
|
| 123 |
+
btn_swap.click(mirror, inputs=[img_output, img_input], outputs=[img_input, img_output])
|
|
|
|
| 124 |
|
| 125 |
with gr.Row():
|
| 126 |
gr.HTML(footer)
|
| 127 |
|
| 128 |
app.launch(share=False, debug=True, show_error=True)
|
| 129 |
+
app.queue()
|