Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to get accuration from the processing? #1508

Open
MR-michaelrio opened this issue May 23, 2023 · 2 comments
Open

how to get accuration from the processing? #1508

MR-michaelrio opened this issue May 23, 2023 · 2 comments

Comments

@MR-michaelrio
Copy link

  • face_recognition version:
  • Python version: 3
  • Operating System: windows

Description

i want to get a accuation from the face recognition processing
but i cant find where the code for get a accuration in your examples

What I Did

@app.post("/face_recognition")
async def recognize_faces(file: UploadFile = File(...)):
# Save the uploaded file temporarily
file_location = f"temp/{file.filename}"
with open(file_location, "wb") as buffer:
buffer.write(await file.read())

# Load the image file and find face locations and encodings
image = face_recognition.load_image_file(file_location)
face_locations = face_recognition.face_locations(image)
face_encodings = face_recognition.face_encodings(image, face_locations)

# Load saved encodings
encodings = []
for filename in os.listdir("encodings"):
    if filename.endswith(".txt"):
        with open(os.path.join("encodings", filename), "r") as f:
            name = os.path.splitext(filename)[0]
            lines = f.readlines()
            encoding = [float(x) for x in lines[0].strip().split()]
            encodings.append((name, encoding))

# Find matches
matches = []
for encoding in face_encodings:
    for name, saved_encoding in encodings:
        match = face_recognition.compare_faces([saved_encoding], encoding)
        if match[0]:
            matches.append(name)
            os.remove(file_location)
            return {"matches": matches,"face": "Recognize"}
        
# Remove the temporary file
os.remove(file_location)
return {"face": "NoRecognize"}
@Devang-C
Copy link

Hi, do you mean that you need the probability at which the face recognition model is recognizing the face? Because there is no such thing as accuracy while recognizing faces, It is the probability at which the model is recognizing the faces. Accuracy will be how many times it recognized faces correctly. Please clarify this, so that I can help furhter.

Thank You

@maika-kanaka
Copy link

if you want to get the number of similiarity between two images, you can using face_distance function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants