코드 6-3 이미지 데이터셋을 불러온 후 훈련, 검증, 테스트로 분리
cat_directory = r'../chap06/data/dogs-vs-cats/Cat/'
dog_directory = r'../chap06/data/dogs-vs-cats/Dog/'
cat_images_filepaths = sorted([os.path.join(cat_directory, f) for f in
os.listdir(cat_directory)]) ------ ①
dog_images_filepaths = sorted([os.path.join(dog_directory, f) for f in
os.listdir(dog_directory)])
images_filepaths = [*cat_images_filepaths, *dog_images_filepaths] ------ 개와 고양이 이미지들을 합쳐서 images_filepaths에 저장
correct_images_filepaths = [i for i in images_filepaths if cv2.imread(i) is not None] ------ ②
random.seed(42) ------ ③
random.shuffle(correct_images_filepaths)
train_images_filepaths = correct_images_filepaths[:400] ------ 훈련용 400개의 이미지
val_images_filepaths = correct_images_filepaths[400:-10] ------ 검증용 92개의 이미지
test_images_filepaths = correct_images_filepaths[-10:] ------ 테스트용 열 개의 이미지
print(len(train_images_filepaths), len(val_images_filepaths), len(test_images_filepaths))