ageitgey / face_recognition_models

Trained models for the face_recognition python library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

module 'face_recognition_models' has no attribute 'face_locations'

chaitanyajalluri opened this issue · comments

when i am running the below line of code :
face_recognition_models.face_locations(rgb,model="cnn")
I am getting this error:
module 'face_recognition_models' has no attribute 'face_locations'

face_recognition_models contains same functions of face_recognition but why i am getting this error.

you can change name .py file, maybe this is duplicate name

I have the same error

You are importing the wrong module. Use face_recognition not face_recognition_models.

Hi Adam, thank you for your answer.
If I'm trying to import face_recognition then I recive following error:

'[3]: runfile('C:/Users/sasa/.spyder-py3/temp.py', wdir='C:/Users/sasa/.spyder-py3')
Traceback (most recent call last):

File "", line 1, in
runfile('C:/Users/sasa/.spyder-py3/temp.py', wdir='C:/Users/sasa/.spyder-py3')

File "C:\Programming\anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 705, in runfile
execfile(filename, namespace)

File "C:\Programming\anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)

File "C:/Users/sasa/.spyder-py3/temp.py", line 9, in
import face_recognition

ModuleNotFoundError: No module named 'face_recognition'>'

This is my code:

import cv2
import face_recognition

cv2.namedWindow("preview")
vc = cv2.VideoCapture(0)

face_locations = []

if vc.isOpened():
   rval, frame = vc.read()
else:
   rval = False

while rval:
   rval, frame = vc.read()
   rgb_frame = frame[:, :, ::-1]

   face_locations = face_recognition.face_locations(frame)
   cv2.imshow('preview', frame)

From the import error, it seems like you haven't actually installed face_recognition.

You are importing the wrong module. Use face_recognition not face_recognition_models.

i cant import it i find error and i dont know why help me please

how can i import face_recignition from pycharm

Check whether you have created face_recognition.py file in your code. If yes then change the name of the file. Its interfeering with existing file of face_recognition module.