Skip to content

bugfixes batched images #96

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions scripts/depthmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down