guangkaixu commited on
Commit
5463b93
·
verified ·
1 Parent(s): 96c15e5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +71 -5
app.py CHANGED
@@ -101,7 +101,7 @@ def process_image(
101
  def run_demo_server(pipe_depth, pipe_normal, pipe_dis):
102
  process_pipe_depth = spaces.GPU(functools.partial(process_image, pipe_depth, mode='depth'))
103
  process_pipe_normal = spaces.GPU(functools.partial(process_image, pipe_normal, mode='normal'))
104
- process_pipe_dis = spaces.GPU(functools.partial(process_image, pipe_dis, mode='dis'))
105
  gradio_theme = gr.themes.Default()
106
 
107
  with gr.Blocks(
@@ -180,7 +180,7 @@ def run_demo_server(pipe_depth, pipe_normal, pipe_dis):
180
  type="filepath",
181
  )
182
  with gr.Row():
183
- image_submit_btn = gr.Button(
184
  value="Estimate Depth", variant="primary"
185
  )
186
  image_reset_btn = gr.Button(value="Reset")
@@ -285,7 +285,7 @@ def run_demo_server(pipe_depth, pipe_normal, pipe_dis):
285
  )
286
  with gr.Row():
287
  image_submit_btn = gr.Button(
288
- value="Estimate Segmentation.", variant="primary"
289
  )
290
  image_reset_btn = gr.Button(value="Reset")
291
  with gr.Accordion("Advanced options", open=False):
@@ -329,7 +329,40 @@ def run_demo_server(pipe_depth, pipe_normal, pipe_dis):
329
 
330
 
331
  ### Image tab
332
- image_submit_btn.click(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
333
  fn=process_image_check,
334
  inputs=image_input,
335
  outputs=None,
@@ -345,7 +378,40 @@ def run_demo_server(pipe_depth, pipe_normal, pipe_dis):
345
  concurrency_limit=1,
346
  )
347
 
348
- image_reset_btn.click(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
349
  fn=lambda: (
350
  None,
351
  None,
 
101
  def run_demo_server(pipe_depth, pipe_normal, pipe_dis):
102
  process_pipe_depth = spaces.GPU(functools.partial(process_image, pipe_depth, mode='depth'))
103
  process_pipe_normal = spaces.GPU(functools.partial(process_image, pipe_normal, mode='normal'))
104
+ process_pipe_dis = spaces.GPU(functools.partial(process_image, pipe_dis, mode='seg'))
105
  gradio_theme = gr.themes.Default()
106
 
107
  with gr.Blocks(
 
180
  type="filepath",
181
  )
182
  with gr.Row():
183
+ depth_image_submit_btn = gr.Button(
184
  value="Estimate Depth", variant="primary"
185
  )
186
  image_reset_btn = gr.Button(value="Reset")
 
285
  )
286
  with gr.Row():
287
  image_submit_btn = gr.Button(
288
+ value="Estimate Dichotomous Segmentation.", variant="primary"
289
  )
290
  image_reset_btn = gr.Button(value="Reset")
291
  with gr.Accordion("Advanced options", open=False):
 
329
 
330
 
331
  ### Image tab
332
+ depth_image_submit_btn.click(
333
+ fn=process_image_check,
334
+ inputs=image_input,
335
+ outputs=None,
336
+ preprocess=False,
337
+ queue=False,
338
+ ).success(
339
+ fn=process_pipe_depth,
340
+ inputs=[
341
+ image_input,
342
+ image_processing_res,
343
+ ],
344
+ outputs=[image_output_slider, image_output_files],
345
+ concurrency_limit=1,
346
+ )
347
+
348
+ depth_image_reset_btn.click(
349
+ fn=lambda: (
350
+ None,
351
+ None,
352
+ None,
353
+ default_image_processing_res,
354
+ ),
355
+ inputs=[],
356
+ outputs=[
357
+ image_input,
358
+ image_output_slider,
359
+ image_output_files,
360
+ image_processing_res,
361
+ ],
362
+ queue=False,
363
+ )
364
+
365
+ normal_image_submit_btn.click(
366
  fn=process_image_check,
367
  inputs=image_input,
368
  outputs=None,
 
378
  concurrency_limit=1,
379
  )
380
 
381
+ normal_image_reset_btn.click(
382
+ fn=lambda: (
383
+ None,
384
+ None,
385
+ None,
386
+ default_image_processing_res,
387
+ ),
388
+ inputs=[],
389
+ outputs=[
390
+ image_input,
391
+ image_output_slider,
392
+ image_output_files,
393
+ image_processing_res,
394
+ ],
395
+ queue=False,
396
+ )
397
+
398
+ dis_image_submit_btn.click(
399
+ fn=process_image_check,
400
+ inputs=image_input,
401
+ outputs=None,
402
+ preprocess=False,
403
+ queue=False,
404
+ ).success(
405
+ fn=process_pipe_dis,
406
+ inputs=[
407
+ image_input,
408
+ image_processing_res,
409
+ ],
410
+ outputs=[image_output_slider, image_output_files],
411
+ concurrency_limit=1,
412
+ )
413
+
414
+ dis_image_reset_btn.click(
415
  fn=lambda: (
416
  None,
417
  None,