def main(args): if sys.version_info < (3, 0): print("Error: Python2 is slow. Use Python3 for max performance.") return cam_index = int(args.webcam) resolutions = [ RESOLUTION_QVGA, RESOLUTION_VGA, RESOLUTION_HD, RESOLUTION_FULLHD ] try: cam_resolution = resolutions[int(args.resolution)] except: cam_resolution = RESOLUTION_QVGA if args.detector: try: detector = FaceDetectorModels(int(args.detector)) print("Parameters: {}".format(detector)) process_facedetection( detector, FacePoseEstimatorModels.DEFAULT, FaceAgeEstimatorModels.DEFAULT, FaceGenderEstimatorModels.DEFAULT, # FaceEmotionEstimatorModels.DEFAULT, cam_resolution, cam_index) except: print("Invalid parameter") return run(cam_index, cam_resolution)
def main(args): if sys.version_info < (3, 0): print("Error: Python2 is slow. Use Python3 for max performance.") return cam_index = int(args.webcam) resolutions = [ RESOLUTION_QVGA, RESOLUTION_VGA, RESOLUTION_HD, RESOLUTION_FULLHD ] try: cam_resolution = resolutions[int(args.resolution)] except: cam_resolution = RESOLUTION_QVGA if args.detector and args.encoder and args.liveness: try: detector = FaceDetectorModels(int(args.detector)) encoder = FaceEncoderModels(int(args.encoder)) liveness = FaceLivenessModels(int(args.liveness)) print("Parameters: {} {} {}".format(detector, encoder, liveness)) process_livenessdetection(detector, encoder, liveness, cam_index, cam_resolution) except: print("Can not indentify your face, please try again!") return run(cam_index, cam_resolution)
def main(args): if sys.version_info < (3, 0): print("Error: Python2 is slow. Use Python3 for max performance.") return cam_index = int(args.webcam) resolutions = [ RESOLUTION_QVGA, RESOLUTION_VGA, RESOLUTION_HD, RESOLUTION_FULLHD ] try: cam_resolution = resolutions[int(args.resolution)] except: cam_resolution = RESOLUTION_QVGA if args.detector and args.encoder and args.speech_synthesizer: try: detector = FaceDetectorModels(int(args.detector)) encoder = FaceEncoderModels(int(args.encoder)) speech_synthesizer = SpeechSynthesizerModels( int(args.speech_synthesizer)) print("Parameters: {} {} {}".format(detector, encoder, speech_synthesizer)) process_facerecognition(detector, encoder, speech_synthesizer, cam_index, cam_resolution) except: print("Invalid parameter") return run(cam_index, cam_resolution)
def main(args): if sys.version_info < (3, 0): print("Error: Python2 is slow. Use Python3 for max performance.") return cam_index = int(args.webcam) resolutions = [ RESOLUTION_QVGA, RESOLUTION_VGA, RESOLUTION_HD, RESOLUTION_FULLHD ] try: cam_resolution = resolutions[int(args.resolution)] except: cam_resolution = RESOLUTION_VGA if args.detector and args.name: try: detector = FaceDetectorModels(int(args.detector)) name = str(args.name) print("Parameters: {}".format(detector)) process_faceenrollment(detector, cam_index, cam_resolution) print("") print("Processing of video recording started...") #video_to_images(detector, "x" + INPUT_DIR_DATASET, name) #video_to_images(detector, INPUT_DIR_DATASET, name, one_image_only=True) video_to_images(detector, INPUT_DIR_DATASET, name) print("Processing of video recording completed!") print("Make sure to train the new datasets before testing!") print("") except: print("Invalid parameter") return run(cam_index, cam_resolution, str(args.name))
def main(args): if args.detector and args.encoder: try: detector = FaceDetectorModels(int(args.detector)) encoder = FaceEncoderModels(int(args.encoder)) classifier = FaceClassifierModels(int(args.classifier)) face_embeddings_path = args.face_embeddings_path print("Parameters: {} {} {} {}".format(detector, encoder, classifier, face_embeddings_path)) train_recognition(detector, encoder, classifier, face_embeddings_path, True) print("\nImage dataset training completed!") # generate audio samples for image datasets using text to speech synthesizer if args.set_speech_synthesizer: from libfaceid.speech_synthesizer import SpeechSynthesizerModels # lazy loading speech_synthesizer = SpeechSynthesizerModels( int(args.speech_synthesizer)) #print( "Parameters: {}".format(speech_synthesizer) ) train_audiosets(speech_synthesizer) print("Audio samples created!") except Exception as ex: print(ex) print("Invalid parameter") return run()
def main(args): if sys.version_info < (3, 0): print("Error: Python2 is slow. Use Python3 for max performance.") return redis_cam = RedisCam(**ConfigRedis.cam2) resolutions = [ RESOLUTION_QVGA, RESOLUTION_VGA, RESOLUTION_HD, RESOLUTION_FULLHD ] try: cam_resolution = resolutions[int(args.resolution)] except: cam_resolution = RESOLUTION_QVGA if args.detector is not None and args.encoder is not None: try: detector = FaceDetectorModels(int(args.detector)) encoder = FaceEncoderModels(int(args.encoder)) embeddings_path = args.embeddings_path image_folder = args.image_folder print( "Parameters: {} {}".format(detector, encoder) ) process_facerecognition(detector, encoder, redis_cam, cam_resolution, embeddings_path, image_folder) except Exception as ex: print( "Invalid parameter" ) print(ex) return
def main(args): if args.detector and args.encoder: try: detector = FaceDetectorModels(int(args.detector)) encoder = FaceEncoderModels(int(args.encoder)) classifier = FaceClassifierModels(int(args.classifier)) print("Parameters: {} {} {}".format(detector, encoder, classifier)) train_recognition(detector, encoder, classifier, True) print("Training completed!") except: print("Invalid parameter") return run()
def main(args): if sys.version_info < (3, 0): print("Error: Python2 is slow. Use Python3 for max performance.") return if args.detector and args.encoder: try: detector = FaceDetectorModels(int(args.detector)) encoder = FaceEncoderModels(int(args.encoder)) print("Parameters: {} {}".format(detector, encoder)) process_facerecognition(detector, encoder, args.image) except: print("Invalid parameter") return run(args.image)
def init_model(int_detect=1, int_encode=3): # Only for debugging while developing try: # Initialize face detection global face_recognizer, face_detector, face_encoder face_detector = FaceDetector(model=FaceDetectorModels(int_detect), path=join(ROOT_DIR, INPUT_DIR_MODEL_DETECTION)) # Initialize face recognizer face_encoder = FaceEncoder(model=FaceEncoderModels(int_encode), path=join(ROOT_DIR, INPUT_DIR_MODEL_ENCODING), path_training=join( ROOT_DIR, INPUT_DIR_MODEL_TRAINING), training=False) face_recognizer = FaceRecognizer(face_embeddings_path=join( ROOT_DIR, EMBEDDINGS_DIR + '/3_face_encodings_83.pickle')) except Exception as ex: face_encoder = None print(ex)
def main(args): if sys.version_info < (3, 0): print("Error: Python2 is slow. Use Python3 for max performance.") return if args.detector and args.encoder: try: detector = FaceDetectorModels(int(args.detector)) encoder = FaceEncoderModels(int(args.encoder)) classifier = FaceEncoderModels(int(args.classifier)) print("Parameters: {} {} {}".format(detector, encoder, classifier)) train_recognition(detector, encoder, classifier, True) fps = process_facerecognition(RESOLUTION_QVGA, None, 0, model_detector=detector, model_recognizer=encoder) print("Result: {}x{} {:.2f} fps".format(RESOLUTION_QVGA[0], RESOLUTION_QVGA[1], fps)) except: print("Invalid parameter") return run()