Spaces:
Running
on
Zero
Running
on
Zero
Added use as input image for output image. and also submits when user clicks enter at prompt.
Browse files
app.py
CHANGED
|
@@ -108,8 +108,7 @@ with gr.Blocks(fill_height=True, fill_width=True) as demo:
|
|
| 108 |
type="pil",
|
| 109 |
label="Input Image",
|
| 110 |
crop_size=(1024, 1024),
|
| 111 |
-
layers=False
|
| 112 |
-
sources=["upload"],
|
| 113 |
)
|
| 114 |
|
| 115 |
result = ImageSlider(
|
|
@@ -117,15 +116,52 @@ with gr.Blocks(fill_height=True, fill_width=True) as demo:
|
|
| 117 |
label="Generated Image",
|
| 118 |
)
|
| 119 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
run_button.click(
|
| 121 |
fn=clear_result,
|
| 122 |
inputs=None,
|
| 123 |
outputs=result,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
).then(
|
| 125 |
fn=fill_image,
|
| 126 |
inputs=[prompt, input_image, model_selection],
|
| 127 |
outputs=result,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
)
|
| 129 |
|
| 130 |
|
| 131 |
-
demo.launch(share=False)
|
|
|
|
| 108 |
type="pil",
|
| 109 |
label="Input Image",
|
| 110 |
crop_size=(1024, 1024),
|
| 111 |
+
layers=False
|
|
|
|
| 112 |
)
|
| 113 |
|
| 114 |
result = ImageSlider(
|
|
|
|
| 116 |
label="Generated Image",
|
| 117 |
)
|
| 118 |
|
| 119 |
+
use_as_input_button = gr.Button("Use as Input Image", visible=False)
|
| 120 |
+
|
| 121 |
+
def use_output_as_input(output_image):
|
| 122 |
+
return gr.update(value=output_image[1])
|
| 123 |
+
|
| 124 |
+
use_as_input_button.click(
|
| 125 |
+
fn=use_output_as_input,
|
| 126 |
+
inputs=[result],
|
| 127 |
+
outputs=[input_image]
|
| 128 |
+
)
|
| 129 |
+
|
| 130 |
run_button.click(
|
| 131 |
fn=clear_result,
|
| 132 |
inputs=None,
|
| 133 |
outputs=result,
|
| 134 |
+
).then(
|
| 135 |
+
fn=lambda: gr.update(visible=False),
|
| 136 |
+
inputs=None,
|
| 137 |
+
outputs=use_as_input_button,
|
| 138 |
).then(
|
| 139 |
fn=fill_image,
|
| 140 |
inputs=[prompt, input_image, model_selection],
|
| 141 |
outputs=result,
|
| 142 |
+
).then(
|
| 143 |
+
fn=lambda: gr.update(visible=True),
|
| 144 |
+
inputs=None,
|
| 145 |
+
outputs=use_as_input_button,
|
| 146 |
+
)
|
| 147 |
+
|
| 148 |
+
prompt.submit(
|
| 149 |
+
fn=clear_result,
|
| 150 |
+
inputs=None,
|
| 151 |
+
outputs=result,
|
| 152 |
+
).then(
|
| 153 |
+
fn=lambda: gr.update(visible=False),
|
| 154 |
+
inputs=None,
|
| 155 |
+
outputs=use_as_input_button,
|
| 156 |
+
).then(
|
| 157 |
+
fn=fill_image,
|
| 158 |
+
inputs=[prompt, input_image, model_selection],
|
| 159 |
+
outputs=result,
|
| 160 |
+
).then(
|
| 161 |
+
fn=lambda: gr.update(visible=True),
|
| 162 |
+
inputs=None,
|
| 163 |
+
outputs=use_as_input_button,
|
| 164 |
)
|
| 165 |
|
| 166 |
|
| 167 |
+
demo.launch(share=False)
|