MMDetModel#

class composer.models.MMDetModel(model, metrics=None)[source]#

A wrapper class that adapts mmdetection detectors to composer models.

Parameters
  • model (mmdet.models.detectors.BaseDetector) โ€“ An MMdetection Detector.

  • metrics (list[Metric], optional) โ€“ list of torchmetrics to apply to the output of eval_forward. Default: None.

Warning

This wrapper is designed to work with mmdet datasets.

Example:

from mmdet.models import build_model
from mmcv import ConfigDict
from composer.models import MMDetModel

yolox_s_config = dict(
    type='YOLOX',
    input_size=(640, 640),
    random_size_range=(15, 25),
    random_size_interval=10,
    backbone=dict(type='CSPDarknet', deepen_factor=0.33, widen_factor=0.5),
    neck=dict(type='YOLOXPAFPN', in_channels=[128, 256, 512], out_channels=128, num_csp_blocks=1),
    bbox_head=dict(type='YOLOXHead', num_classes=num_classes, in_channels=128, feat_channels=128),
    train_cfg=dict(assigner=dict(type='SimOTAAssigner', center_radius=2.5)),
    test_cfg=dict(score_thr=0.01, nms=dict(type='nms', iou_threshold=0.65)))
yolox = build_model(ConfigDict(yolox_s_config))
yolox.init_weights()
model = MMDetModel(yolox)
eval_forward(batch, outputs=None)[source]#
Parameters
  • batch (dict) โ€“ a eval batch of the format:

  • img (List[Tensor]) โ€“ list of image torch.Tensors of shape (batch, c, h , w).

  • img_metas (List[Dict]) โ€“ (1, batch_size) list of image_meta dicts.

Returns: model predictions: A batch_size length list of dictionaries containg detection boxes in (x,y, x2, y2) format, class labels, and class probabilities.