diff --git a/scripts/depthmap.py b/scripts/depthmap.py index 8ee57a3..5a30181 100644 --- a/scripts/depthmap.py +++ b/scripts/depthmap.py @@ -150,7 +150,7 @@ def run(self, p, compute_device, model_type, net_width, net_height, match_size, inputimages = [] for count in range(0, len(processed.images)): # skip first grid image - if count == 0 and len(processed.images) > 1: + if count == 0 and len(processed.images) > 1 and opts.return_grid: continue inputimages.append(processed.images[count]) @@ -407,10 +407,10 @@ def run_depthmap(processed, outpath, inputimages, inputnames, compute_device, mo #applying background masks after depth if background_removal: print('applying background masks') - background_removed_image = background_removed_images[count-1] + background_removed_image = background_removed_images[count] #maybe a threshold cut would be better on the line below. background_removed_array = np.array(background_removed_image) - bg_mask = (background_removed_array[:,:,0]==0)|(background_removed_array[:,:,1]==0)|(background_removed_array[:,:,2]==0) + bg_mask = (background_removed_array[:,:,0]==0)&(background_removed_array[:,:,1]==0)&(background_removed_array[:,:,2]==0)&(background_removed_array[:,:,3]<=0.2) far_value = 255 if invert_depth else 0 img_output[bg_mask] = far_value * far_value #255*255 or 0*0 @@ -1345,9 +1345,6 @@ def batched_background_removal(inimages, model_name): #starting a session background_removal_session = new_session(model_name) for count in range(0, len(inimages)): - # skip first grid image - if count == 0 and len(inimages) > 1: - continue bg_remove_img = np.array(remove(inimages[count], session=background_removal_session)) outimages.append(Image.fromarray(bg_remove_img)) #The line below might be redundant