def process_ssd_output(
    predicted_bboxes,
    predicted_scores,
    gt_bboxes,
    gt_labels,
    width=300,
    height=300,
    ignore_class=0,
    iou_threshold=0.5,
):
    """Generate bbox and classes from SSD model outputs.

    Args:
        predicted_bboxes (torch.Tensor): predicted bounding boxes,
            expected shapes [batch, num anchors, 4].
        predicted_scores (torch.Tensor): predicted class scores,
            expected shapes [batch, num anchors, num classes + 1].
        gt_bboxes (torch.Tensor): ground truth bounding boxes,
            expected shapes [batch, num anchors, 4].
        gt_labels (torch.Tensor): ground truth bounding box labels,
            expected shape [batch, num anchors].
        width (int): model input image width.
            Default is ``300``.
        height (int): model input image height.
            Default is ``300``.
        ignore_class (int): index of background class, this class should be ignored.
            Default is ``0``.
        iou_threshold (float): IoU threshold to use in NMS.
            Default is ``0.5``.

    Yields:
        predicted sample (np.ndarray) and ground truth sample (np.ndarray)
    """
    batch_size = predicted_bboxes.size(0)

    pred_boxes = predicted_bboxes.detach().cpu().numpy()
    pred_confidence, pred_cls = torch.max(F.softmax(predicted_scores, dim=-1), dim=-1)
    pred_confidence = pred_confidence.detach().cpu().numpy()
    pred_cls = pred_cls.detach().cpu().numpy()

    for i in range(batch_size):
        # build predictions
        sample_bboxes = change_box_order(pred_boxes[i], "xywh2xyxy")
        sample_bboxes = (sample_bboxes * (width, height, width, height)).astype(np.int32)
        sample_bboxes, sample_classes, sample_confs = nms_filter(
            sample_bboxes, pred_cls[i], pred_confidence[i], iou_threshold=iou_threshold
        )
        pred_sample = np.concatenate(
            [sample_bboxes, sample_classes[:, None], sample_confs[:, None]], -1
        )

        # build ground truth
        sample_target_classes = gt_labels[i].detach().cpu().numpy()
        sample_target_bboxes = gt_bboxes[i, :].detach().cpu().numpy()
        # drop empty bboxes
        mask = sample_target_classes != ignore_class
        sample_target_bboxes = sample_target_bboxes[mask, :]
        sample_target_classes = sample_target_classes[mask]
        # convert to required format
        sample_target_bboxes = change_box_order(sample_target_bboxes, "xywh2xyxy")
        sample_target_bboxes = (
            sample_target_bboxes * (width, height, width, height)
        ).astype(np.int32)
        gt_sample = np.zeros((sample_target_classes.shape[0], 7), dtype=np.float32)
        gt_sample[:, :4] = sample_target_bboxes
        gt_sample[:, 4] = sample_target_classes

        yield pred_sample, gt_sample
Generate bbox and classes from SSD model outputs.

    Args:
        predicted_bboxes (torch.Tensor): predicted bounding boxes,
            expected shapes [batch, num anchors, 4].
        predicted_scores (torch.Tensor): predicted class scores,
            expected shapes [batch, num anchors, num classes + 1].
        gt_bboxes (torch.Tensor): ground truth bounding boxes,
            expected shapes [batch, num anchors, 4].
        gt_labels (torch.Tensor): ground truth bounding box labels,
            expected shape [batch, num anchors].
        width (int): model input image width.
            Default is ``300``.
        height (int): model input image height.
            Default is ``300``.
        ignore_class (int): index of background class, this class should be ignored.
            Default is ``0``.
        iou_threshold (float): IoU threshold to use in NMS.
            Default is ``0.5``.

    Yields:
        predicted sample (np.ndarray) and ground truth sample (np.ndarray)
    
examples/detection/callbacks.py