코드 6-24 데이터를 가져와서 훈련, 검증, 테스트 용도로 분리
cat_directory = '../chap06/data/dogs-vs-cats/Cat/'
dog_directory = '../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]
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]
val_images_filepaths = correct_images_filepaths[400:-10]
test_images_filepaths = correct_images_filepaths[-10:]
print(len(train_images_filepaths), len(val_images_filepaths), len(test_images_filepaths))
다음은 훈련, 검증, 테스트에서 사용할 데이터셋의 이미지 수입니다.
400 92 10
우리가 사용하는 노트북(혹은 서버, 코랩)의 성능(CPU/GPU, 메모리)이 좋지 않다고 가정한 채 진행하고 있으므로 훈련 데이터셋을 400개로 제한했습니다.