Ejemplo n.º 1
0
    def __out_pipe_process(self, result):
        result, inference = result

        if inference.get_meta('expand_dims'):
            num_detections = int(result['num_detections'][0])
            detection_classes = result['detection_classes'][
                0][:num_detections].astype(np.uint8)
            detection_boxes = result['detection_boxes'][0][:num_detections]
            detection_scores = result['detection_scores'][0][:num_detections]
            if 'detection_masks' in result:
                detection_masks = result['detection_masks'][0][:num_detections]
            else:
                detection_masks = None

            results = InferedDetections(inference.get_input(),
                                        num_detections,
                                        detection_boxes,
                                        detection_classes,
                                        detection_scores,
                                        masks=detection_masks,
                                        is_normalized=True,
                                        get_category_fnc=self.get_category,
                                        annotator=self.annotate)

        else:
            results = []
            for i in range(len(result['num_detections'])):
                num_detections = int(result['num_detections'][i])
                detection_classes = result['detection_classes'][
                    i][:num_detections].astype(np.uint8)
                detection_boxes = result['detection_boxes'][i][:num_detections]
                detection_scores = result['detection_scores'][
                    i][:num_detections]
                if 'detection_masks' in result:
                    detection_masks = result['detection_masks'][
                        i][:num_detections]
                else:
                    detection_masks = None

                results.append(
                    InferedDetections(inference.get_input()[i],
                                      num_detections,
                                      detection_boxes,
                                      detection_classes,
                                      detection_scores,
                                      masks=detection_masks,
                                      is_normalized=True,
                                      get_category_fnc=self.get_category,
                                      annotator=self.annotate))

        inference.set_result(results)
        if inference.get_return_pipe():
            return '\0'

        return inference
Ejemplo n.º 2
0
 def __out_pipe_process(self, result):
     (out_boxes, out_classes, out_scores), inference = result
     out_boxes = np.array([[0 if y < 0 else y for y in x]
                           for x in out_boxes])
     result = InferedDetections(inference.get_input(),
                                len(out_boxes),
                                out_boxes,
                                out_classes,
                                out_scores,
                                masks=None,
                                is_normalized=False,
                                get_category_fnc=self.get_category,
                                annotator=self.annotate)
     inference.set_result(result)
     return inference
    def __out_pipe_process(self, result):
        result, inference = result
        num_detections = int(result['num_detections'][0])
        detection_classes = result['detection_classes'][0][:num_detections].astype(np.uint8)
        detection_boxes = result['detection_boxes'][0][:num_detections]
        detection_scores = result['detection_scores'][0][:num_detections]
        if 'detection_masks' in result:
            detection_masks = result['detection_masks'][0][:num_detections]
        else:
            detection_masks = None

        result = InferedDetections(inference.get_input(), num_detections, detection_boxes, detection_classes,
                                   detection_scores,
                                   masks=detection_masks, is_normalized=True, get_category_fnc=self.get_category,
                                   annotator=self.annotate)
        inference.set_result(result)
        return inference