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

Attribute error #1556

Open
Sidhartha8023 opened this issue Feb 19, 2024 · 1 comment
Open

Attribute error #1556

Sidhartha8023 opened this issue Feb 19, 2024 · 1 comment

Comments

@Sidhartha8023
Copy link

  • face_recognition version:1.4.0
  • face_recognition_models:0.3.0
  • Python version: 3.12.2
  • Operating System: windows 11

Description

I was trying to build a face recognition software for my college project work , but I have issues in face_recognition module it shows error having no atribute . Kindly help me I need to do this for my graduation

What I Did

import cv2
import numpy as np
import face_recognition_models
import face_recognition as fr


video_capture = cv2.VideoCapture(0)
image = fr.load_image_file('boy.jpg')
image_face_encoding = fr.face_encodings (image)[0]
known_face_encodings = [image_face_encoding]
known_face_names = ["sidhartha"]

while True:
     ret, frame = video_capture.read()
     rgb_frame = frame[:, :, ::-1]
     
     fc_locations = fr.face_locations(rgb_frame)
     fc_enodings = fr.face_encodings(rgb_frame, fc_locations)

     for(top, right, bottom, left), face_encoding in zip(fc_locations, face_encodings):
         mathces = fr.compare_faces(known_face_encodings, face_encoding)

         name= "unknown"

         fc_distances = fr.face_distances(known_face_encodings, face_encoding)

         match_index = np.argmin(fc_distances)

         if matches[match_index]:
             name = known_face_names[match_index]

         cv2.rectangle(frame, (left, top), (right, bottom), (0,0,225), 2)

         cv2.rectangle(frame, (left, botttom - 35), (right, bottom), (0,0,255), cv2.FILLED)

         font = cv2.FONT_HERSHEY_SIMPLEX


         cv2.putText(frame, name, (left +6, bottom - 6), font, 1.0, (255, 255, 255), 1)

     cv2.imshow('simplilearn face detection system', frame)

     if cv2.waitKey(1) & 0xff == ord('q'):
        break

video_capture.release()
cv2.destroyAllWindows()
output.
Traceback (most recent call last):
  File "C:/Users/ASUS/sid.py", line 3, in <module>
    import face_recognition
  File "C:\Users/ASUS\face_recognition.py", line 7, in <module>
    image = fr.load_image_file('boy.jpg')
AttributeError: module 'face_recognition_models' has no attribute 'load_image_file'
@cpate4
Copy link

cpate4 commented Mar 3, 2024

For what it's worth, I had similar issues and downgrading to python-3.11 allowed the face_recognition module to work. I haven't had time to look into "why" yet.

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

2 participants