name: data-preparation
description: "Guides Mask_RCNN dataset subclassing, mask formats, sample dataset
layouts, validation, resizing, and synthetic fixtures."
disable-model-invocation: true
metadata:
disco-role: operating
license: NOASSERTION
Data Preparation
Use this sub-skill when a task asks how to prepare images, masks, polygons, COCO annotations, VIA JSON, nucleus challenge folders, or custom mrcnn.utils.Dataset subclasses for Mask_RCNN.
Read first by need
Dataset preparation workflow
-
Subclass mrcnn.utils.Dataset.
-
In a loader method, call add_class(source, class_id, class_name) and add_image(source, image_id, path, **metadata) for each image.
-
Implement load_mask(image_id) to return:
mask: np.ndarray # shape [height, width, instance_count], bool or 0/1
class_ids: np.ndarray # shape [instance_count], dtype int32
-
Override load_image() only when images are generated or not stored as ordinary files.
-
Call dataset.prepare() before using dataset.image_ids, class_names, source_class_ids, load_image_gt, training, or visualization.
-
Use mrcnn.model.load_image_gt(dataset, config, image_id, augmentation=..., use_mini_mask=...) to check the full preprocessing path.
Data-specific routes
- VIA polygons / Balloon-style one-class dataset: validate folder split and
via_region_data.json; read data-formats.md.
- COCO: validate
annotations/instances_<subset><year>.json plus <subset><year>/ images; pycocotools is required for actual loading and evaluation.
- Nucleus / Data Science Bowl: validate
<image_id>/images/<image_id>.png and optional <image_id>/masks/*.png; RLE output is owned by inference-evaluation.
- Synthetic Shapes: use generated shapes for quick data-pipeline checks; do not treat them as proof of real dataset quality.
Boundary notes
This sub-skill validates and explains data. For training schedules, layer choices, checkpoints, and weight loading, route to training. For prediction outputs, COCO AP, visualization, color splash, or RLE submission files, route to inference-evaluation.