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

when I import face_recognition module Python stop working. #813

Closed
ridarafisyed opened this issue May 3, 2019 · 6 comments
Closed

when I import face_recognition module Python stop working. #813

ridarafisyed opened this issue May 3, 2019 · 6 comments

Comments

@ridarafisyed
Copy link

I dont know what is the isssue. I reinstall my window and only install Visual studio 2019. then miniconda3. In env i install opencv, Cmake and then pip --no-cache-dir install face_recognition everything goes well. but when I import face_recognition python stop working error pop up.

@taily-khucnaykhongquantrong

Me too, when I press enter, it auto exit python console
image

@MrShafqatNadeem
Copy link

Same issue i'm having with my laptop... re installed my windows, and every software that is required. like python, Miniconda, even created new environment but the problem remained same, ... alas

@ridarafisyed
Copy link
Author

Finally, i'have solved my issue by installing newer version of windows 10, it seems some kind of compatibility issue and it fails to compile dlib properly and when we import face_recognition python stop working.

@Raj9417
Copy link

Raj9417 commented May 27, 2019

Im having the same issue in PyCharm IDE, when i use import face_recognition im getting this code:

C:\Users\User.conda\envs\opencv-env\python.exe C:/Users/User/Desktop/CsvTrial/face_recognizer.py

Process finished with exit code -1073741795 (0xC000001D)

================================================
Below is my code that i use to run in windows 10 all updated ,pycharm also updated

import face_recognition
import cv2
import sys
import os

The output video

#fourcc = cv2.VideoWriter_fourcc(0)
#output_movie = cv2.VideoWriter('tbbt_output.avi', fourcc, 30, (1280, 720))
print("Hiu") # this line was to test whether the code coming through this line or not.

Open the input movie file

input_movie = cv2.VideoCapture(0)
length = int(input_movie.get(cv2.CAP_PROP_FRAME_COUNT))

Load some sample pictures and learn how to recognize them.

lmm_image = face_recognition.load_image_file("C:/Users/User/Desktop/CsvTrial/vimalraj.jpg")
lmm_face_encoding = face_recognition.face_encodings(lmm_image)[0]

al_image = face_recognition.load_image_file("C:/Users/User/Desktop/CsvTrial/kirpal.jpg")
al_face_encoding = face_recognition.face_encodings(al_image)[0]

known_faces = [
lmm_face_encoding,
al_face_encoding
]

Initialize some variables

face_locations = []
face_encodings = []
face_names = []
frame_number = 0

current_path = "C:/Users/User/Desktop/CsvTrial"
print(current_path)

counter = 0
counter1 = 0

while True:
# Grab a single frame of video
ret, frame = input_movie.read()
frame_number += 1

# Quit when the input video file ends
if not ret:
    break

# Find all the faces and face encodings in the current frame of video
face_locations = face_recognition.face_locations(frame)
face_encodings = face_recognition.face_encodings(frame, face_locations)

face_names = []
for face_encoding in face_encodings:
    # See if the face is a match for the known face(s)
    match = face_recognition.compare_faces(known_faces, face_encoding, tolerance=0.50)

    # If you had more than 2 faces, you could make this logic a lot prettier
    # but I kept it simple for the demo
    name = None
    if match[0]:
        name = "Vimalraj"
    elif match[1]:
        name = "Kirpal"

    face_names.append(name)

# Label the results
for (top, right, bottom, left), name in zip(face_locations, face_names):
    if not name:
        continue

    # Draw a box around the face
    cv2.rectangle(frame, (left, top), (right, bottom), (0, 0, 255), 2)

    crop_img = frame[top:bottom, left:right]
    if(name == "Vimalraj"):
        cv2.imwrite(current_path + "/face_database/Vimalraj/" + "vimalraj"+str(counter)+".png",crop_img)
        counter = counter + 1
    elif(name == "Kirpal"):
        cv2.imwrite(current_path + "/face_database/Kirpal/" + "kirpal"+str(counter1)+".png",crop_img)
        counter1 = counter1 + 1

    # Draw a label with a name below the face
    cv2.rectangle(frame, (left, bottom - 35), (right, bottom), (0, 0, 255), cv2.FILLED)
    font = cv2.FONT_HERSHEY_DUPLEX
    cv2.putText(frame, name, (left + 6, bottom - 6), font, 1.0, (255, 255, 255), 1)

# Write the resulting image to the output video file
input_movie.write(frame)
print("Writing frame {} / {}".format(frame_number, length))

