1011
8주차-Day3) 실전 프로젝트-1. 기본적인 기계학습 알고리즘을 활용한 풍경(Scene)_이미지_분류
데이터 전처리
나름 열심히 적었던 코드 부분만 공유...
import random
X_train_X = [image for image in X_train[:500]]
y_train_y = [label for label in y_train[:500]]
X_train_augmented = [image for image in X_train]
y_train_augmented = [label for label in y_train]
# 이미지를 하나씩 확인하며 변형된 이미지 추가
for image, label in zip(X_train_X, y_train_y):
dx = random.uniform(1, 3)
dy = random.uniform(1, 3)
X_train_augmented.append(shift_image(image, dx, dy))
y_train_augmented.append(label)
for image, label in zip(X_train_X, y_train_y):
X_train_augmented.append(horizontal_flip(image))
y_train_augmented.append(label)
X_train_augmented = np.array(X_train_augmented)
y_train_augmented = np.array(y_train_augmented)
# 증진된 데이터들을 섞기(shuffle)
shuffle_idx = np.random.permutation(len(X_train_augmented))
X_train_augmented = X_train_augmented[shuffle_idx]
y_train_augmented = y_train_augmented[shuffle_idx]