@@ -105,7 +105,8 @@ def main_ui_panel(is_depth_tab):
105
105
gr .HTML ("More options for generating video can be found in the Generate video tab" )
106
106
107
107
with gr .Group ():
108
- # TODO: it should be clear from the UI that the background removal does not use the model selected above
108
+ # TODO: it should be clear from the UI that there is an option of the background removal
109
+ # that does not use the model selected above
109
110
with gr .Row ():
110
111
inp += "background_removal" , gr .Checkbox (label = "Remove background" , value = False )
111
112
with gr .Row (visible = False ) as bgrem_options_row_1 :
@@ -236,7 +237,7 @@ def on_ui_tabs():
236
237
** backbone .get_hide_dirs (),
237
238
placeholder = "A directory on the same machine where the server is running." )
238
239
inp += gr .Textbox (elem_id = "depthmap_batch_output_dir" , label = "Output directory" ,
239
- ** backbone .get_hide_dirs ,
240
+ ** backbone .get_hide_dirs () ,
240
241
placeholder = "Leave blank to save images to the default path." )
241
242
gr .HTML ("Files in the output directory may be overwritten." )
242
243
inp += gr .Checkbox (elem_id = "depthmap_batch_reuse" ,
@@ -273,7 +274,7 @@ def on_ui_tabs():
273
274
with gr .Column ():
274
275
vid_html_info_x = gr .HTML ()
275
276
vid_html_info = gr .HTML ()
276
- fn_mesh = gr .Textbox (label = "Input Mesh (.ply | .obj)" , ** shared . hide_dirs ,
277
+ fn_mesh = gr .Textbox (label = "Input Mesh (.ply | .obj)" , ** backbone . get_hide_dirs () ,
277
278
placeholder = "A file on the same machine where "
278
279
"the server is running." )
279
280
with gr .Row ():
@@ -377,7 +378,7 @@ def run_generate(*inputs):
377
378
if depthmap_mode == '2' and depthmap_batch_output_dir != '' :
378
379
outpath = depthmap_batch_output_dir
379
380
else :
380
- outpath = backbone .opts . outdir_samples or backbone . opts . outdir_extras_samples
381
+ outpath = backbone .get_outpath ()
381
382
382
383
if depthmap_mode == '0' : # Single image
383
384
if depthmap_input_image is None :
@@ -399,7 +400,7 @@ def run_generate(*inputs):
399
400
inputimages .append (image )
400
401
inputnames .append (os .path .splitext (img .orig_name )[0 ])
401
402
elif depthmap_mode == '2' : # Batch from Directory
402
- assert not backbone .cmd_opts . hide_ui_dir_config , '--hide-ui-dir-config option must be disabled'
403
+ assert not backbone .get_opt ( ' hide_ui_dir_config' , False ) , '--hide-ui-dir-config option must be disabled'
403
404
if depthmap_batch_input_dir == '' :
404
405
return [], None , None , "Please select an input directory."
405
406
if depthmap_batch_input_dir == depthmap_batch_output_dir :
@@ -414,9 +415,9 @@ def run_generate(*inputs):
414
415
if depthmap_batch_reuse :
415
416
basename = Path (path ).stem
416
417
# Custom names are not used in samples directory
417
- if outpath != backbone .opts . outdir_extras_samples :
418
+ if outpath != backbone .get_opt ( ' outdir_extras_samples' , None ) :
418
419
# Possible filenames that the custom depthmaps may have
419
- name_candidates = [f'{ basename } -0000.{ backbone .opts . samples_format } ' , # current format
420
+ name_candidates = [f'{ basename } -0000.{ backbone .get_opt ( " samples_format" , "png" ) } ' , # current format
420
421
f'{ basename } .png' , # human-intuitive format
421
422
f'{ Path (path ).name } ' ] # human-intuitive format (worse)
422
423
for fn_cand in name_candidates :
@@ -430,22 +431,22 @@ def run_generate(*inputs):
430
431
inputdepthmaps_n = len ([1 for x in inputdepthmaps if x is not None ])
431
432
print (f'{ len (inputimages )} images will be processed, { inputdepthmaps_n } existing depthmaps will be reused' )
432
433
433
- outputs , mesh_fi , meshsimple_fi = core_generation_funnel (outpath , inputimages , inputdepthmaps , inputnames , inputs , backbone .gather_ops ())
434
+ outputs , fn_mesh , display_mesh = core_generation_funnel (outpath , inputimages , inputdepthmaps , inputnames , inputs , backbone .gather_ops ())
434
435
435
436
# Saving images
436
437
show_images = []
437
438
for input_i , imgs in enumerate (outputs ):
438
439
basename = 'depthmap'
439
- if depthmap_mode == '2' and inputnames [input_i ] is not None and outpath != backbone .opts . outdir_extras_samples :
440
+ if depthmap_mode == '2' and inputnames [input_i ] is not None and outpath != backbone .get_opt ( ' outdir_extras_samples' , None ) :
440
441
basename = Path (inputnames [input_i ]).stem
441
442
442
443
for image_type , image in list (imgs .items ()):
443
444
show_images += [image ]
444
445
if inputs ["save_outputs" ]:
445
446
try :
446
- suffix = "" if image_type == "depth" else f"_ { image_type } "
447
+ suffix = "" if image_type == "depth" else f"{ image_type } "
447
448
backbone .save_image (image , path = outpath , basename = basename , seed = None ,
448
- prompt = None , extension = backbone .opts . samples_format , short_filename = True ,
449
+ prompt = None , extension = backbone .get_opt ( ' samples_format' , 'png' ) , short_filename = True ,
449
450
no_prompt = True , grid = False , pnginfo_section_name = "extras" ,
450
451
suffix = suffix )
451
452
except Exception as e :
@@ -454,12 +455,12 @@ def run_generate(*inputs):
454
455
print ('Catched exception: image has wrong mode!' )
455
456
traceback .print_exc ()
456
457
458
+ display_mesh = None
457
459
# use inpainted 3d mesh to show in 3d model output when enabled in settings
458
- if hasattr (backbone .opts , 'depthmap_script_show_3d_inpaint' ) and backbone .opts .depthmap_script_show_3d_inpaint \
459
- and mesh_fi is not None and len (mesh_fi ) > 0 :
460
- meshsimple_fi = mesh_fi
460
+ if backbone .get_opt ('depthmap_script_show_3d_inpaint' , True ) and fn_mesh is not None and len (fn_mesh ) > 0 :
461
+ display_mesh = fn_mesh
461
462
# however, don't show 3dmodel when disabled in settings
462
- if hasattr ( backbone .opts , 'depthmap_script_show_3d' ) and not backbone . opts . depthmap_script_show_3d :
463
- meshsimple_fi = None
463
+ if not backbone .get_opt ( 'depthmap_script_show_3d' , True ) :
464
+ display_mesh = None
464
465
# TODO: return more info
465
- return show_images , mesh_fi , meshsimple_fi , 'Generated!'
466
+ return show_images , fn_mesh , display_mesh , 'Generated!'
0 commit comments