diff --git a/deepface/commons/functions.py b/deepface/commons/functions.py index 5a26ebb..92cb18e 100644 --- a/deepface/commons/functions.py +++ b/deepface/commons/functions.py @@ -38,9 +38,13 @@ def initialize_input(img1_path, img2_path = None): img_list = img1_path.copy() else: bulkProcess = False - if img2_path != None: + + if ( + (type(img2_path) == str and img2_path != None) #exact image path, base64 image + or (isinstance(img2_path, np.ndarray) and img2_path.any()) #numpy array + ): img_list = [[img1_path, img2_path]] - else: + else: #analyze function passes just img1_path img_list = [img1_path] return img_list, bulkProcess diff --git a/tests/unit_tests.py b/tests/unit_tests.py index 3f1efa2..fcc50fc 100644 --- a/tests/unit_tests.py +++ b/tests/unit_tests.py @@ -104,11 +104,8 @@ print(resp_obj["instance_2"]["age"]," years old ", resp_obj["instance_2"]["domin print(resp_obj["instance_3"]["age"]," years old ", resp_obj["instance_3"]["dominant_emotion"], " ",resp_obj["instance_3"]["gender"]) print(resp_obj["instance_4"]["age"]," years old ", resp_obj["instance_4"]["dominant_emotion"], " ",resp_obj["instance_4"]["gender"]) - print("-----------------------------------------") -#----------------------------------------- - print("Facial analysis test. Passing nothing as an action") img = "dataset/img4.jpg" @@ -277,5 +274,34 @@ df = DeepFace.find("dataset/img1.jpg", db_path = "dataset", model_name = 'Ensemb print(df) -#----------------------------------- print("--------------------------") + +import cv2 + +print("Passing numpy array to analyze function") + +img = cv2.imread("dataset/img1.jpg") +resp_obj = DeepFace.analyze(img) +print(resp_obj) + +print("--------------------------") + +print("Passing numpy array to verify function") + +img1 = cv2.imread("dataset/img1.jpg") +img2 = cv2.imread("dataset/img2.jpg") + +res = DeepFace.verify(img1, img2) +print(res) + +print("--------------------------") + +print("Passing numpy array to find function") + +img1 = cv2.imread("dataset/img1.jpg") + +df = DeepFace.find(img1, db_path = "dataset") + +print(df.head()) + +print("--------------------------") \ No newline at end of file