I am not very clear with the data preparation , any way in which i can understand it more efficiently
Not clear with the data preparation part
hey @itzsakshi26gupta ,
Can you let me know what confusion or difficulty are facing in understanding any particular topic/task in data preparation ?
As explaining it fully is done better in video.
Thank You .
Data Preparation
for fx in os.listdir(dataset_path):
if fx.endswith(’.npy’):
#Create a mapping btw class_id and name
names[class_id] = fx[:-4]
print("Loaded "+fx)
data_item = np.load(dataset_path+fx)
face_data.append(data_item)
#Create Labels for the class
target = class_id*np.ones((data_item.shape[0],))
class_id += 1
labels.append(target)
face_dataset = np.concatenate(face_data,axis=0)
face_labels = np.concatenate(labels,axis=0).reshape((-1,1))
print(face_dataset.shape)
print(face_labels.shape)
trainset = np.concatenate((face_dataset,face_labels),axis=1)
print(trainset.shape)
I dont understand the code under #Create Labels for the class .
hey @itzsakshi26gupta ,
assume that you have created 100 images of your face but named the folder containing those images as your name . Ok…
Now , what you want is to train a model to classify an image of face as yours , For this you need to train a model with x values and y values. So for this , what we do is , lets assume currently class_id is 1 for for 100 images of yours you need 100 labels mean 100 1’s okay.
With this code , we create an array of ones with shape to be as ( number of images , ) = (100,).
So we have 100 x values as 100 images and 100 y values as 100 1’s.
With this data you can easily train any model to recognize you and have fun.
I hope this would have helped you understand the logic.
Thank You and Happy Learning .
this really helped me a lot… thank you!
No Problem .
If you doubt is now resolve i would request you to kindly mark it as resolved and also to provide your valuable feedback.
Thank You and Happy Learning .