def stream(db_path = '', model_name ='VGG-Face', distance_metric = 'cosine' , enable_face_analysis = True , source = 0, time_threshold = 5, frame_threshold = 5): """ This function applies real time face recognition and facial attribute analysis Parameters: db_path (string): facial database path. You should store some .jpg files in this folder. model_name (string): VGG-Face, Facenet, OpenFace, DeepFace, DeepID, Dlib or Ensemble distance_metric (string): cosine, euclidean, euclidean_l2 enable_facial_analysis (boolean): Set this to False to just run face recognition source: Set this to 0 for access web cam. Otherwise, pass exact video path. time_threshold (int): how many second analyzed image will be displayed frame_threshold (int): how many frames required to focus on face """ if time_threshold < 1: raise ValueError("time_threshold must be greater than the value 1 but you passed "+str(time_threshold)) if frame_threshold < 1: raise ValueError("frame_threshold must be greater than the value 1 but you passed "+str(frame_threshold)) functions.initialize_detector(detector_backend = 'opencv') realtime.analysis(db_path, model_name, distance_metric, enable_face_analysis , source = source, time_threshold = time_threshold, frame_threshold = frame_threshold)
def stream(db_path='', model_name='VGG-Face', distance_metric='cosine', enable_face_analysis=True, source=0, time_threshold=5, frame_threshold=5): if time_threshold < 1: raise ValueError( "time_threshold must be greater than the value 1 but you passed " + str(time_threshold)) if frame_threshold < 1: raise ValueError( "frame_threshold must be greater than the value 1 but you passed " + str(frame_threshold)) functions.initialize_detector(detector_backend='opencv') realtime.analysis(db_path, model_name, distance_metric, enable_face_analysis, source=source, time_threshold=time_threshold, frame_threshold=frame_threshold)
def stream( db_path="", model_name="VGG-Face", distance_metric="cosine", enable_face_analysis=True, ): realtime.analysis(db_path, model_name, distance_metric, enable_face_analysis)
def stream(db_path='', model_name='VGG-Face', distance_metric='cosine', enable_face_analysis=True): functions.initialize_detector(detector_backend='opencv') realtime.analysis(db_path, model_name, distance_metric, enable_face_analysis)
def stream(db_path='', model_name='Facenet', distance_metric='cosine', enable_face_analysis=False): realtime.analysis(db_path, model_name, distance_metric, enable_face_analysis)
def stream(db_path = '', model_name ='VGG-Face', distance_metric = 'cosine', enable_face_analysis = True): realtime.analysis(db_path, model_name, distance_metric, enable_face_analysis)
import logging import os os.environ["TF_CPP_MIN_LOG_LEVEL"] = "3" # FATAL logging.getLogger("tensorflow").setLevel(logging.FATAL) from deepface import DeepFace from deepface.commons import realtime import youtube_dl import cv2 from cv2 import VideoCapture ###########################################YOUTUBE f_list = glob("nested/*/*") ids = defaultdict(list) for f in f_list: ids[f.split('/')[1]].append(f) dfs = DeepFace.find(img_path=f_list, db_path="nested") models = ["VGG-Face", "Facenet", "OpenFace", "DeepFace", "DeepID"] realtime.analysis(cap=cap, out=out, db_path="friends", model_name=models[1], distance_metric='cosine', enable_face_analysis=False, embd_saved=True)