Spaces:
Running
Running
yizhangliu
commited on
Commit
β’
a006e4e
1
Parent(s):
b314d07
add 'save' button to download image for mobile devices
Browse files
app.py
CHANGED
@@ -192,7 +192,7 @@ def predict(input, img_enhancer):
|
|
192 |
image = np.array(image_pil)
|
193 |
mask = np.array(mask_pil.convert("L"))
|
194 |
output = model_process(image, mask, img_enhancer)
|
195 |
-
return output, gr.update(visible=True)
|
196 |
|
197 |
css = '''
|
198 |
.container {max-width: 1150px; margin: auto;padding-top: 1.5rem}
|
@@ -209,9 +209,12 @@ css = '''
|
|
209 |
#image_output{margin: 0 auto; text-align: center;width:640px}
|
210 |
|
211 |
#download-container{margin: 0 auto; text-align: center;width:fit-content; min-width: min(150px, 100%);flex-grow: 0; flex-wrap: nowrap;}
|
212 |
-
|
|
|
213 |
#download-btn {padding:0;}
|
214 |
|
|
|
|
|
215 |
#image_upload .touch-none{display: flex}
|
216 |
@keyframes spin {
|
217 |
from {
|
@@ -272,6 +275,8 @@ set_page_elements = """async() => {
|
|
272 |
const share_btn_container = gradioEl.querySelectorAll('#share-btn-container')[0];
|
273 |
share_btn_container.setAttribute('style', 'width: 0px; height:0px;');
|
274 |
|
|
|
|
|
275 |
} else {
|
276 |
max_height = 800;
|
277 |
image_upload.setAttribute('style', 'min-height: ' + max_height + 'px; overflow-x: overlay');
|
@@ -365,18 +370,19 @@ with image_blocks as demo:
|
|
365 |
with gr.Row(elem_id="output-container"):
|
366 |
with gr.Column():
|
367 |
image_out = gr.Image(elem_id="image_output",label="Result", show_label=False)
|
368 |
-
with gr.Group(elem_id="share-btn-container", visible=False) as share_btn_container:
|
369 |
-
community_icon = gr.HTML(community_icon_html)
|
370 |
-
loading_icon = gr.HTML(loading_icon_html)
|
371 |
-
share_button = gr.Button("Share to community", elem_id="share-btn")
|
372 |
with gr.Row(elem_id="download-container", visible=False) as download_container:
|
373 |
-
with gr.Column(elem_id="download-btn-container"):
|
374 |
-
download_button = gr.Button(elem_id="download-btn", value="Save(β)")
|
375 |
-
|
376 |
-
|
|
|
|
|
|
|
|
|
|
|
377 |
download_button.click(None, [], [], _js=download_img)
|
378 |
share_button.click(None, [], [], _js=share_js)
|
379 |
|
380 |
begin_button.click(fn=None, inputs=[], outputs=[group_1, group_2], _js=set_page_elements)
|
381 |
|
382 |
-
image_blocks.launch(server_name='0.0.0.0')
|
|
|
192 |
image = np.array(image_pil)
|
193 |
mask = np.array(mask_pil.convert("L"))
|
194 |
output = model_process(image, mask, img_enhancer)
|
195 |
+
return output, gr.update(visible=True)
|
196 |
|
197 |
css = '''
|
198 |
.container {max-width: 1150px; margin: auto;padding-top: 1.5rem}
|
|
|
209 |
#image_output{margin: 0 auto; text-align: center;width:640px}
|
210 |
|
211 |
#download-container{margin: 0 auto; text-align: center;width:fit-content; min-width: min(150px, 100%);flex-grow: 0; flex-wrap: nowrap;}
|
212 |
+
|
213 |
+
#download-btn-container{margin: 0 auto; text-align: center;width: 100px;border-width:1px;border-color:#2c9748}
|
214 |
#download-btn {padding:0;}
|
215 |
|
216 |
+
#share-container{margin: 0 auto; text-align: center;width:fit-content; min-width: min(150px, 100%);flex-grow: 0; flex-wrap: nowrap;}
|
217 |
+
|
218 |
#image_upload .touch-none{display: flex}
|
219 |
@keyframes spin {
|
220 |
from {
|
|
|
275 |
const share_btn_container = gradioEl.querySelectorAll('#share-btn-container')[0];
|
276 |
share_btn_container.setAttribute('style', 'width: 0px; height:0px;');
|
277 |
|
278 |
+
const share_btn_share_icon = gradioEl.querySelectorAll('#share-btn-share-icon')[0];
|
279 |
+
share_btn_share_icon.setAttribute('style', 'width: 0px; height:0px;');
|
280 |
} else {
|
281 |
max_height = 800;
|
282 |
image_upload.setAttribute('style', 'min-height: ' + max_height + 'px; overflow-x: overlay');
|
|
|
370 |
with gr.Row(elem_id="output-container"):
|
371 |
with gr.Column():
|
372 |
image_out = gr.Image(elem_id="image_output",label="Result", show_label=False)
|
|
|
|
|
|
|
|
|
373 |
with gr.Row(elem_id="download-container", visible=False) as download_container:
|
374 |
+
with gr.Column(elem_id="download-btn-container") as download_btn_container:
|
375 |
+
download_button = gr.Button(elem_id="download-btn", value="Save(β)")
|
376 |
+
with gr.Column(elem_id="share-container") as share_container:
|
377 |
+
with gr.Group(elem_id="share-btn-container"):
|
378 |
+
community_icon = gr.HTML(community_icon_html, elem_id="community-icon", visible=True)
|
379 |
+
loading_icon = gr.HTML(loading_icon_html, elem_id="loading-icon", visible=True)
|
380 |
+
share_button = gr.Button("Share to community", elem_id="share-btn", visible=True)
|
381 |
+
|
382 |
+
erase_btn.click(fn=predict, inputs=[image_input, img_enhancer], outputs=[image_out, download_container])
|
383 |
download_button.click(None, [], [], _js=download_img)
|
384 |
share_button.click(None, [], [], _js=share_js)
|
385 |
|
386 |
begin_button.click(fn=None, inputs=[], outputs=[group_1, group_2], _js=set_page_elements)
|
387 |
|
388 |
+
image_blocks.launch(server_name='0.0.0.0')
|