Mask_rcnn: how to draw bounding box and mask only on few classes

Created on 7 Mar 2018  路  9Comments  路  Source: matterport/Mask_RCNN

while testing the images I want to draw mask or bounding box only on the class I want to.
for eg. I want to detect person in an image then bounding box should be drawn on person class only
it should not draw on any other class of coco dataset .

can u tell me how to do that?

All 9 comments

From the demo.ipynb,
you can get the output data and create your own display method. It should be easy to do
r = results[0] #this variable contains the bboxes and class_ids of the detected instances

You also can edit the display_instances in the visualize.py

def display_instances(image, boxes, masks, class_ids, class_names,
                      scores=None, title="",
                      figsize=(16, 16), ax=None):

thank you for ur help.
now I'm able to successfully print the bounding box and mask over my interested class only.
I just read the corresponding id of my class ( i.e person ) and i put this line under display_instance method as u told...
if ( class_id ==1 ):
then draw box or mask.
Thank You.

what is the location of visualize.py ?

inside Mask_RCNN/mrcnn/visualize.py

got it . but after doing that i get following error

UnboundLocalError: local variable 'box' referenced before assignment
and
index out of range. any solution?

how you are doing that ..send me code that u have modified for your requirement

and what is ur requirement ..

I want to detect a human and a motorcycle ONLY.
how can I send you the code?
`

through email or post here?

Was this page helpful?
0 / 5 - 0 ratings