I want to count the total number of pixels for each segmented class, I only need the count for each general objects, like one class for every vehicle, one for every person and so on. For this reason, I’m using semantic segmentation instead of instance segmentation (which would consider each vehicle or person instance separately).But the output of semantic segmentation in detectron2 does not have binary mask.
I know the output of instance segmentation is binary mask and can get the pixel count using the following code:
masks = output['instances'].pred_masks
results = torch.sum(torch.flatten(masks, start_dim=1),dim=1)
This gives the pixel count but considers each vehicle instance separately which I do not want
.
But the output of semantic segmentation is the field ‘sem_seg’ which contains class label index for each general class and not binary mask, how can I go on into getting the pixel count for each class in semantic segmentation?
Sayem is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.