Shortcuts

torchgeo.models

Change Star

class torchgeo.models.ChangeStar(dense_feature_extractor, seg_classifier, changemixin, inference_mode='t1t2')

Bases: torch.nn.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 (torch.nn.Module) – module for dense feature extraction, typically a semantic segmentation model without semantic segmentation head.

  • seg_classifier (torch.nn.Module) – semantic segmentation head, typically a convolutional layer followed by an upsampling layer.

  • changemixin (torchgeo.models.ChangeMixin) – torchgeo.models.ChangeMixin module

  • inference_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'

forward(x)[source]

Forward pass of the model.

Parameters

x (torch.Tensor) – a bitemporal input tensor of shape [B, T, C, H, W]

Returns

a dictionary containing bitemporal semantic segmentation logit and binary change detection logit/probability

Return type

Dict[str, torch.Tensor]

class torchgeo.models.ChangeStarFarSeg(backbone='resnet50', classes=1, backbone_pretrained=True)

Bases: torchgeo.models.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:

__init__(backbone='resnet50', classes=1, backbone_pretrained=True)[source]

Initializes a new ChangeStarFarSeg model.

Parameters
  • backbone (str) – name of ResNet backbone

  • classes (int) – number of output segmentation classes

  • backbone_pretrained (bool) – whether to use pretrained weight for backbone

class torchgeo.models.ChangeMixin(in_channels=256, inner_channels=16, num_convs=4, scale_factor=4.0)

Bases: torch.nn.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:

__init__(in_channels=256, inner_channels=16, num_convs=4, scale_factor=4.0)[source]

Initializes a new ChangeMixin module.

Parameters
  • in_channels (int) – sum of channels of bitemporal feature maps

  • inner_channels (int) – number of channels of inner feature maps

  • num_convs (int) – number of convolution blocks

  • scale_factor (float) – number of upsampling factor

forward(bi_feature)[source]

Forward pass of the model.

Parameters

bi_feature (torch.Tensor) – input bitemporal feature maps of shape [b, t, c, h, w]

Returns

a list of bidirected output predictions

Return type

List[torch.Tensor]

Foreground-aware Relation Network (FarSeg)

class torchgeo.models.FarSeg(backbone='resnet50', classes=16, backbone_pretrained=True)

Bases: torch.nn.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:

__init__(backbone='resnet50', classes=16, backbone_pretrained=True)[source]

Initialize a new FarSeg model.

Parameters
  • backbone (str) – name of ResNet backbone, one of [“resnet18”, “resnet34”, “resnet50”, “resnet101”]

  • classes (int) – number of output segmentation classes

  • backbone_pretrained (bool) – whether to use pretrained weight for backbone

forward(x)[source]

Forward pass of the model.

Parameters

x (torch.Tensor) – input image

Returns

output prediction

Return type

torch.Tensor

Fully-convolutional Network (FCN)

class torchgeo.models.FCN(in_channels, classes, num_filters=64)

Bases: torch.nn.Module

A simple 5 layer FCN with leaky relus and ‘same’ padding.

__init__(in_channels, classes, num_filters=64)[source]

Initializes the 5 layer FCN model.

Parameters
  • in_channels (int) – Number of input channels that the model will expect

  • classes (int) – Number of filters in the final layer

  • num_filters (int) – Number of filters in each convolutional layer

forward(x)[source]

Forward pass of the model.

Fully Convolutional Siamese Networks for Change Detection

class torchgeo.models.FCEF(in_channels=3, t=2, classes=2)

Bases: torch.nn.Module

Fully-convolutional Early Fusion (FC-EF).

‘Fully Convolutional Siamese Networks for Change Detection’, Daudt et al. (2018)

If you use this model in your research, please cite the following paper:

__init__(in_channels=3, t=2, classes=2)[source]

Initializes the FCEF module.

Parameters
  • in_channels (int) – number of channels per input image

  • t (int) – number of input images being compared for change

  • classes (int) – number of output segmentation classes (default=2 for binary segmentation)

forward(x)[source]

Forward pass of the model.

Parameters

x (torch.Tensor) – input image

Returns

prediction

Return type

torch.Tensor

class torchgeo.models.FCSiamConc(in_channels=3, t=2, classes=2)

Bases: torch.nn.Module

Fully-convolutional Siamese Concatenation (FC-Siam-conc).

‘Fully Convolutional Siamese Networks for Change Detection’, Daudt et al. (2018)

If you use this model in your research, please cite the following paper:

__init__(in_channels=3, t=2, classes=2)[source]

Initializes the FCSiamConc module.

Parameters
  • in_channels (int) – number of channels per input image

  • t (int) – number of input images being compared for change

  • classes (int) – number of output segmentation classes (default=2 for binary segmentation)

forward(x)[source]

Forward pass of the model.

Parameters

x (torch.Tensor) – input image

Returns

prediction

Return type

torch.Tensor

class torchgeo.models.FCSiamDiff(in_channels=3, t=2, classes=2)

Bases: torch.nn.Module

Fully-convolutional Siamese Difference (FC-Siam-diff).

‘Fully Convolutional Siamese Networks for Change Detection’, Daudt et al. (2018)

If you use this model in your research, please cite the following paper:

__init__(in_channels=3, t=2, classes=2)[source]

Initializes the FCSiamDiff module.

Parameters
  • in_channels (int) – number of channels per input image

  • t (int) – number of input images being compared for change

  • classes (int) – number of output segmentation classes (default=2 for binary segmentation)

forward(x)[source]

Forward pass of the model.

Parameters

x (torch.Tensor) – input image

Returns

prediction

Return type

torch.Tensor

Random-convolutional feature (RCF) extractor

class torchgeo.models.RCF(in_channels=4, features=16, kernel_size=3, bias=- 1.0, seed=None)

Bases: torch.nn.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.

forward(x)[source]

Forward pass of the RCF model.

Parameters

x (torch.Tensor) – a tensor with shape (B, C, H, W)

Returns

a tensor of size (B, self.num_features)

Return type

torch.Tensor

Residual Network (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
  • sensor (str) – imagery source which determines number of input channels

  • bands (str) – which spectral bands to consider: “all”, “rgb”, etc.

  • pretrained (bool) – if True, returns a model pre-trained on sensor imagery

  • progress (bool) – if True, displays a progress bar of the download to stderr

Returns

A ResNet-50 model

Return type

torchvision.models.resnet.ResNet

Read the Docs v: v0.2.1
Versions
latest
stable
v0.2.1
v0.2.0
v0.1.1
v0.1.0
Downloads
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources