Skip to content

Commit a3373aa

Browse files
authored
Merge pull request thygate#96 from graemeniedermayer/depth
bugfixes batched images
2 parents 0a23e63 + 3eeb086 commit a3373aa

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

scripts/depthmap.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def run(self, p, compute_device, model_type, net_width, net_height, match_size,
150150
inputimages = []
151151
for count in range(0, len(processed.images)):
152152
# 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:
154154
continue
155155
inputimages.append(processed.images[count])
156156

@@ -407,10 +407,10 @@ def run_depthmap(processed, outpath, inputimages, inputnames, compute_device, mo
407407
#applying background masks after depth
408408
if background_removal:
409409
print('applying background masks')
410-
background_removed_image = background_removed_images[count-1]
410+
background_removed_image = background_removed_images[count]
411411
#maybe a threshold cut would be better on the line below.
412412
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)
414414
far_value = 255 if invert_depth else 0
415415

416416
img_output[bg_mask] = far_value * far_value #255*255 or 0*0
@@ -1345,9 +1345,6 @@ def batched_background_removal(inimages, model_name):
13451345
#starting a session
13461346
background_removal_session = new_session(model_name)
13471347
for count in range(0, len(inimages)):
1348-
# skip first grid image
1349-
if count == 0 and len(inimages) > 1:
1350-
continue
13511348
bg_remove_img = np.array(remove(inimages[count], session=background_removal_session))
13521349
outimages.append(Image.fromarray(bg_remove_img))
13531350
#The line below might be redundant

0 commit comments

Comments
 (0)