async def embedding_loop(preload): # =================== FR MODEL ==================== mlp, class_names = read_pkl_model('./model-mlp/mlp.pkl') embedding = face_embedding.EmbeddingModel(preload) while True: ip, img = suspicion_face_queue.get() dt = time.strftime('%m-%d %H:%M:%S') predict = mlp.predict_proba([embedding.get_one_feature(img)]) prob = predict.max(1)[0] name = class_names[predict.argmax(1)[0]] result_queue.put((ip, img, dt, prob, name))
async def embedding_loop(preload): # =================== FR MODEL ==================== embedding = face_embedding.EmbeddingModel(preload) while True: result = embedding.arcface_deal(suspicion_face_queue.get()) result_queue.put(result)
import imageGenerator from sklearn import metrics from helper import read_pkl_model, start_up_init, get_dataset, get_image_paths_and_labels import face_embedding import face_detector # =================== ARGS ==================== os.environ["MXNET_CUDNN_AUTOTUNE_DEFAULT"] = "0" args = start_up_init() args.retina_model = './model/M25' args.scales = [0.5] # =================== MODEL CLASS ==================== detector = face_detector.DetectorModel(args) arcface = face_embedding.EmbeddingModel(args) # =================== LOAD DATASET ====================. dir_train = './Temp/train.npy' data_train = './Temp/train_data' dataset_train = get_dataset(data_train) paths_train, labels_train = get_image_paths_and_labels(dataset_train) try: train_emb_array = np.load(dir_train) train_emb_array = imageGenerator.generator() except OSError: if not os.path.exists('./Temp/raw/'): os.makedirs('./Temp/raw/') detector.get_all_boxes_from_path(paths_train, save_img=True) dataset_train = get_dataset(data_train) paths_train, labels_train = get_image_paths_and_labels(dataset_train)