Skip to content

Commit

Permalink
some more check for find test
Browse files Browse the repository at this point in the history
  • Loading branch information
serengil committed Jan 8, 2024
1 parent 0eb1515 commit d35833e
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions tests/test_find.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,42 @@


def test_find_with_exact_path():
dfs = DeepFace.find(img_path="dataset/img1.jpg", db_path="dataset", silent=True)
img_path = "dataset/img1.jpg"
dfs = DeepFace.find(img_path=img_path, db_path="dataset", silent=True)
assert len(dfs) > 0
for df in dfs:
assert isinstance(df, pd.DataFrame)

# one is img1.jpg itself
identity_df = df[df["identity"] == img_path]
assert identity_df.shape[0] > 0

# validate reproducability
assert identity_df["VGG-Face_cosine"].values[0] == 0

df = df[df["identity"] != img_path]
logger.debug(df.head())
assert df.shape[0] > 0
logger.info("✅ test find for exact path done")


def test_find_with_array_input():
img1 = cv2.imread("dataset/img1.jpg")
img_path = "dataset/img1.jpg"
img1 = cv2.imread(img_path)
dfs = DeepFace.find(img1, db_path="dataset", silent=True)

assert len(dfs) > 0
for df in dfs:
assert isinstance(df, pd.DataFrame)

# one is img1.jpg itself
identity_df = df[df["identity"] == img_path]
assert identity_df.shape[0] > 0

# validate reproducability
assert identity_df["VGG-Face_cosine"].values[0] == 0


df = df[df["identity"] != img_path]
logger.debug(df.head())
assert df.shape[0] > 0

Expand Down

0 comments on commit d35833e

Please sign in to comment.