Python dlib.face_recognition_model_v1() Examples

The following are 1 code examples of dlib.face_recognition_model_v1(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module dlib , or try the search function .
Example #1
Source File: dlib_featurizer.py    From ColumbiaImageSearch with Apache License 2.0 6 votes vote down vote up
def __init__(self, global_conf_in, prefix="DLIBFEAT_"):
    """DLibFeaturizer constructor.

    :param global_conf_in: configuration file or dictionary
    :type global_conf_in: str, dict
    :param prefix: prefix in configuration
    :type prefix: str
    :raise ValueError: if ``pred_path`` or ``rec_path`` is not set in configuration
    """
    super(DLibFeaturizer, self).__init__(global_conf_in, prefix)
    self.set_pp(pp="DLibFeaturizer")
    if self.verbose > 0:
      print("[{}.log] global_conf: {}".format(self.pp, self.global_conf))

    # Get shape predictor
    pred_path = self.get_required_param('pred_path')
    # Test if file exits there
    if not os.path.exists(pred_path):
      # Download file if not
      download_model(www_pred_path, pred_path, pred_bz2_file)
    # Intialize shape predictor
    self.sp = dlib.shape_predictor(str(pred_path))

    # Get recognizer model
    rec_path = self.get_required_param('rec_path')
    # Test if file exits there
    if not os.path.exists(rec_path):
      # Download file if not
      download_model(www_rec_path, rec_path, rec_bz2_file)
    # Initialize recognizer model
    self.facerec = dlib.face_recognition_model_v1(str(rec_path))