| 47 | |
| 48 | |
| 49 | def test_find_with_array_input(): |
| 50 | img_path = os.path.join("dataset", "img1.jpg") |
| 51 | img1 = cv2.imread(img_path) |
| 52 | dfs = DeepFace.find(img1, db_path="dataset", silent=True) |
| 53 | assert len(dfs) > 0 |
| 54 | for df in dfs: |
| 55 | assert isinstance(df, pd.DataFrame) |
| 56 | |
| 57 | # one is img1.jpg itself |
| 58 | identity_df = df[df["identity"] == img_path] |
| 59 | assert identity_df.shape[0] > 0 |
| 60 | |
| 61 | # validate reproducability |
| 62 | assert identity_df["distance"].values[0] < threshold |
| 63 | |
| 64 | df = df[df["identity"] != img_path] |
| 65 | logger.debug(df.head()) |
| 66 | assert df.shape[0] > 0 |
| 67 | |
| 68 | logger.info("✅ test find for array input done") |
| 69 | |
| 70 | |
| 71 | def test_find_with_extracted_faces(): |