TypeError at /mark_your_attendance Can't parse 'center'. Sequence item with index 0 has a wrong type

Hello guys! i am working on attendance system using Face Recognition, i have trained the captured images once want to mark the attendance it gives me following error, i have used django at backend.

TypeError at /mark_your_attendance Can't parse 'center'. Sequence item with index 0 has a wrong type

Request Method: GET
Request URL:    http://127.0.0.1:8000/mark_your_attendance
Django Version: 2.2.2
Exception Type: TypeError
Exception Value:    
Can't parse 'center'. Sequence item with index 0 has a wrong type
Exception Location: /home/saifullah/Desktop/attendance/attendance-system/env/lib/python3.8/site-packages/imutils/face_utils/facealigner.py in align, line 68
Python Executable:  /home/saifullah/Desktop/attendance/attendance-system/env/bin/python3
Python Version: 3.8.10
Python Path:    
['/home/saifullah/Desktop/attendance/attendance-system',
 '/usr/lib/python38.zip',
 '/usr/lib/python3.8',
 '/usr/lib/python3.8/lib-dynload',
 '/home/saifullah/Desktop/attendance/attendance-system/env/lib/python3.8/site-packages']

Hereby i am sharing the code can anyone please help how to solve it.

Code

def mark_your_attendance(request):

    detector = dlib.get_frontal_face_detector()

    predictor = dlib.shape_predictor(
        'face_recognition_data/shape_predictor_68_face_landmarks.dat')
    # Add path to the shape predictor ######CHANGE TO RELATIVE PATH LATER
    svc_save_path = "face_recognition_data/svc.sav"

    with open(svc_save_path, 'rb') as f:
        svc = pickle.load(f)
    fa = FaceAligner(predictor, desiredFaceWidth=96)
    encoder = LabelEncoder()
    encoder.classes_ = np.load('face_recognition_data/classes.npy')

    faces_encodings = np.zeros((1, 128))
    no_of_faces = len(svc.predict_proba(faces_encodings)[0])
    count = dict()
    present = dict()
    log_time = dict()
    start = dict()
    for i in range(no_of_faces):
        count[encoder.inverse_transform([i])[0]] = 0
        present[encoder.inverse_transform([i])[0]] = False

    vs = VideoStream(src=0).start()

    sampleNum = 0

    while(True):

        frame = vs.read()

        frame = imutils.resize(frame, width=800)

        gray_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

        faces = detector(gray_frame, 0)

        for face in faces:
            print("INFO : inside for loop")
            (x, y, w, h) = face_utils.rect_to_bb(face)

            face_aligned = fa.align(frame, gray_frame, face)
            cv2.rectangle(frame, (int(x, y)), (int(x+w, y+h)), (0, 255, 0), 1)

            (pred, prob) = predict(face_aligned, svc)

            if(pred != [-1]):

                person_name = encoder.inverse_transform(np.ravel([pred]))[0]
                pred = person_name
                if count[pred] == 0:
                    start[pred] = time.time()
                    count[pred] = count.get(pred, 0) + 1

                if count[pred] == 4 and (time.time()-start[pred]) > 1.2:
                    count[pred] = 0
                else:
                    # if count[pred] == 4 and (time.time()-start) <= 1.5:
                    present[pred] = True
                    log_time[pred] = datetime.datetime.now()
                    count[pred] = count.get(pred, 0) + 1
                    print(pred, present[pred], count[pred])
                cv2.putText(frame, str(person_name) + str(prob), (x+6,
                            y+h-6), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 1)

            else:
                person_name = "unknown"
                cv2.putText(frame, str(person_name), (x+6, y+h-6),
                            cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 1)

            # cv2.putText()
            # Before continuing to the next loop, I want to give it a little pause
            # waitKey of 100 millisecond
            # cv2.waitKey(50)

        # Showing the image in another window
        # Creates a window with window name "Face" and with the image img
        cv2.imshow("Mark Attendance - In - Press q to exit", frame)
        # Before closing it we need to give a wait command, otherwise the open cv wont work
        # @params with the millisecond of delay 1
        # cv2.waitKey(1)
        # To get out of the loop
        key = cv2.waitKey(100) & 0xFF
        if(key == ord("q")):
            break

    # Stoping the videostream
    vs.stop()

    # destroying all the windows
    cv2.destroyAllWindows()
    update_attendance_in_db_in(present)
    return redirect('home')
Back to Top