Skip to content

Commit bb4bf46

Browse files
fixing depthtab
1 parent 39cfa3d commit bb4bf46

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

scripts/depthmap.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1048,6 +1048,10 @@ def run_generate(depthmap_mode,
10481048
clipthreshold_far,
10491049
clipthreshold_near,
10501050
inpaint,
1051+
background_removal_model,
1052+
background_removal,
1053+
pre_depth_background_removal,
1054+
save_background_removal_masks,
10511055
vid_format,
10521056
vid_ssaa
10531057
):
@@ -1091,8 +1095,15 @@ def run_generate(depthmap_mode,
10911095
else:
10921096
outpath = opts.outdir_samples or opts.outdir_extras_samples
10931097

1098+
background_removed_images = []
1099+
if background_removal:
1100+
if pre_depth_background_removal:
1101+
imageArr = batched_background_removal(imageArr, background_removal_model)
1102+
background_removed_images = imageArr
1103+
else:
1104+
background_removed_images = batched_background_removal(imageArr, background_removal_model)
10941105

1095-
outputs, mesh_fi = run_depthmap(None, outpath, imageArr, imageNameArr, compute_device, model_type, net_width, net_height, match_size, invert_depth, boost, save_depth, show_depth, show_heat, combine_output, combine_output_axis, gen_stereo, gen_anaglyph, stereo_divergence, stereo_fill, stereo_balance, clipdepth, clipthreshold_far, clipthreshold_near, inpaint, fnExt, vid_ssaa)
1106+
outputs, mesh_fi = run_depthmap(None, outpath, imageArr, imageNameArr, compute_device, model_type, net_width, net_height, match_size, invert_depth, boost, save_depth, show_depth, show_heat, combine_output, combine_output_axis, gen_stereo, gen_anaglyph, stereo_divergence, stereo_fill, stereo_balance, clipdepth, clipthreshold_far, clipthreshold_near, inpaint, fnExt, vid_ssaa, background_removal, background_removed_images, save_background_removal_masks)
10961107

10971108
return outputs, mesh_fi, plaintext_to_html('info'), ''
10981109

@@ -1157,6 +1168,14 @@ def on_ui_tabs():
11571168
with gr.Row():
11581169
inpaint = gr.Checkbox(label="Generate 3D inpainted mesh and demo videos. (Sloooow)",value=False)
11591170

1171+
with gr.Group():
1172+
with gr.Row():
1173+
background_removal_model = gr.Dropdown(label="Model", choices=['u2net','u2netp','u2net_human_seg', 'silueta'], value='u2net', type="value", elem_id="model_type")
1174+
with gr.Row():
1175+
background_removal = gr.Checkbox(label="remove background",value=False)
1176+
save_background_removal_masks = gr.Checkbox(label="save the foreground masks",value=False)
1177+
pre_depth_background_removal = gr.Checkbox(label="pre-depth background removal",value=False)
1178+
11601179
with gr.Box():
11611180
gr.HTML("Information, comment and share @ <a href='https://github.com/thygate/stable-diffusion-webui-depthmap-script'>https://github.com/thygate/stable-diffusion-webui-depthmap-script</a>")
11621181

@@ -1231,6 +1250,10 @@ def on_ui_tabs():
12311250
clipthreshold_far,
12321251
clipthreshold_near,
12331252
inpaint,
1253+
background_removal_model,
1254+
background_removal,
1255+
pre_depth_background_removal,
1256+
save_background_removal_masks,
12341257
vid_format,
12351258
vid_ssaa
12361259
],

0 commit comments

Comments
 (0)