guangkaixu commited on
Commit
a9d6e82
1 Parent(s): 76d5ecf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +168 -168
app.py CHANGED
@@ -295,111 +295,111 @@ def run_demo_server(pipe_depth, pipe_normal, pipe_dis):
295
  cache_examples=False,
296
  )
297
 
298
- # with gr.Tab("Normal"):
299
- # with gr.Row():
300
- # with gr.Column():
301
- # normal_image_input = gr.Image(
302
- # label="Input Image",
303
- # type="filepath",
304
- # )
305
- # with gr.Row():
306
- # normal_image_submit_btn = gr.Button(
307
- # value="Estimate Normal", variant="primary"
308
- # )
309
- # normal_image_reset_btn = gr.Button(value="Reset")
310
- # with gr.Accordion("Advanced options", open=False):
311
- # image_processing_res = gr.Radio(
312
- # [
313
- # ("Native", 0),
314
- # ("Recommended", 768),
315
- # ],
316
- # label="Processing resolution",
317
- # value=default_image_processing_res,
318
- # )
319
- # with gr.Column():
320
- # normal_image_output_slider = ImageSlider(
321
- # label="Predicted surface normal",
322
- # type="filepath",
323
- # show_download_button=True,
324
- # show_share_button=True,
325
- # interactive=False,
326
- # elem_classes="slider",
327
- # position=0.25,
328
- # )
329
- # normal_image_output_files = gr.Files(
330
- # label="Normal outputs",
331
- # elem_id="download",
332
- # interactive=False,
333
- # )
334
-
335
- # filenames = []
336
- # filenames.extend(["normal_%d.jpg" %(i+1) for i in range(10)])
337
- # example_folder = os.path.join(os.path.dirname(__file__), "./images")
338
- # Examples(
339
- # fn=process_pipe_normal,
340
- # examples=[
341
- # os.path.join(example_folder, name)
342
- # for name in filenames
343
- # ],
344
- # inputs=[normal_image_input],
345
- # outputs=[normal_image_output_slider, normal_image_output_files],
346
- # # cache_examples=True,
347
- # # directory_name="examples_normal",
348
- # cache_examples=False,
349
- # )
350
 
351
- # with gr.Tab("Dichotomous Segmentation"):
352
- # with gr.Row():
353
- # with gr.Column():
354
- # dis_image_input = gr.Image(
355
- # label="Input Image",
356
- # type="filepath",
357
- # )
358
- # with gr.Row():
359
- # dis_image_submit_btn = gr.Button(
360
- # value="Estimate Dichotomous Segmentation.", variant="primary"
361
- # )
362
- # dis_image_reset_btn = gr.Button(value="Reset")
363
- # with gr.Accordion("Advanced options", open=False):
364
- # image_processing_res = gr.Radio(
365
- # [
366
- # ("Native", 0),
367
- # ("Recommended", 768),
368
- # ],
369
- # label="Processing resolution",
370
- # value=default_image_processing_res,
371
- # )
372
- # with gr.Column():
373
- # dis_image_output_slider = ImageSlider(
374
- # label="Predicted dichotomous image segmentation",
375
- # type="filepath",
376
- # show_download_button=True,
377
- # show_share_button=True,
378
- # interactive=False,
379
- # elem_classes="slider",
380
- # position=0.25,
381
- # )
382
- # dis_image_output_files = gr.Files(
383
- # label="DIS outputs",
384
- # elem_id="download",
385
- # interactive=False,
386
- # )
387
-
388
- # filenames = []
389
- # filenames.extend(["dis_%d.jpg" %(i+1) for i in range(10)])
390
- # example_folder = os.path.join(os.path.dirname(__file__), "./images")
391
- # Examples(
392
- # fn=process_pipe_dis,
393
- # examples=[
394
- # os.path.join(example_folder, name)
395
- # for name in filenames
396
- # ],
397
- # inputs=[dis_image_input],
398
- # outputs=[dis_image_output_slider, dis_image_output_files],
399
- # # cache_examples=True,
400
- # # directory_name="examples_dis",
401
- # cache_examples=False,
402
- # )
403
 
