matterport / Mask_RCNN

Mask R-CNN for object detection and instance segmentation on Keras and TensorFlow
Other
24.68k stars 11.7k forks source link

How to get how many elements of each class have been detected #1356

Open AlbertoMCS opened 5 years ago

AlbertoMCS commented 5 years ago

Hi,

I set up demo.ipynb correctly so now every time I input an image I get as an output the same image with the elements detected highlighted with different colours. The question is: how can I get how many elements of one class have been detected? e.g. If the network has detected 5 people and 3 cars and I would like to get as an output "5 people, 3 cars".

Thanks,

monjurulkarim commented 5 years ago

You can insert a for loop to count every detected class.

freezurbern commented 5 years ago

You will want to look at the model.detect() output.

andreasalamanos commented 5 years ago

You will want to look at the model.detect() output.

* https://github.com/matterport/Mask_RCNN/blob/master/mrcnn/model.py#L2532
  counting the number of each class_id will give you the information you want.

When I count the number of class_id, using len(r['class_ids'])) it just returns me 1. I suppose it counts the number of classes identified in each image. In my case I have only one class, like nucleus samples. The solution I tried is len(r["rois"]). I think I get the right answer using this.

kimile599 commented 3 years ago

Have you solved this problem ?