Example #1
0
    def __init__(self, name, input_img_channel='rgb'):
        name_model, inference, tpu = name.split('_')
        tpu = (tpu == 'tpu')
        assert inference in ['fp32',
                             'int8'], 'Available inferences are: fp32, int8'
        name_model = name_model + '_' + inference
        if tpu:
            delegates = [load_delegate('libedgetpu.so.1')]
            name_model = name_model + '_tpu'
        else:
            name_model = name_model + '_cpu'
            delegates = []
        path_tflite = helper.get_path('landmark_detection', name_model)

        self.landmark_detection_inference = Interpreter(
            model_path=str(path_tflite),
            experimental_delegates=delegates,
        )
        self.landmark_detection_inference.allocate_tensors()
        self.input_index = self.landmark_detection_inference.get_input_details(
        )[0]['index']
        self.output_index = self.landmark_detection_inference.get_output_details(
        )[0]['index']

        assert input_img_channel in ['bgr',
                                     'rgb'], 'Incorrect input_img_channel'
        self.input_img_channel = input_img_channel
Example #2
0
 def __init__(self, min_neighbors=5, scale=1.2, **kwargs):
     name_model = 'haarcascade'
     type_model = 'face_detection'
     path_xml = helper.get_path(type_model, name_model)
     super(HAARCascade, self).__init__(
         path_xml,
         min_neighbors=min_neighbors,
         scale=scale,
         **kwargs,
     )
Example #3
0
 def __init__(self, input_img_channel='rgb', resize=None, tpu=False):
     if tpu:
         name_model = 'ssd_int8_tpu'
         delegates = [load_delegate('libedgetpu.so.1')]
     else:
         name_model = 'ssd_int8_cpu'
         delegates = []
     path_tflite = helper.get_path('face_detection', name_model)
     self.face_detection_inference = Interpreter(
         model_path=str(path_tflite), experimental_delegates=delegates)
     self.face_detection_inference.allocate_tensors()
     self.index_input = self.face_detection_inference.get_input_details(
     )[0]['index']
     self.index_boxes = self.face_detection_inference.get_output_details(
     )[0]['index']
     self.index_probs = self.face_detection_inference.get_output_details(
     )[2]['index']
     assert input_img_channel in ['bgr',
                                  'rgb'], 'Incorrect input_img_channel'
     self.input_img_channel = input_img_channel