결과: 잘 맞춤!
------------------------------------------
전체코드
# 1. 필요한 패키지 가져오는 코드
import tensorflow as tf # 텐써 플로우 2.0
from tensorflow.keras.datasets.mnist import load_data # 텐써플로우에 내장되어있는
# mnist 데이터를 가져온다.
from tensorflow.keras.models import Sequential # 모델을 구성하기 위한 모듈
from tensorflow.keras.layers import Dense, Conv2D, MaxPooling2D, Flatten ,BatchNormalization,Dropout # CNN, 완전 연결계층을 구성하기 위한 모듈
from tensorflow.keras.utils import to_categorical # one encoding 하는 모듈
tf.random.set_seed(777)
# 수집해서 저장한 데이터를 가져오는 코드
train_images='/content/drive/MyDrive/pretty/train_resize'
train_label ='/content/drive/MyDrive/pretty/train_label.csv'
x_train = image_load(train_images)
y_train = label_load(train_label)
#print(x_train.shape) # (400, 32, 32, 3), 4차원
#print(x_train[201].shape) # (32, 32, 3), 3차원
# 2. 정규화를 진행합니다.
x_train = x_train / 255.0
x_train1= x_train[165].reshape(-1, 32, 32, 3) # 3차원을 4차원으로 reshape
a = model.predict(x_train1) # 모델 예측
np.argmax(a) # 확률 벡터에서 가장 큰 원소의 인덱스 번호 추출
# 이미지 출력해보기
import cv2
from google.colab.patches import cv2_imshow
#train_images='/content/drive/MyDrive/cute/train_resize'
path = "/content/drive/MyDrive/pretty/train200/image_all/165.jpg"
image = cv2.imread(path)
print("0: 박해진, 1: 손석구")
print(np.argmax(a))
cv2_imshow(image)