def forward()

in siammot/modelling/track_head/EMM/track_core.py [0:0]


    def forward(self, features, boxes, sr, targets=None, template_features=None):
        """
        forward functions of the tracker
        :param features: raw FPN feature maps from feature backbone
        :param boxes: template bounding boxes
        :param sr: search region bounding boxes
        :param targets:
        :param template_features: features of the template bounding boxes

        the number of track boxes should be the same as that of
        search region and template_features
        """

        # x, y shifting due to feature padding
        shift_x = self.pad_pixels
        shift_y = self.pad_pixels

        if self.training:
            template_features = self.feature_extractor(features, boxes)
            features = self.track_utils.shuffle_feature(features)

        features = self.track_utils.pad_feature(features)

        sr_features = self.feature_extractor(features, boxes, sr)

        response_map = xcorr_depthwise(sr_features, template_features)
        cls_logits, center_logits, reg_logits = self.predictor(response_map)

        if self.training:
            locations = get_locations(sr_features, template_features, sr, shift_xy=(shift_x, shift_y))
            src_bboxes = cat([b.bbox for b in boxes], dim=0)
            gt_bboxes = cat([b.bbox for b in targets], dim=0)
            cls_loss, reg_loss, centerness_loss = self.loss(
                locations, cls_logits, reg_logits, center_logits, src_bboxes, gt_bboxes)

            loss = dict(loss_tracker_class=cls_loss,
                        loss_tracker_motion=reg_loss,
                        loss_tracker_center=centerness_loss)

            return {}, {}, loss
        else:
            cls_logits = F.interpolate(cls_logits, scale_factor=16, mode='bicubic')
            center_logits = F.interpolate(center_logits, scale_factor=16, mode='bicubic')
            reg_logits = F.interpolate(reg_logits, scale_factor=16, mode='bicubic')

            locations = get_locations(sr_features, template_features, sr, shift_xy=(shift_x, shift_y), up_scale=16)

            assert len(boxes) == 1
            bb, bb_conf = decode_response(cls_logits, center_logits, reg_logits, locations, boxes[0],
                                          use_centerness=self.use_centerness, sigma= self.sigma)
            track_result = wrap_results_to_boxlist(bb, bb_conf, boxes, amodal=self.amodal)
            return {}, track_result, {}