404
 
405
  ### Image tab
@@ -436,71 +436,71 @@ def run_demo_server(pipe_depth, pipe_normal, pipe_dis):
436
  queue=False,
437
  )
438
 
439
- # normal_image_submit_btn.click(
440
- # fn=process_image_check,
441
- # inputs=normal_image_input,
442
- # outputs=None,
443
- # preprocess=False,
444
- # queue=False,
445
- # ).success(
446
- # fn=process_pipe_normal,
447
- # inputs=[
448
- # normal_image_input,
449
- # image_processing_res,
450
- # ],
451
- # outputs=[normal_image_output_slider, normal_image_output_files],
452
- # concurrency_limit=1,
453
- # )
454
-
455
- # normal_image_reset_btn.click(
456
- # fn=lambda: (
457
- # None,
458
- # None,
459
- # None,
460
- # default_image_processing_res,
461
- # ),
462
- # inputs=[],
463
- # outputs=[
464
- # normal_image_input,
465
- # normal_image_output_slider,
466
- # normal_image_output_files,
467
- # image_processing_res,
468
- # ],
469
- # queue=False,
470
- # )
471
 
472
- # dis_image_submit_btn.click(
473
- # fn=process_image_check,
474
- # inputs=dis_image_input,
475
- # outputs=None,
476
- # preprocess=False,
477
- # queue=False,
478
- # ).success(
479
- # fn=process_pipe_dis,
480
- # inputs=[
481
- # dis_image_input,
482
- # image_processing_res,
483
- # ],
484
- # outputs=[dis_image_output_slider, dis_image_output_files],
485
- # concurrency_limit=1,
486
- # )
487
-
488
- # dis_image_reset_btn.click(
489
- # fn=lambda: (
490
- # None,
491
- # None,
492
- # None,
493
- # default_image_processing_res,
494
- # ),
495
- # inputs=[],
496
- # outputs=[
497
- # dis_image_input,
498
- # dis_image_output_slider,
499
- # dis_image_output_files,
500
- # image_processing_res,
501
- # ],
502
- # queue=False,
503
- # )
504
 
505
  ### Server launch
506
 
 
295
  cache_examples=False,
296
  )
297
 
298
+ with gr.Tab("Normal"):
299
+ with gr.Row():
300
+ with gr.Column():
301
+ normal_image_input = gr.Image(
302
+ label="Input Image",
303
+ type="filepath",
304
+ )
305
+ with gr.Row():
306
+ normal_image_submit_btn = gr.Button(
307
+ value="Estimate Normal", variant="primary"
308
+ )
309
+ normal_image_reset_btn = gr.Button(value="Reset")
310
+ with gr.Accordion("Advanced options", open=False):
311
+ image_processing_res = gr.Radio(
312
+ [
313
+ ("Native", 0),
314
+ ("Recommended", 768),
315
+ ],
316
+ label="Processing resolution",
317
+ value=default_image_processing_res,
318
+ )
319
+ with gr.Column():
320
+ normal_image_output_slider = ImageSlider(
321
+ label="Predicted surface normal",
322
+ type="filepath",
323
+ show_download_button=True,
324
+ show_share_button=True,
325
+ interactive=False,
326
+ elem_classes="slider",
327
+ position=0.25,
328
+ )
329
+ normal_image_output_files = gr.Files(
330
+ label="Normal outputs",
331
+ elem_id="download",
332
+ interactive=False,
333
+ )
334
+
335
+ filenames = []
336
+ filenames.extend(["normal_%d.jpg" %(i+1) for i in range(10)])
337
+ example_folder = os.path.join(os.path.dirname(__file__), "./images")
338
+ Examples(
339
+ fn=process_pipe_normal,
340
+ examples=[
341
+ os.path.join(example_folder, 'depth', name)
342
+ for name in filenames
343
+ ],
344
+ inputs=[normal_image_input],
345
+ outputs=[normal_image_output_slider, normal_image_output_files],
346
+ # cache_examples=True,
347
+ # directory_name="examples_normal",
348
+ cache_examples=False,
349
+ )
350
 
