Ejemplo n.º 1
0
        def postprocess(output):
            # extract_predictions
            total_boxes = np.zeros((0, 9), np.float)
            for idx, outputs in enumerate(output):
                scales = input_meta['scales'][idx]

                mapping = outputs[self._output_layers['pnet']
                                  ['probabilities']][0, 1]
                regions = outputs[self._output_layers['pnet']['regions']][0]
                boxes = utils.generate_bounding_box(mapping, regions, scales,
                                                    0.6)
                if len(boxes) != 0:
                    pick = utils.nms(boxes, 0.5)
                    if np.size(pick) > 0:
                        boxes = boxes[pick]
                if len(boxes) != 0:
                    total_boxes = np.concatenate((total_boxes, boxes), axis=0)

            if np.size(total_boxes) == 0:
                return np.zeros((0, 5))

            pick = utils.nms(total_boxes, 0.7)
            total_boxes = total_boxes[pick]

            return utils.bbreg(total_boxes[:, :5],
                               total_boxes[:, 5:],
                               include_bound=False)
Ejemplo n.º 2
0
 def postprocess(output):
     score = output[self._output_layers['onet']['probabilities']][:, 1]
     regions = output[self._output_layers['onet']['regions']]
     bboxes = utils.calibrate_bboxes(prev_stage_output, score, regions)
     pick = utils.nms(bboxes, 0.7, 'min')
     bboxes_to_remove = np.setdiff1d(np.arange(len(bboxes)), pick)
     return np.delete(bboxes, bboxes_to_remove, axis=0)