torchgeo.models¶
Change Star¶
- class torchgeo.models.ChangeStar(dense_feature_extractor, seg_classifier, changemixin, inference_mode='t1t2')¶
Bases:
Module
The base class of the network architecture of ChangeStar.
ChangeStar is composed of an any segmentation model and a ChangeMixin module. This model is mainly used for binary/multi-class change detection under bitemporal supervision and single-temporal supervision. It features the property of segmentation architecture reusing, which is helpful to integrate advanced dense prediction (e.g., semantic segmentation) network architecture into change detection.
For multi-class change detection, semantic change prediction can be inferred by a binary change prediction from the ChangeMixin module and two semantic predictions from the Segmentation model.
If you use this model in your research, please cite the following paper:
- __init__(dense_feature_extractor, seg_classifier, changemixin, inference_mode='t1t2')[source]¶
Initializes a new ChangeStar model.
- Parameters
dense_feature_extractor (Module) – module for dense feature extraction, typically a semantic segmentation model without semantic segmentation head.
seg_classifier (Module) – semantic segmentation head, typically a convolutional layer followed by an upsampling layer.
changemixin (ChangeMixin) –
torchgeo.models.ChangeMixin
moduleinference_mode (str) – name of inference mode
't1t2'
|'t2t1'
|'mean'
.'t1t2'
: concatenate bitemporal features in the order of t1->t2;'t2t1'
: concatenate bitemporal features in the order of t2->t1;'mean'
: the weighted mean of the output of't1t2'
and't1t2'
- class torchgeo.models.ChangeStarFarSeg(backbone='resnet50', classes=1, backbone_pretrained=True)¶
Bases:
ChangeStar
The network architecture of ChangeStar(FarSeg).
ChangeStar(FarSeg) is composed of a FarSeg model and a ChangeMixin module.
If you use this model in your research, please cite the following paper:
- class torchgeo.models.ChangeMixin(in_channels=256, inner_channels=16, num_convs=4, scale_factor=4.0)¶
Bases:
Module
This module enables any segmentation model to detect binary change.
The common usage is to attach this module on a segmentation model without the classification head.
If you use this model in your research, please cite the following paper:
FarSeg¶
- class torchgeo.models.FarSeg(backbone='resnet50', classes=16, backbone_pretrained=True)¶
Bases:
Module
Foreground-Aware Relation Network (FarSeg).
This model can be used for binary- or multi-class object segmentation, such as building, road, ship, and airplane segmentation. It can be also extended as a change detection model. It features a foreground-scene relation module to model the relation between scene embedding, object context, and object feature, thus improving the discrimination of object feature representation.
If you use this model in your research, please cite the following paper:
Fully-convolutional Network¶
FC Siamese Networks¶
- class torchgeo.models.FCSiamConc(encoder_name='resnet34', encoder_depth=5, encoder_weights='imagenet', decoder_use_batchnorm=True, decoder_channels=(256, 128, 64, 32, 16), decoder_attention_type=None, in_channels=3, classes=1, activation=None)¶
Bases:
SegmentationModel
Fully-convolutional Siamese Concatenation (FC-Siam-conc).
If you use this model in your research, please cite the following paper:
- __init__(encoder_name='resnet34', encoder_depth=5, encoder_weights='imagenet', decoder_use_batchnorm=True, decoder_channels=(256, 128, 64, 32, 16), decoder_attention_type=None, in_channels=3, classes=1, activation=None)[source]¶
Initialize a new FCSiamConc model.
- Parameters
encoder_name (str) – Name of the classification model that will be used as an encoder (a.k.a backbone) to extract features of different spatial resolution
encoder_depth (int) – A number of stages used in encoder in range [3, 5]. two times smaller in spatial dimensions than previous one (e.g. for depth 0 we will have features. Each stage generate features with shapes [(N, C, H, W),], for depth 1 - [(N, C, H, W), (N, C, H // 2, W // 2)] and so on). Default is 5
encoder_weights (Optional[str]) – One of None (random initialization), “imagenet” (pre-training on ImageNet) and other pretrained weights (see table with available weights for each encoder_name)
decoder_channels (Sequence[int]) – List of integers which specify in_channels parameter for convolutions used in decoder. Length of the list should be the same as encoder_depth
decoder_use_batchnorm (bool) – If True, BatchNorm2d layer between Conv2D and Activation layers is used. If “inplace” InplaceABN will be used, allows to decrease memory consumption. Available options are True, False, “inplace”
decoder_attention_type (Optional[str]) – Attention module used in decoder of the model. Available options are None and scse. SCSE paper https://arxiv.org/abs/1808.08127
in_channels (int) – A number of input channels for the model, default is 3 (RGB images)
classes (int) – A number of classes for output mask (or you can think as a number of channels of output mask)
activation (Optional[Union[str, Callable[[Tensor], Tensor]]]) – An activation function to apply after the final convolution n layer. Available options are “sigmoid”, “softmax”, “logsoftmax”, “tanh”, “identity”, callable and None. Default is None
- class torchgeo.models.FCSiamDiff(*args, **kwargs)¶
Bases:
Unet
Fully-convolutional Siamese Difference (FC-Siam-diff).
If you use this model in your research, please cite the following paper:
- __init__(*args, **kwargs)[source]¶
Initialize a new FCSiamConc model.
- Parameters
encoder_name – Name of the classification model that will be used as an encoder (a.k.a backbone) to extract features of different spatial resolution
encoder_depth – A number of stages used in encoder in range [3, 5]. two times smaller in spatial dimensions than previous one (e.g. for depth 0 we will have features. Each stage generate features with shapes [(N, C, H, W),], for depth 1 - [(N, C, H, W), (N, C, H // 2, W // 2)] and so on). Default is 5
encoder_weights – One of None (random initialization), “imagenet” (pre-training on ImageNet) and other pretrained weights (see table with available weights for each encoder_name)
decoder_channels – List of integers which specify in_channels parameter for convolutions used in decoder. Length of the list should be the same as encoder_depth
decoder_use_batchnorm – If True, BatchNorm2d layer between Conv2D and Activation layers is used. If “inplace” InplaceABN will be used, allows to decrease memory consumption. Available options are True, False, “inplace”
decoder_attention_type – Attention module used in decoder of the model. Available options are None and scse. SCSE paper https://arxiv.org/abs/1808.08127
in_channels – A number of input channels for the model, default is 3 (RGB images)
classes – A number of classes for output mask (or you can think as a number of channels of output mask)
activation – An activation function to apply after the final convolution n layer. Available options are “sigmoid”, “softmax”, “logsoftmax”, “tanh”, “identity”, callable and None. Default is None
RCF Extractor¶
- class torchgeo.models.RCF(in_channels=4, features=16, kernel_size=3, bias=- 1.0, seed=None)¶
Bases:
Module
This model extracts random convolutional features (RCFs) from its input.
RCFs are used in Multi-task Observation using Satellite Imagery & Kitchen Sinks (MOSAIKS) method proposed in https://www.nature.com/articles/s41467-021-24638-z.
Note
This Module is not trainable. It is only used as a feature extractor.
- __init__(in_channels=4, features=16, kernel_size=3, bias=- 1.0, seed=None)[source]¶
Initializes the RCF model.
This is a static model that serves to extract fixed length feature vectors from input patches.
- Parameters
in_channels (int) – number of input channels
features (int) – number of features to compute, must be divisible by 2
kernel_size (int) – size of the kernel used to compute the RCFs
bias (float) – bias of the convolutional layer
seed (Optional[int]) – random seed used to initialize the convolutional layer
New in version 0.2: The seed parameter.
ResNet¶
- torchgeo.models.resnet50(sensor, bands, pretrained=False, progress=True, **kwargs)¶
ResNet-50 model.
If you use this model in your research, please cite the following paper:
- Parameters
- Returns
A ResNet-50 model
- Return type
ResNet