corebreakout.datasets package

Submodules

corebreakout.datasets.polygondataset module

Dataset class for COCO format segmentation labels

class corebreakout.datasets.polygondataset.PolygonDataset(classes=['col', 'tray'])

Bases: mrcnn.utils.Dataset

Subclass of mrcnn.utils.Dataset for polygonal JSON annotations in labelme format. See wkentaro/labelme to get the GUI. Outputs a JSON file with list of polygon ‘shapes’.

Labels must start with a unique class name, but instances can be differentiated afterward however you like. For example, different col instances can be labeled ‘col1’, ‘col2’, etc. And multiple polygons may belong to a single instance of a class.

The tradeoff is that no class name can a substring of any other class name.

ann_to_mask(ann)

Take JSON annotation dict, return (mask, class_ids) arrays.

Assumes that some classes may have multiple instances (‘col1’, ‘col2’, etc.), and that each labeled instance may be composed of multiple polygons.

static check_classes(classes)

Make sure no class is a substring of any other class.

collect_annotated_images(data_dir, subset)

Check for annotation (‘.json’) and image (‘.jpg’/’.jpeg’) pairs, and add them.

Corresponding annotation and image paths should differ only in their file extensions.

image_reference(image_id)

Return the path of the image corresponding to image_id, if there is one.

label_to_class_id(label)

Return class_id corresponding to label given that label just needs to start with the class name.

load_mask(image_id)

Return the mask and class_ids arrays for a given image_id.

Module contents