ageitgey / face_recognition

The world's simplest facial recognition api for Python and the command line
MIT License
53.16k stars 13.47k forks source link

Face encoding using a lot of ram GPU #1233

Open khs123 opened 4 years ago

khs123 commented 4 years ago

Description

Hello I am using face_recognition for my task. The general description of my system is a time attendance system that uses facial recognition. For each person, there will be a range of 100-200 photos with their face, the image size is not fixed. I tested on about 20 people with more than 2000 images. I used the Colad GPU to encoding that set of images, but the problem happened was that when I was encoding around 190 images, the Colad's memory was full. Is there any way to optimize this encoding? Thank you

What I Did

ap = argparse.ArgumentParser()
ap.add_argument("-i", "--dataset", required=True, help="path to input directory of faces and images")
ap.add_argument("-e", "--encodings", required=True, help="path to serialize db of facial encodings")
ap.add_argument("-d", "--detection-method", type=str, default="cnn", help="face detection model to use 'hog' or 'cnn")
args = vars(ap.parse_args())
print("[INFO] quantifying faces...")
imagePaths = list(paths.list_images(args['dataset']))
knownEncodings = []
knownNames = []
for i, imagePath in enumerate(imagePaths):
    print("[INFO] processing image {}/{}".format(i + 1, len(imagePaths)))
    name = imagePath.split(os.path.sep)[-2]
    image = cv2.imread(imagePath)
    rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
    boxes = face_recognition.face_locations(rgb, model=args["detection_method"])
    encodings = face_recognition.face_encodings(rgb, boxes)
    for encoding in encodings:
        knownEncodings.append(encoding)
        knownNames.append(name)

print("[INFO] serializing encodings...")
data = {"encoding": knownEncodings, "names": knownNames}
with open(args["encodings"], "wb") as f:
    f.write(pickle.dumps(data))
sabrina-123 commented 3 years ago

hello, I want to contribute to this issue in order to validate the university project, can you explain to me how it goes please