@@ -150,7 +150,7 @@ def run(self, p, compute_device, model_type, net_width, net_height, match_size,
150
150
inputimages = []
151
151
for count in range (0 , len (processed .images )):
152
152
# skip first grid image
153
- if count == 0 and len (processed .images ) > 1 :
153
+ if count == 0 and len (processed .images ) > 1 and opts . return_grid :
154
154
continue
155
155
inputimages .append (processed .images [count ])
156
156
@@ -407,10 +407,10 @@ def run_depthmap(processed, outpath, inputimages, inputnames, compute_device, mo
407
407
#applying background masks after depth
408
408
if background_removal :
409
409
print ('applying background masks' )
410
- background_removed_image = background_removed_images [count - 1 ]
410
+ background_removed_image = background_removed_images [count ]
411
411
#maybe a threshold cut would be better on the line below.
412
412
background_removed_array = np .array (background_removed_image )
413
- bg_mask = (background_removed_array [:,:,0 ]== 0 )| (background_removed_array [:,:,1 ]== 0 )| (background_removed_array [:,:,2 ]== 0 )
413
+ bg_mask = (background_removed_array [:,:,0 ]== 0 )& (background_removed_array [:,:,1 ]== 0 )& (background_removed_array [:,:,2 ]== 0 ) & ( background_removed_array [:,:, 3 ] <= 0.2 )
414
414
far_value = 255 if invert_depth else 0
415
415
416
416
img_output [bg_mask ] = far_value * far_value #255*255 or 0*0
@@ -1345,9 +1345,6 @@ def batched_background_removal(inimages, model_name):
1345
1345
#starting a session
1346
1346
background_removal_session = new_session (model_name )
1347
1347
for count in range (0 , len (inimages )):
1348
- # skip first grid image
1349
- if count == 0 and len (inimages ) > 1 :
1350
- continue
1351
1348
bg_remove_img = np .array (remove (inimages [count ], session = background_removal_session ))
1352
1349
outimages .append (Image .fromarray (bg_remove_img ))
1353
1350
#The line below might be redundant
0 commit comments