Combining all masks to one mask? #3882
Unanswered
mrmoonshine24
asked this question in
Q&A
Replies: 1 comment 2 replies
-
when you get your mask array with shape [5, 768, 1159] just do PS your for loop looks weird. You are reassigning the output each iteration. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all,
I am currently working on a schoolproject and therefor we need to use detectron2. However I want to combine all the detected masks from detectron2 in 1 masks, so basically having the following: [768, 1159, 3 ] where the 3 needs to be combined in 1. below you can see the code:
`mask_array = result['instances'].pred_masks.numpy()
print(mask_array.shape)
[5, 768, 1159]
num_instances = mask_array.shape[0]
mask_array = np.moveaxis(mask_array, 0, -1)
mask_array_instance = []
output = np.zeros_like(images) #black
#print('output',output)
for i in range(num_instances):
mask_array_instance.append(mask_array[:, :, i:(i+1)])
output = np.where(mask_array_instance[i] == True, 255, output)
masks = output #mask
print(masks)
[768, 1159, 3] `
so the 3 needs to be just 1 mask...
thank you so much for your time and effort.
Beta Was this translation helpful? Give feedback.
All reactions