yizhangliu commited on
Commit
9abc2ce
1 Parent(s): 9de9483

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -183,7 +183,7 @@ model = ModelManager(
183
  )
184
 
185
  image_type = 'pil' # filepath'
186
- def predict(input, img_enhancer):
187
  if input is None:
188
  return None, [], gr.update(visible=False)
189
  if image_type == 'filepath':
@@ -199,7 +199,10 @@ def predict(input, img_enhancer):
199
  image = np.array(image_pil)
200
  mask = np.array(mask_pil.convert("L"))
201
  output, ori_image = model_process(image, mask, img_enhancer)
202
- return output, [resize_image(ori_image, new_width=400), resize_image(output, new_width=400)], gr.update(visible=True)
 
 
 
203
 
204
  image_blocks = gr.Blocks(css=css, title='Image Cleaner')
205
  with image_blocks as demo:
@@ -256,6 +259,8 @@ with image_blocks as demo:
256
  gallery = gr.Gallery(
257
  label="Generated images", show_label=False, elem_id="gallery"
258
  ).style(grid=[2], height="600px")
 
 
259
  with gr.Row(elem_id="download-container", visible=False) as download_container:
260
  with gr.Column(elem_id="download-btn-container") as download_btn_container:
261
  download_button = gr.Button(elem_id="download-btn", value="Save(⏩)")
@@ -273,7 +278,7 @@ with image_blocks as demo:
273
  """
274
  )
275
 
276
- erase_btn.click(fn=predict, inputs=[image_input, img_enhancer], outputs=[image_out, gallery, download_container])
277
  download_button.click(None, [], [], _js=download_img)
278
  share_button.click(None, [], [], _js=share_js)
279
 
 
183
  )
184
 
185
  image_type = 'pil' # filepath'
186
+ def predict(input, platform_radio, img_enhancer):
187
  if input is None:
188
  return None, [], gr.update(visible=False)
189
  if image_type == 'filepath':
 
199
  image = np.array(image_pil)
200
  mask = np.array(mask_pil.convert("L"))
201
  output, ori_image = model_process(image, mask, img_enhancer)
202
+ if platform_radio == 'pc':
203
+ return output, [ori_image, output], gr.update(visible=True)
204
+ else:
205
+ return output, [resize_image(ori_image, new_width=400), resize_image(output, new_width=400)], gr.update(visible=True)
206
 
207
  image_blocks = gr.Blocks(css=css, title='Image Cleaner')
208
  with image_blocks as demo:
 
259
  gallery = gr.Gallery(
260
  label="Generated images", show_label=False, elem_id="gallery"
261
  ).style(grid=[2], height="600px")
262
+ platform_radio = gr.Radio(["pc", "mobile"], elem_id="platform_radio",value="pc",
263
+ label="platform:", show_label=True, visible=False)
264
  with gr.Row(elem_id="download-container", visible=False) as download_container:
265
  with gr.Column(elem_id="download-btn-container") as download_btn_container:
266
  download_button = gr.Button(elem_id="download-btn", value="Save(⏩)")
 
278
  """
279
  )
280
 
281
+ erase_btn.click(fn=predict, inputs=[image_input, platform_radio, img_enhancer], outputs=[image_out, gallery, download_container])
282
  download_button.click(None, [], [], _js=download_img)
283
  share_button.click(None, [], [], _js=share_js)
284