cv2.imshow('face_recog_crop', frame)
# Hit 'q' on the keyboard to quit!
if cv2.waitKey(10) & 0xFF == ord('q'):
    break

All done!

input_movie.release()
cv2.destroyAllWindows()
create_csv.CreateCsv(current_path + "/face_database/")

=============================================
Please help ...

@Raj9417
Copy link

Raj9417 commented May 29, 2019

Im having the same issue in PyCharm IDE, when i use import face_recognition im getting this code:

C:\Users\User.conda\envs\opencv-env\python.exe C:/Users/User/Desktop/CsvTrial/face_recognizer.py

Process finished with exit code -1073741795 (0xC000001D)

================================================

Below is my code that i use to run in windows 10 all updated ,pycharm also updated
import face_recognition
import cv2
import sys
import os

The output video

#fourcc = cv2.VideoWriter_fourcc(0)
#output_movie = cv2.VideoWriter('tbbt_output.avi', fourcc, 30, (1280, 720))
print("Hiu") # this line was to test whether the code coming through this line or not.

Open the input movie file

input_movie = cv2.VideoCapture(0)
length = int(input_movie.get(cv2.CAP_PROP_FRAME_COUNT))

Load some sample pictures and learn how to recognize them.

lmm_image = face_recognition.load_image_file("C:/Users/User/Desktop/CsvTrial/vimalraj.jpg")
lmm_face_encoding = face_recognition.face_encodings(lmm_image)[0]

al_image = face_recognition.load_image_file("C:/Users/User/Desktop/CsvTrial/kirpal.jpg")
al_face_encoding = face_recognition.face_encodings(al_image)[0]

known_faces = [
lmm_face_encoding,
al_face_encoding
]

Initialize some variables

face_locations = []
face_encodings = []
face_names = []
frame_number = 0

current_path = "C:/Users/User/Desktop/CsvTrial"
print(current_path)

counter = 0
counter1 = 0

while True:

Grab a single frame of video

ret, frame = input_movie.read()
frame_number += 1

# Quit when the input video file ends
if not ret:
    break

# Find all the faces and face encodings in the current frame of video
face_locations = face_recognition.face_locations(frame)
face_encodings = face_recognition.face_encodings(frame, face_locations)

face_names = []
for face_encoding in face_encodings:
    # See if the face is a match for the known face(s)
    match = face_recognition.compare_faces(known_faces, face_encoding, tolerance=0.50)

    # If you had more than 2 faces, you could make this logic a lot prettier
    # but I kept it simple for the demo
    name = None
    if match[0]:
        name = "Vimalraj"
    elif match[1]:
        name = "Kirpal"

    face_names.append(name)

# Label the results
for (top, right, bottom, left), name in zip(face_locations, face_names):
    if not name:
        continue

    # Draw a box around the face
    cv2.rectangle(frame, (left, top), (right, bottom), (0, 0, 255), 2)

    crop_img = frame[top:bottom, left:right]
    if(name == "Vimalraj"):
        cv2.imwrite(current_path + "/face_database/Vimalraj/" + "vimalraj"+str(counter)+".png",crop_img)
        counter = counter + 1
    elif(name == "Kirpal"):
        cv2.imwrite(current_path + "/face_database/Kirpal/" + "kirpal"+str(counter1)+".png",crop_img)
        counter1 = counter1 + 1

    # Draw a label with a name below the face
    cv2.rectangle(frame, (left, bottom - 35), (right, bottom), (0, 0, 255), cv2.FILLED)
    font = cv2.FONT_HERSHEY_DUPLEX
    cv2.putText(frame, name, (left + 6, bottom - 6), font, 1.0, (255, 255, 255), 1)

# Write the resulting image to the output video file
input_movie.write(frame)
print("Writing frame {} / {}".format(frame_number, length))

cv2.imshow('face_recog_crop', frame)
# Hit 'q' on the keyboard to quit!
if cv2.waitKey(10) & 0xFF == ord('q'):
    break

All done!

input_movie.release()
cv2.destroyAllWindows()
create_csv.CreateCsv(current_path + "/face_database/")

=============================================
Please help ...

Solve it by reinstalling all on same version, previously python version was 3.7 and the dlib,face_recognition was for python3.6.

Then i watch a video on this link:
https://www.youtube.com/watch?v=HqjcqpCNiZg

where the way the person install dlib was perfect for windows and i install all libraries such as numpy,argparse,imutils and etc same like in video and solve the error.

@ridarafisyed
Copy link
Author

Issue solved by reinstalling every thing!

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

4 participants