Mask R-CNN Demo
A quick intro to using the pre-trained model to detect and segment objects.
Configurations
We'll be using a model trained on the MS-COCO dataset. The configurations of this model are in the CocoConfig
class in coco.py
.
For inferencing, modify the configurations a bit to fit the task. To do so, sub-class the CocoConfig
class and override the attributes you need to change.
Create Model and Load Trained Weights
Class Names
The model classifies objects and returns class IDs, which are integer value that identify each class. Some datasets assign integer values to their classes and some don't. For example, in the MS-COCO dataset, the 'person' class is 1 and 'teddy bear' is 88. The IDs are often sequential, but not always. The COCO dataset, for example, has classes associated with class IDs 70 and 72, but not 71.
To improve consistency, and to support training on data from multiple sources at the same time, our Dataset
class assigns it's own sequential integer IDs to each class. For example, if you load the COCO dataset using our Dataset
class, the 'person' class would get class ID = 1 (just like COCO) and the 'teddy bear' class is 78 (different from COCO). Keep that in mind when mapping class IDs to class names.
To get the list of class names, you'd load the dataset and then use the class_names
property like this.
We don't want to require you to download the COCO dataset just to run this demo, so we're including the list of class names below. The index of the class name in the list represent its ID (first class is 0, second is 1, third is 2, ...etc.)