| 18 | |
| 19 | |
| 20 | def test_find_with_exact_path(): |
| 21 | img_path = os.path.join("dataset", "img1.jpg") |
| 22 | dfs = DeepFace.find(img_path=img_path, db_path="dataset", silent=True) |
| 23 | assert len(dfs) > 0 |
| 24 | for df in dfs: |
| 25 | assert isinstance(df, pd.DataFrame) |
| 26 | |
| 27 | # one is img1.jpg itself |
| 28 | identity_df = df[df["identity"] == img_path] |
| 29 | assert identity_df.shape[0] > 0 |
| 30 | |
| 31 | # validate reproducability |
| 32 | assert identity_df["distance"].values[0] <= threshold |
| 33 | |
| 34 | df = df[df["identity"] != img_path] |
| 35 | logger.debug(df.head()) |
| 36 | assert df.shape[0] > 0 |
| 37 | |
| 38 | assert "confidence" in df.columns |
| 39 | # confidence is between 0 and 100 |
| 40 | assert df["confidence"].max() <= 100 |
| 41 | assert df["confidence"].min() >= 0 |
| 42 | # also we just show verified ones in results |
| 43 | assert df["confidence"].max() <= 100 |
| 44 | assert df["confidence"].min() >= 51 |
| 45 | |
| 46 | logger.info("✅ test find for exact path done") |
| 47 | |
| 48 | |
| 49 | def test_find_with_array_input(): |