def get_model()

in source/containers/face-comparison/recognizer/predictor.py [0:0]


    def get_model(cls):
        """
        Get the face detector and face representation model for this instance, loading it if it's not already loaded.

        :return:
        """
        # face detector model
        if cls.face_detector is None:
            cls.face_detector = insightface.model_zoo.get_model(
                name=face_detection_model_name,
                root=model_root_dir
            )
            ctx_id = -1 if mx.context.num_gpus() == 0 else 0
            cls.face_detector.prepare(ctx_id=ctx_id)

        # face representation (embedding vector representation) model
        if cls.face_embedding_model is None:
            sym, arg_params, aux_params = mx.model.load_checkpoint(
                prefix=cls.face_representation_model_prefix, epoch=0)
            all_layers = sym.get_internals()
            sym = all_layers['fc1_output']
            cls.face_embedding_model = mx.mod.Module(symbol=sym, context=cls.ctx, label_names=None)
            cls.face_embedding_model.bind(data_shapes=[('data', (1, 3, cls.face_size[0], cls.face_size[1]))])
            cls.face_embedding_model.set_params(arg_params, aux_params)

        return cls.face_detector, cls.face_embedding_model