Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
AmirAliHakimiyan authored Jan 27, 2024
1 parent 1b6ff35 commit e94eb64
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Face Verification/face_verification.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from insightface.app import FaceAnalysis
import numpy as np
import argparse
import cv2
ap=argparse.ArgumentParser()
ap.add_argument("--image1",type=str,help="Path of the first image")
ap.add_argument("--image2",type=str,help="Path of the second image")
args=ap.parse_args
image1_p=args.image1
image2_p=args.image2
fa=FaceAnalysis(providers=['CPUEecutionProvider'],name="buffalo_l")
fa.prepare(ctx_id=0,det_size=(640,640))
image1=cv2.imread(image1_p)
image1=cv2.cvtColor(image1,cv2.COLOR_BGR2RGB)
result1=fa.get(image1)


image2=cv2.imread(image2_p)
image2=cv2.cvtColor(image2,cv2.COLOR_BGR2RGB)
result2=fa.get(image2)

distance=np.sprt(np.sum((result1[0]["embedding"]-result2[0]["embedding"])**2))
threshold=25
if distance<threshold:
print("Same person")
else:
print("Diffrent persons")
4 changes: 4 additions & 0 deletions Face Verification/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
insightface
numpy
opencv-python
matplotlib

0 comments on commit e94eb64

Please sign in to comment.