def process_and_viz_img(pil_img, det_models, face_id_model, reference, crop_size, id_npy, font):
    face_results = process_faces(img=pil_img, det_models=det_models, reference=reference, crop_size=crop_size)
    filtered_face_results = []
    for face_result in face_results:
        face_prob = face_result.bounding_box[4]
        if (face_prob < MIN_FACE_PROB):
            print('Skipping detection with low face probability: {:.2f}'.format(face_prob))
            continue
        filtered_face_results.append(face_result)
    face_results = filtered_face_results
    identity_list = []
    for face_result in face_results:
        features = extract_feature_for_img(img=face_result.warped_face, backbone=face_id_model)
        (identity, min_dist) = check_identity(id_npy=id_npy, query_features=features.numpy())
        identity_list.append((identity, '({:.2f})'.format(min_dist)))
    viz_img = show_results(img=pil_img, bounding_boxes=[fr.bounding_box for fr in face_results], facial_landmarks=[fr.landmark for fr in face_results], names=identity_list, font=font)
    if identity_list:
        names = list(zip(*identity_list))[0]
    else:
        names = []
    return (viz_img, names)
def process_and_viz_img(pil_img, det_models, face_id_model, reference, crop_size, id_npy, font):
    face_results = process_faces(img=pil_img, det_models=det_models, reference=reference, crop_size=crop_size)
    filtered_face_results = []
    for face_result in face_results:
        face_prob = face_result.bounding_box[4]
        if (face_prob < MIN_FACE_PROB):
            print('Skipping detection with low face probability: {:.2f}'.format(face_prob))
            continue
        filtered_face_results.append(face_result)
    face_results = filtered_face_results
    identity_list = []
    for face_result in face_results:
        features = extract_feature_for_img(img=face_result.warped_face, backbone=face_id_model)
        (identity, min_dist) = check_identity(id_npy=id_npy, query_features=features.numpy())
        identity_list.append((identity, '({:.2f})'.format(min_dist)))
    viz_img = show_results(img=pil_img, bounding_boxes=[fr.bounding_box for fr in face_results], facial_landmarks=[fr.landmark for fr in face_results], names=identity_list, font=font)
    if identity_list:
        names = list(zip(*identity_list))[0]
    else:
        names = []
    return (viz_img, names)