encoder.py
def encode_images(self,args):
        """
        path_to_images: The path to the image directory
        """

        self.known_encoding = []
        self.known_names = []
        
        #Calling the name_ima_reader in the same class
        class_names,images = self.name_img_reader(args.path_to_images)
        
        #zip into tuples
        for name,img in zip(class_names,images):
            #to rgb color
            rgb_img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
            
            #get the face of the image
            face_extract = face_recognition.face_locations(rgb_img,model='hog')
            encoded_img = face_recognition.face_encodings(rgb_img,face_extract)
            # loop over the encodings
            for encoding in encoded_img:
                self.known_encoding.append(encoding)
                self.known_names.append(name)

        self.known_encoded_dict = {'names':self.known_names,'images':self.known_encoding}

        f = open('encoded_images','wb')
        f.write(pickle.dumps(self.known_encoded_dict))
        f.close()
        print('Learning Completed')

        path_to_images: The path to the image directory
        
The path to the image directory
The path to the image directory
def encode_images(self,args):
        self.known_encoding = []
        self.known_names = []
        class_names,images = self.name_img_reader(args.path_to_images)
        for name,img in zip(class_names,images):
            rgb_img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
            face_extract = face_recognition.face_locations(rgb_img,model='hog')
            encoded_img = face_recognition.face_encodings(rgb_img,face_extract)
            for encoding in encoded_img:
                self.known_encoding.append(encoding)
                self.known_names.append(name)
        self.known_encoded_dict = {'names':self.known_names,'images':self.known_encoding}
        f = open('encoded_images','wb')
        f.write(pickle.dumps(self.known_encoded_dict))
        f.close()
        print('Learning Completed')
def encode_images ( self , args ) : self . known_encoding = [ ] self . known_names = [ ] class_names , images = self . name_img_reader ( args . path_to_images ) for name , img in zip ( class_names , images ) : rgb_img = cv2 . cvtColor ( img , cv2 . COLOR_BGR2RGB ) face_extract = face_recognition . face_locations ( rgb_img , model = 'hog' ) encoded_img = face_recognition . face_encodings ( rgb_img , face_extract ) for encoding in encoded_img : self . known_encoding . append ( encoding ) self . known_names . append ( name ) self . known_encoded_dict = { 'names' : self . known_names , 'images' : self . known_encoding } f = open ( 'encoded_images' , 'wb' ) f . write ( pickle . dumps ( self . known_encoded_dict ) ) f . close ( ) print ( 'Learning Completed' )
path_to_images: The path to the image directory
path_to_images : The path to the image directory
"""
        path_to_images: The path to the image directory
        """ #Calling the name_ima_reader in the same class #zip into tuples #to rgb color #get the face of the image # loop over the encodings
self
args