Skip to content

common

[source]

model

icevision.models.torchvision.faster_rcnn.model.model(
    num_classes, backbone=None, remove_internal_transforms=True, **faster_rcnn_kwargs
)

FasterRCNN model implemented by torchvision.

Arguments

  • num_classes int: Number of classes.
  • backbone Optional[icevision.models.torchvision.backbones.backbone_config.TorchvisionBackboneConfig]: Backbone model to use. Defaults to a resnet50_fpn model.
  • remove_internal_transforms bool: The torchvision model internally applies transforms like resizing and normalization, but we already do this at the Dataset level, so it's safe to remove those internal transforms.
  • pretrained: Argument passed to fastercnn_resnet50_fpn if backbone is None.
  • By default it is set to True: this is generally used when training a new model (transfer learning). pretrained = False is used during inference (prediction) for cases where the users have their own pretrained weights.
  • **faster_rcnn_kwargs: Keyword arguments that internally are going to be passed to torchvision.models.detection.faster_rcnn.FastRCNN.

Returns

A Pytorch nn.Module.


[source]

train_dl

icevision.models.torchvision.faster_rcnn.dataloaders.train_dl(
    dataset, batch_tfms=None, **dataloader_kwargs
)

A DataLoader with a custom collate_fn that batches items as required for training the model.

Arguments

  • dataset: Possibly a Dataset object, but more generally, any Sequence that returns records.
  • batch_tfms: Transforms to be applied at the batch level.
  • **dataloader_kwargs: Keyword arguments that will be internally passed to a Pytorch DataLoader. The parameter collate_fn is already defined internally and cannot be passed here.

Returns

A Pytorch DataLoader.


[source]

valid_dl

icevision.models.torchvision.faster_rcnn.dataloaders.valid_dl(
    dataset, batch_tfms=None, **dataloader_kwargs
)

A DataLoader with a custom collate_fn that batches items as required for validating the model.

Arguments

  • dataset: Possibly a Dataset object, but more generally, any Sequence that returns records.
  • batch_tfms: Transforms to be applied at the batch level.
  • **dataloader_kwargs: Keyword arguments that will be internally passed to a Pytorch DataLoader. The parameter collate_fn is already defined internally and cannot be passed here.

Returns

A Pytorch DataLoader.


[source]

infer_dl

icevision.models.torchvision.faster_rcnn.dataloaders.infer_dl(
    dataset, batch_tfms=None, **dataloader_kwargs
)

A DataLoader with a custom collate_fn that batches items as required for inferring the model.

Arguments

  • dataset: Possibly a Dataset object, but more generally, any Sequence that returns records.
  • batch_tfms: Transforms to be applied at the batch level.
  • **dataloader_kwargs: Keyword arguments that will be internally passed to a Pytorch DataLoader. The parameter collate_fn is already defined internally and cannot be passed here.

Returns

A Pytorch DataLoader.


[source]

build_train_batch

icevision.models.torchvision.faster_rcnn.dataloaders.build_train_batch(records)

Builds a batch in the format required by the model when training.

Arguments

  • records Sequence[Dict[str, Any]]: A Sequence of records.
  • batch_tfms: Transforms to be applied at the batch level.

Returns

A tuple with two items. The first will be a tuple like (images, targets), in the input format required by the model. The second will be a list of the input records.

Examples

Use the result of this function to feed the model.

batch, records = build_train_batch(records)
outs = model(*batch)


[source]

build_valid_batch

icevision.models.torchvision.faster_rcnn.dataloaders.build_valid_batch(records)

Builds a batch in the format required by the model when validating.

Arguments

  • records List[Dict[str, Any]]: A Sequence of records.
  • batch_tfms: Transforms to be applied at the batch level.

Returns

A tuple with two items. The first will be a tuple like (images, targets), in the input format required by the model. The second will be a list of the input records.

Examples

Use the result of this function to feed the model.

batch, records = build_valid_batch(records)
outs = model(*batch)


[source]

build_infer_batch

icevision.models.torchvision.faster_rcnn.dataloaders.build_infer_batch(records)

Builds a batch in the format required by the model when doing inference.

Arguments

  • records Sequence[Dict[str, Any]]: A Sequence of records.

Returns

A tuple with two items. The first will be a tuple like (images, targets), in the input format required by the model. The second will be a list of the input records.

Examples

Use the result of this function to feed the model.

batch, records = build_infer_batch(records)
outs = model(*batch)