InstanceSegmentationTask#
- class torchgeo.trainers.InstanceSegmentationTask(model='mask-rcnn', backbone='resnet50', weights=None, weights_backbone=None, in_channels=3, num_classes=91, lr=0.001, patience=10, freeze_backbone=False)[source]#
Bases:
BaseTaskInstance Segmentation.
Added in version 0.7.
- ignore = ('weights', 'weights_backbone')#
Parameters to ignore when saving hyperparameters.
- monitor = 'val_segm_map'#
Performance metric to monitor in learning rate scheduler and callbacks.
- mode = 'max'#
Whether the goal is to minimize or maximize the performance metric to monitor.
- __init__(model='mask-rcnn', backbone='resnet50', weights=None, weights_backbone=None, in_channels=3, num_classes=91, lr=0.001, patience=10, freeze_backbone=False)[source]#
Initialize a new InstanceSegmentationTask instance.
Note that we disable the internal normalize+resize transform of the MaskRCNN model. Please ensure your images are appropriately resized before passing them to the model.
- Parameters:
model (str) – Name of the model to use.
backbone (str) – Name of the backbone to use.
weights (WeightsEnum | None) – Initial model weights.
weights_backbone (WeightsEnum | None) – Initial backbone weights.
in_channels (int) – Number of input channels to model.
num_classes (int) – Number of prediction classes (including the background).
lr (float) – Learning rate for optimizer.
patience (int) – Patience for learning rate scheduler.
freeze_backbone (bool) – Freeze the backbone network to fine-tune the decoder and segmentation head.
Added in version 0.9: The weights_backbone parameter.
- configure_models()[source]#
Initialize the model.
- Raises:
ValueError – If model or backbone are invalid.
- configure_metrics()[source]#
Initialize the performance metrics.
MeanAveragePrecision: Mean average precision (mAP) and mean average recall (mAR). Precision is the number of true positives divided by the number of true positives + false positives. Recall is the number of true positives divived by the number of true positives + false negatives. Uses ‘macro’ averaging. Higher values are better.
Note
‘Micro’ averaging suits overall performance evaluation but may not reflect minority class accuracy.
‘Macro’ averaging gives equal weight to each class, and is useful for balanced performance assessment across imbalanced classes.