Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from deepface import DeepFace
- import os
- os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0'
- def main():
- # Assuming img1_path and img2_path are defined elsewhere
- # and point to image files
- print('matching...')
- # result = DeepFace.verify(
- # img1_path="bieber.jpeg",
- # img2_path="bieber.jpg",
- # model_name="ArcFace",
- # detector_backend="retinaface"
- # )
- results = DeepFace.find(img_path="menight.jpeg", db_path="imgs/", model_name="ArcFace",
- detector_backend="mtcnn",
- distance_metric="euclidean",
- #enforce_detection=False,
- )
- df = results[0] if isinstance(results, list) else results
- print(len(df))
- if len(df) == 0:
- exit()
- # Get the row with the smallest distance
- best_match = df.iloc[df['distance'].idxmin()]
- # Get the file path (identity)
- identity_path = best_match['identity']
- distance = best_match['distance']
- print(f"Best match: {identity_path} with distance {distance}")
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement