//  [python]
def detect(self, image_data):
        input_image = image_data.asarray().astype('uint8')
        if self._rgb_to_bgr:
            input_image = cv2.cvtColor(input_image, cv2.COLOR_RGB2BGR)
        detections = inference_detector(self._model, input_image)
        if isinstance(detections, tuple):
            bbox_result, _ = detections
        else:              
            bbox_result, _ = detections, None
        if np.size(bbox_result) > 0:
            bboxes = np.vstack(bbox_result)
        else:
            bboxes = np.array([])

        labels = [
            np.full(bbox.shape[0], i, dtype=np.int32)
            for i, bbox in enumerate(bbox_result)
        ]
    
        if np.size(labels) > 0:
            labels = np.concatenate(labels)
        else:
            labels = []
            return DetectedObjectSet()
        output = DetectedObjectSet()
        input_image = torch.from_numpy(input_image).permute(2,0,1)
        feats = self._model.extract_feat(input_image.float().unsqueeze(0).cuda())
        feat_rois = torch.zeros(bboxes.shape)
        feat_rois[:, 1:] = torch.from_numpy(bboxes)[:, :4]
        bbox_feats = self._model.roi_head.bbox_roi_extractor[2](
        feats, feat_rois.cuda())
        test_data = torch.amax(bbox_feats, (2,3))
        test_data = torch.norm(test_data, dim=1, p=self._norm_degree)
        prob_test = []

        # convert to kwiver format, apply threshold
        for row in test_data:
            sample_ReScore = self.remax.ReScore(row)
            if sample_ReScore.isnan().any():
                raise Exception
            prob_test.append(sample_ReScore.view(-1))
        from PIL import Image, ImageDraw
        img = Image.fromarray(image_data.asarray())
        img1 = ImageDraw.Draw(img)
        prob_test = torch.cat(prob_test,dim=0)
        names = []
        for prob in prob_test:
            if prob not in names:
                names.append(str(prob.item()))
        for bbox, label, novelty_prob in zip(bboxes, labels, prob_test):
            img1.rectangle([(bbox[0], bbox[1]), (bbox[2], bbox[3])])
            class_confidence = float(bbox[-1])
            if class_confidence < self._thresh:
                continue
            bbox_int = bbox.astype('uint16')
            bounding_box = BoundingBoxD(bbox_int[0], bbox_int[1],
                                        bbox_int[2], bbox_int[3])
            class_name = self._labels[label]
            detected_object_type = DetectedObjectType(class_name, class_confidence)
            detected_object = DetectedObject(bounding_box,
                                             np.max(class_confidence),
                                             detected_object_type)
            
            # add in novelty prob attribute to detected object
            detected_object.add_note(":novelty=" + str(novelty_prob.item()))
            output.add(detected_object)
        if True and self._display_detections:

            mmcv.imshow_det_bboxes(
                input_image,
                bboxes,
                labels,
                class_names=self._labels,
                score_thr=self._thresh,
                show=True)
        
        return output