I'm encountering an issue with a Python script that utilizes the face_recognition library. Despite having successfully installed the face_recognition_models package, the script repeatedly prompts me to install it when I attempt to execute the script. Here's the command and output I receive:
the code :
import osimport face_recognitionimport face_recognition_modelsimport cv2image_path = "tes.png"# Check if the image file existsif not os.path.isfile(image_path): print("Image file does not exist:", image_path) exit()# Get a reference to webcam #0 (the default one)video_capture = cv2.VideoCapture(0)# Load your image and learn how to recognize it.image = face_recognition.load_image_file(image_path)face_encoding = face_recognition.face_encodings(image)[0]# Create arrays of known face encodings and their namesknown_face_encodings = [ face_encoding,]known_face_names = ["Walid"]while True: # Grab a single frame of video ret, frame = video_capture.read() # Convert the image from BGR color (which OpenCV uses) to RGB color (which face_recognition uses) rgb_frame = frame[:, :, ::-1] # Find all the faces in the current frame of video face_locations = face_recognition.face_locations(rgb_frame) face_encodings = face_recognition.face_encodings(rgb_frame, face_locations) # Loop through each face in this frame of video for (top, right, bottom, left), face_encoding in zip(face_locations, face_encodings): # See if the face is a match for the known face(s) matches = face_recognition.compare_faces(known_face_encodings, face_encoding) name = "Unknown" if True in matches: first_match_index = matches.index(True) name = known_face_names[first_match_index] # Draw a box around the face cv2.rectangle(frame, (left, top), (right, bottom), (0, 0, 255), 2) # 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) # Display the resulting image cv2.imshow('Video', frame) # Hit 'q' on the keyboard to quit! if cv2.waitKey(1) & 0xFF == ord('q'): break# Release handle to the webcamvideo_capture.release()cv2.destroyAllWindows()
I attempted to execute a Python script utilizing the face_recognition library. Despite successfully installing the face_recognition_models package, the script continuously prompted me to install it when executed. I expected the script to recognize the installed package and execute without errors, but it continued to request installation of face_recognition_models.