common
model
icevision.models.torchvision.mask_rcnn.model.model(
num_classes, backbone=None, remove_internal_transforms=True, **mask_rcnn_kwargs
)
MaskRCNN model implemented by torchvision.
Arguments
- num_classes
int
: Number of classes. - backbone
Optional[icevision.models.torchvision.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 theDataset
level, so it's safe to remove those internal transforms. - **mask_rcnn_kwargs: Keyword arguments that internally are going to be passed to
torchvision.models.detection.mask_rcnn.MaskRCNN
.
Return
A Pytorch nn.Module
.
train_dl
icevision.models.torchvision.mask_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, anySequence
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 parametercollate_fn
is already defined internally and cannot be passed here.
Returns
A Pytorch DataLoader
.
valid_dl
icevision.models.torchvision.mask_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, anySequence
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 parametercollate_fn
is already defined internally and cannot be passed here.
Returns
A Pytorch DataLoader
.
infer_dl
icevision.models.torchvision.mask_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, anySequence
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 parametercollate_fn
is already defined internally and cannot be passed here.
Returns
A Pytorch DataLoader
.
build_train_batch
icevision.models.torchvision.mask_rcnn.dataloaders.build_train_batch(records)
Builds a batch in the format required by the model when training.
Arguments
- records
List[Dict[str, Any]]
: ASequence
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)
build_valid_batch
icevision.models.torchvision.mask_rcnn.dataloaders.build_valid_batch(records)
Builds a batch in the format required by the model when validating.
Arguments
- records
List[Dict[str, Any]]
: ASequence
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)
build_infer_batch
icevision.models.torchvision.mask_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]]
: ASequence
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)