ChangeDetectionTask#
- class torchgeo.trainers.ChangeDetectionTask(model='unet', backbone='resnet50', weights=None, in_channels=3, task='binary', num_classes=None, num_labels=None, labels=None, num_filters=3, pos_weight=None, loss='bce', class_weights=None, ignore_index=None, lr=0.001, patience=10, freeze_backbone=False, freeze_decoder=False)[source]#
Bases:
ClassificationMixin,BaseTaskChange Detection. Supports binary, multiclass, and multilabel change detection.
Added in version 0.8.
- __init__(model='unet', backbone='resnet50', weights=None, in_channels=3, task='binary', num_classes=None, num_labels=None, labels=None, num_filters=3, pos_weight=None, loss='bce', class_weights=None, ignore_index=None, lr=0.001, patience=10, freeze_backbone=False, freeze_decoder=False)[source]#
Initialize a new ChangeDetectionTask instance.
- Parameters:
model (Literal['unet', 'deeplabv3+', 'fcn', 'upernet', 'segformer', 'dpt', 'fcsiamdiff', 'fcsiamconc', 'changevit', 'btc']) – Name of the model to use.
weights (WeightsEnum | str | bool | None) – Initial model weights. Either a weight enum, the string representation of a weight enum, True for ImageNet weights, False or None for random weights, or the path to a saved model state dict. FCN model does not support pretrained weights.
in_channels (int) – Number of channels per image.
task (Literal['binary', 'multiclass', 'multilabel']) – One of ‘binary’, ‘multiclass’, or ‘multilabel’.
num_classes (int | None) – Number of prediction classes (only for
task='multiclass').num_labels (int | None) – Number of prediction labels (only for
task='multilabel').num_filters (int) – Number of filters. Only applicable when model=’fcn’.
pos_weight (Tensor | None) – A weight of positive examples and used with ‘bce’ loss.
loss (Literal['ce', 'bce', 'jaccard', 'focal', 'dice']) – Name of the loss function, currently supports ‘ce’, ‘bce’, ‘jaccard’, ‘focal’, and ‘dice’ loss.
class_weights (Tensor | Sequence[float] | None) – Optional rescaling weight given to each class and used with ‘ce’ loss.
ignore_index (int | None) – Optional integer class index to ignore in the loss and metrics.
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.
freeze_decoder (bool) – Freeze the decoder network to linear probe the segmentation head.
Added in version 0.9: The labels parameter.