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="simi.png", db_path="imgs/",
- model_name="Facenet512", # Match verify's default
- detector_backend="opencv", # Match verify' s default
- distance_metric="euclidean", # Match verify' s default
- enforce_detection=False, # Match verify' s default (and find's typical behavior)
- align=True,
- )
- 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()
- #print(DeepFace.verify(img1_path='menight.jpeg', img2_path='imgs/me2.jpeg'))
Advertisement
Add Comment
Please, Sign In to add comment