I am coding an age and gender detection model using Google Colab Notebook.
Originally in the dataset there were around 24000 images and at that time my code was working but taking too much time on training. So I decided to reduce the dataset to 10000 images. After doing that I am getting this error message.
path = "/content/drive/MyDrive/Colab Notebooks/UTKFace/UTKFace"
images = []
age = []
gender = []
for img in os.listdir(path):
print(str(img))
ages = img.split("_")[0]
genders = img.split("_")[1]
img = cv2.imread(str(path) "/" str(img))
img = cv2.cvtColor(img,cv2.COLOR_BGR2RGB)
images.append(np.array(img))
age.append(np.array(ages))
gender.append(np.array(genders))
age = np.array(age,dtype=np.int64)
images = np.array(images) #Forgot to scale image for my training. Please divide by 255 to scale.
gender = np.array(gender,np.uint64)
x_train_age, x_test_age, y_train_age, y_test_age = train_test_split(images, age, random_state=42)
x_train_gender, x_test_gender, y_train_gender, y_test_gender = train_test_split(images, gender, random_state=42)
This is the error message I am getting.
CodePudding user response:
Desktop.ini
for example has no "_"
in his name, you should check if "_"
are present first before you split and index by them