351
+ with gr.Tab("Dichotomous Segmentation"):
352
+ with gr.Row():
353
+ with gr.Column():
354
+ dis_image_input = gr.Image(
355
+ label="Input Image",
356
+ type="filepath",
357
+ )
358
+ with gr.Row():
359
+ dis_image_submit_btn = gr.Button(
360
+ value="Estimate Dichotomous Segmentation.", variant="primary"
361
+ )
362
+ dis_image_reset_btn = gr.Button(value="Reset")
363
+ with gr.Accordion("Advanced options", open=False):
364
+ image_processing_res = gr.Radio(
365
+ [
366
+ ("Native", 0),
367
+ ("Recommended", 768),
368
+ ],
369
+ label="Processing resolution",
370
+ value=default_image_processing_res,
371
+ )
372
+ with gr.Column():
373
+ dis_image_output_slider = ImageSlider(
374
+ label="Predicted dichotomous image segmentation",
375
+ type="filepath",
376
+ show_download_button=True,
377
+ show_share_button=True,
378
+ interactive=False,
379
+ elem_classes="slider",
380
+ position=0.25,
381
+ )
382
+ dis_image_output_files = gr.Files(
383
+ label="DIS outputs",
384
+ elem_id="download",
385
+ interactive=False,
386
+ )
387
+
388
+ filenames = []
389
+ filenames.extend(["dis_%d.jpg" %(i+1) for i in range(10)])
390
+ example_folder = os.path.join(os.path.dirname(__file__), "./images")
391
+ Examples(
392
+ fn=process_pipe_dis,
393
+ examples=[
394
+ os.path.join(example_folder, 'depth', name)
395
+ for name in filenames
396
+ ],
397
+ inputs=[dis_image_input],
398
+ outputs=[dis_image_output_slider, dis_image_output_files],
399
+ # cache_examples=True,
400
+ # directory_name="examples_dis",
401
+ cache_examples=False,
402
+ )
403
 
404
 
405
  ### Image tab
 
436
  queue=False,
437
  )
438
 
439
+ normal_image_submit_btn.click(
440
+ fn=process_image_check,
441
+ inputs=normal_image_input,
442
+ outputs=None,
443
+ preprocess=False,
444
+ queue=False,
445
+ ).success(
446
+ fn=process_pipe_normal,
447
+ inputs=[
448
+ normal_image_input,
449
+ image_processing_res,
450
+ ],
451
+ outputs=[normal_image_output_slider, normal_image_output_files],
452
+ concurrency_limit=1,
453
+ )
454
+
455
+ normal_image_reset_btn.click(
456
+ fn=lambda: (
457
+ None,
458
+ None,
459
+ None,
460
+ default_image_processing_res,
461
+ ),
462
+ inputs=[],
463
+ outputs=[
464
+ normal_image_input,
465
+ normal_image_output_slider,
466
+ normal_image_output_files,
467
+ image_processing_res,
468
+ ],
469
+ queue=False,
470
+ )
471
 
472
+ dis_image_submit_btn.click(
473
+ fn=process_image_check,
474
+ inputs=dis_image_input,
475
+ outputs=None,
476
+ preprocess=False,
477
+ queue=False,
478
+ ).success(
479
+ fn=process_pipe_dis,
480
+ inputs=[
481
+ dis_image_input,
482
+ image_processing_res,
483
+ ],
484
+ outputs=[dis_image_output_slider, dis_image_output_files],
485
+ concurrency_limit=1,
486
+ )
487
+
488
+ dis_image_reset_btn.click(
489
+ fn=lambda: (
490
+ None,
491
+ None,
492
+ None,
493
+ default_image_processing_res,
494
+ ),
495
+ inputs=[],
496
+ outputs=[
497
+ dis_image_input,
498
+ dis_image_output_slider,
499
+ dis_image_output_files,
500
+ image_processing_res,
501
+ ],
502
+ queue=False,
503
+ )
504
 
505
  ### Server launch
506