장학금 나이따 나이따
'Project' 카테고리의 다른 글
인공지능 경진대회 - Kaggle Wafer defect dection (CNN을 이용한 웨이퍼 결함 탐지) (2) | 2021.11.17 |
---|---|
인공지능 경진대회 - Kaggle Cat&Dog Dataset 이진분류 (0) | 2021.11.17 |
딥러닝용 데이터셋 생성기 만들기 - labelpix YOLO Bounding BOX 라벨링 오류코드 해결 (0) | 2021.06.30 |
장학금 나이따 나이따
인공지능 경진대회 - Kaggle Wafer defect dection (CNN을 이용한 웨이퍼 결함 탐지) (2) | 2021.11.17 |
---|---|
인공지능 경진대회 - Kaggle Cat&Dog Dataset 이진분류 (0) | 2021.11.17 |
딥러닝용 데이터셋 생성기 만들기 - labelpix YOLO Bounding BOX 라벨링 오류코드 해결 (0) | 2021.06.30 |
import os
from os.path import join
import numpy as np
import pandas as pd
import tensorflow as tf
import keras
from keras import layers, Input, models
from keras.utils import to_categorical
from keras.wrappers.scikit_learn import KerasClassifier
from sklearn.model_selection import KFold
from sklearn.model_selection import cross_val_score
from sklearn.model_selection import train_test_split
import matplotlib.pyplot as plt
print(os.listdir("../project(2)"))
import warnings
warnings.filterwarnings("ignore")
Using TensorFlow backend.
['.ipynb_checkpoints', '.vscode', '19 Holyday Inn Hotel.jpg', 'Adain_transfer.ipynb', 'agumented.jpg', 'art', 'Blur.py', 'bobPool0.jpg', 'bobPool1.jpg', 'bobPool2.jpg', 'bobPool3.jpg', 'cat&dog.ipynb', 'cat&dog_set', 'chromedriver.exe', 'CNN_networks', 'Color.py', 'Contrast.py', 'Crawled_Img(Tesla)', 'Crawling_Naver.py', 'Crawling_Pinterst.py', 'Data03.csv', 'Data04.csv', 'dataset', 'datasets', 'decoder.pth', 'eda_nlp', 'Geometry.py', 'ImgCorruptlike.py', 'labelpix', 'LSWMD.pkl', 'me.jpg', 'Neural_style_transfer.ipynb', 'night_star.jpg', 'night_style.jpg', 'Plotly시각화.ipynb', 'project - 복사본.ui', 'project.py', 'project.spec', 'project.ui', 'pul.jpg', 'pyqy5.py', 'requirements.txt', 'ResNet50V2.ipynb', 's.jpg', 'saeggi(2)_test.xml', 'samsung.csv', 'sansu.jpg', 'Save.py', 'seoultech.jpg', 'seoultech2.jpg', 'siva', 'src.txt', 'style.jpg', 'style2.jpg', 'style_exam.jpg', 'stylized_campus-image.png', 'stylized_image0.png', 'stylized_image1.png', 'stylized_image2.png', 'stylized_image3.png', 'stylized_image4.png', 'stylized_suck.png', 'stylized_suck1-image.png', 'stylized_suck3-image.png', 'stylized_suck4-image.png', 't.jpg', 'test.jpg', 'test_aug', 'trash.py', 'Untitled.ipynb', 'vgg_normalised.pth', 'wafer_defect탐지.ipynb', 'weather.csv', 'weather_100.csv', 'weather_10000.csv', 'zic.mp4', '__pycache__', '구글이미지크롤링(미완성).py', '네이버이미지크롤링(데모).py', '데이터셋생성연습.ipynb', '데이터시각화.ipynb', '삼성과목입력.py', '수강신청.py', '암거나하장.py', '웹캠샘플링.py', '컴비수업1.ipynb', '크롤링공부.py']
df=pd.read_pickle("../project(2)/LSWMD.pkl")
df.info()
<class 'pandas.core.frame.DataFrame'> RangeIndex: 811457 entries, 0 to 811456 Data columns (total 6 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 waferMap 811457 non-null object 1 dieSize 811457 non-null float64 2 lotName 811457 non-null object 3 waferIndex 811457 non-null float64 4 trianTestLabel 811457 non-null object 5 failureType 811457 non-null object dtypes: float64(2), object(4) memory usage: 37.1+ MB
df.head()
waferMap | dieSize | lotName | waferIndex | trianTestLabel | failureType | |
---|---|---|---|---|---|---|
0 | [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,... | 1683.0 | lot1 | 1.0 | [[Training]] | [[none]] |
1 | [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,... | 1683.0 | lot1 | 2.0 | [[Training]] | [[none]] |
2 | [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,... | 1683.0 | lot1 | 3.0 | [[Training]] | [[none]] |
3 | [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,... | 1683.0 | lot1 | 4.0 | [[Training]] | [[none]] |
4 | [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,... | 1683.0 | lot1 | 5.0 | [[Training]] | [[none]] |
import matplotlib.pyplot as plt
%matplotlib inline
uni_Index=np.unique(df.waferIndex, return_counts=True)
plt.bar(uni_Index[0],uni_Index[1], color='gold', align='center', alpha=0.5)
plt.title(" wafer Index distribution")
plt.xlabel("index #")
plt.ylabel("frequency")
plt.xlim(0,26)
plt.ylim(30000,34000)
plt.show()
웨이퍼 인덱스별로 데이터의 분포가 고르지 않다.
웨이퍼 인덱스 기능은 분류에 필요하지 않기 때문에 feature engineering이 필요하다
df = df.drop(['waferIndex'], axis = 1)
웨이퍼 맵 열에서는 많은 정보를 얻을 수 없지만 인스턴스별로 다이 크기가 다르다.
웨이퍼 맵 차원 검사를 위한 새로운 변수 'waferMapDim'을 만든다.
def find_dim(x):
dim0=np.size(x,axis=0)
dim1=np.size(x,axis=1)
return dim0,dim1
df['waferMapDim']=df.waferMap.apply(find_dim)
df.sample(10)
waferMap | dieSize | lotName | trianTestLabel | failureType | waferMapDim | |
---|---|---|---|---|---|---|
398224 | [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,... | 1338.0 | lot23837 | [] | [] | (41, 42) |
264380 | [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,... | 2466.0 | lot16372 | [] | [] | (56, 57) |
85292 | [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2,... | 939.0 | lot6110 | [] | [] | (39, 31) |
534024 | [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 1,... | 710.0 | lot33381 | [] | [] | (32, 29) |
777611 | [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,... | 1414.0 | lot46169 | [[Test]] | [[none]] | (42, 44) |
142591 | [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2,... | 710.0 | lot9220 | [] | [] | (32, 29) |
465281 | [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2,... | 712.0 | lot28622 | [] | [] | (32, 29) |
716008 | [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,... | 1485.0 | lot43668 | [[Test]] | [[none]] | (45, 42) |
745085 | [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,... | 822.0 | lot44847 | [[Test]] | [[none]] | (22, 50) |
76132 | [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1,... | 846.0 | lot5634 | [] | [] | (33, 33) |
sub_df = df.loc[df['waferMapDim'] == (26, 26)]
sub_wafer = sub_df['waferMap'].values
sw = np.ones((1, 26, 26))
label = list()
for i in range(len(sub_df)):
# skip null label
if len(sub_df.iloc[i,:]['failureType']) == 0:
continue
sw = np.concatenate((sw, sub_df.iloc[i,:]['waferMap'].reshape(1, 26, 26)))
label.append(sub_df.iloc[i,:]['failureType'][0][0])
x = sw[1:]
y = np.array(label).reshape((-1,1))
# check dimension
print('x shape : {}, y shape : {}'.format(x.shape, y.shape))
x shape : (14366, 26, 26), y shape : (14366, 1)
# plot 1st data
plt.imshow(x[0])
plt.show()
# check faulty case
print('Faulty case : {} '.format(y[0]))
Faulty case : ['none']
x = x.reshape((-1, 26, 26, 1))
faulty_case = np.unique(y)
print('Faulty case list : {}'.format(faulty_case))
Faulty case list : ['Center' 'Donut' 'Edge-Loc' 'Edge-Ring' 'Loc' 'Near-full' 'Random' 'Scratch' 'none']
for f in faulty_case :
print('{} : {}'.format(f, len(y[y==f])))
Center : 90 Donut : 1 Edge-Loc : 296 Edge-Ring : 31 Loc : 297 Near-full : 16 Random : 74 Scratch : 72 none : 13489
웨이퍼 데이터의 각 픽셀에는 웨이퍼가 아닌 0, 1: 정상, 2: 결함을 나타내는 범주형 변수가 있다. 원-핫 인코딩된 단일 범주 데이터를 채널로 사용하여 추가 차원을 확장한다.
# 정량적 변수들을 각 채널에 따라 원핫인코딩
new_x = np.zeros((len(x), 26, 26, 3))
for w in range(len(x)):
for i in range(26):
for j in range(26):
new_x[w, i, j, int(x[w, i, j])] = 1
#check new x dimension
new_x.shape
(14366, 26, 26, 3)
# parameter
epoch=15
batch_size=512
input_shape = (26, 26, 3)
input_tensor = Input(input_shape)
encode = layers.Conv2D(64, (3,3), padding='same', activation='relu')(input_tensor)
latent_vector = layers.MaxPool2D()(encode)
#디코더
decode_layer_1 = layers.Conv2DTranspose(64, (3,3), padding='same', activation='relu')
decode_layer_2 = layers.UpSampling2D()
output_tensor = layers.Conv2DTranspose(3, (3,3), padding='same', activation='sigmoid')
# 디코더 레이어 연결
decode = decode_layer_1(latent_vector)
decode = decode_layer_2(decode)
ae = models.Model(input_tensor, output_tensor(decode))
ae.compile(optimizer='Adam', loss='mse')
ae.summary()
Model: "model" _________________________________________________________________ Layer (type) Output Shape Param # ================================================================= input_1 (InputLayer) [(None, 26, 26, 3)] 0 _________________________________________________________________ conv2d (Conv2D) (None, 26, 26, 64) 1792 _________________________________________________________________ max_pooling2d (MaxPooling2D) (None, 13, 13, 64) 0 _________________________________________________________________ conv2d_transpose (Conv2DTran (None, 13, 13, 64) 36928 _________________________________________________________________ up_sampling2d (UpSampling2D) (None, 26, 26, 64) 0 _________________________________________________________________ conv2d_transpose_1 (Conv2DTr (None, 26, 26, 3) 1731 ================================================================= Total params: 40,451 Trainable params: 40,451 Non-trainable params: 0 _________________________________________________________________
ae.fit(new_x,new_x, batch_size=batch_size,epochs=epoch,verbose=1)
Epoch 1/15 29/29 [==============================] - 5s 24ms/step - loss: 0.1597 Epoch 2/15 29/29 [==============================] - 1s 23ms/step - loss: 0.0858 Epoch 3/15 29/29 [==============================] - 1s 22ms/step - loss: 0.0665 Epoch 4/15 29/29 [==============================] - 1s 23ms/step - loss: 0.0524 Epoch 5/15 29/29 [==============================] - 1s 22ms/step - loss: 0.0415 Epoch 6/15 29/29 [==============================] - 1s 23ms/step - loss: 0.0318 Epoch 7/15 29/29 [==============================] - 1s 23ms/step - loss: 0.0245 Epoch 8/15 29/29 [==============================] - 1s 23ms/step - loss: 0.0200 Epoch 9/15 29/29 [==============================] - 1s 23ms/step - loss: 0.0169 Epoch 10/15 29/29 [==============================] - 1s 22ms/step - loss: 0.0148 Epoch 11/15 29/29 [==============================] - 1s 23ms/step - loss: 0.0131 Epoch 12/15 29/29 [==============================] - 1s 22ms/step - loss: 0.0117 Epoch 13/15 29/29 [==============================] - 1s 23ms/step - loss: 0.0106 Epoch 14/15 29/29 [==============================] - 1s 22ms/step - loss: 0.0096 Epoch 15/15 29/29 [==============================] - 1s 22ms/step - loss: 0.0088
<tensorflow.python.keras.callbacks.History at 0x241e0723b88>
# 오토인코더 모델 층의 일부로 인코더 모델로 만든다
encoder = models.Model(input_tensor, latent_vector)
# 오토인코더 모델 층의 일부로 디코더 모델을 만든다
decoder_input = Input((13, 13, 64))
decode = decode_layer_1(decoder_input)
decode = decode_layer_2(decode)
decoder = models.Model(decoder_input, output_tensor(decode))
# 기존의 결함이 있는 wafer를 엔코딩
encoded_x = encoder.predict(new_x)
# 노이즈 첨가
noised_encoded_x = encoded_x + np.random.normal(loc=0, scale=0.1, size = (len(encoded_x), 13, 13, 64))
# 기존의 결함 있는 wafer data 시각화
plt.imshow(np.argmax(new_x[3], axis=2))
<matplotlib.image.AxesImage at 0x2427ee781c8>
# 노이즈 첨가된 웨이퍼 데이터 시각화
noised_gen_x = np.argmax(decoder.predict(noised_encoded_x), axis=3)
plt.imshow(noised_gen_x[3])
<matplotlib.image.AxesImage at 0x2427a1fc048>
def gen_data(wafer, label):
encoded_x = encoder.predict(wafer)
gen_x = np.zeros((1, 26, 26, 3))
for i in range((2000//len(wafer)) + 1):
noised_encoded_x = encoded_x + np.random.normal(loc=0, scale=0.1, size = (len(encoded_x), 13, 13, 64))
noised_gen_x = decoder.predict(noised_encoded_x)
gen_x = np.concatenate((gen_x, noised_gen_x), axis=0)
gen_y = np.full((len(gen_x), 1), label)
return gen_x[1:], gen_y[1:]
# 모든 faulty 데이터를 증강
for f in faulty_case :
# skip none case
if f == 'none' :
continue
gen_x, gen_y = gen_data(new_x[np.where(y==f)[0]], f)
new_x = np.concatenate((new_x, gen_x), axis=0)
y = np.concatenate((y, gen_y))
print('new_x shape 만든 후 : {}, new_y shape : {}'.format(new_x.shape, y.shape))
new_x shape 만든 후 : (30624, 26, 26, 3), new_y shape : (30707, 1)
for f in faulty_case :
print('{} : {}'.format(f, len(y[y==f])))
Center : 2160 Donut : 2002 Edge-Loc : 2368 Edge-Ring : 2046 Loc : 2376 Near-full : 2032 Random : 2146 Scratch : 2088 none : 13489
# 대체하지 않고 인덱스 선택
none_idx = np.where(y=='none')[0][np.random.choice(len(np.where(y=='none')[0]), size=83, replace=False)]
# 지정한 인덱스 데이터 제거
new_x = np.delete(new_x, none_idx, axis=0)
new_y = np.delete(y, none_idx, axis=0)
print('"none" class 제거 후의 new_x shape : {}, new_y shape : {}'.format(new_x.shape, new_y.shape))
"none" class 제거 후의 new_x shape : (30624, 26, 26, 3), new_y shape : (30624, 9)
for f in faulty_case :
print('{} : {}'.format(f, len(new_y[new_y==f])))
Center : 2160 Donut : 2002 Edge-Loc : 2368 Edge-Ring : 2046 Loc : 2376 Near-full : 2032 Random : 2146 Scratch : 2088 none : 13406
# 문자 라벨을 정량적 라벨로 만든다
for i, l in enumerate(faulty_case):
new_y[new_y==l] = i
# 원-핫인코딩
new_y = to_categorical(new_y)
# train, test 데이터 분리
x_train, x_test, y_train, y_test = train_test_split(new_x, new_y,
test_size=0.33,
random_state=2019)
print('Train x : {}, y : {}'.format(x_train.shape, y_train.shape))
print('Test x: {}, y : {}'.format(x_test.shape, y_test.shape))
Train x : (20518, 26, 26, 3), y : (20518, 9) Test x: (10106, 26, 26, 3), y : (10106, 9)
def create_model():
input_shape = (26, 26, 3)
input_tensor = Input(input_shape)
conv_1 = layers.Conv2D(16, (3,3), activation='relu', padding='same')(input_tensor)
conv_2 = layers.Conv2D(64, (3,3), activation='relu', padding='same')(conv_1)
conv_3 = layers.Conv2D(128, (3,3), activation='relu', padding='same')(conv_2)
flat = layers.Flatten()(conv_3)
dense_1 = layers.Dense(512, activation='relu')(flat)
dense_2 = layers.Dense(128, activation='relu')(dense_1)
output_tensor = layers.Dense(9, activation='softmax')(dense_2)
model = models.Model(input_tensor, output_tensor)
model.compile(optimizer='Adam',
loss='categorical_crossentropy',
metrics=['accuracy'])
return model
# Make keras model to sklearn classifier.
model = KerasClassifier(build_fn=create_model, epochs=10, batch_size=1024, verbose=2)
# 3-Fold Crossvalidation
kfold = KFold(n_splits=3, shuffle=True, random_state=2019)
results = cross_val_score(model, x_train, y_train, cv=kfold)
# Check 3-fold model's mean accuracy
print('Simple CNN Cross validation score : {:.4f}'.format(np.mean(results)))
Epoch 1/10 14/14 - 2s - loss: 2.0356 - accuracy: 0.4588 Epoch 2/10 14/14 - 2s - loss: 0.8517 - accuracy: 0.7171 Epoch 3/10 14/14 - 2s - loss: 0.5793 - accuracy: 0.8134 Epoch 4/10 14/14 - 2s - loss: 0.2641 - accuracy: 0.9093 Epoch 5/10 14/14 - 2s - loss: 0.1137 - accuracy: 0.9674 Epoch 6/10 14/14 - 2s - loss: 0.0507 - accuracy: 0.9871 Epoch 7/10 14/14 - 2s - loss: 0.0290 - accuracy: 0.9938 Epoch 8/10 14/14 - 2s - loss: 0.0173 - accuracy: 0.9960 Epoch 9/10 14/14 - 2s - loss: 0.0102 - accuracy: 0.9982 Epoch 10/10 14/14 - 2s - loss: 0.0084 - accuracy: 0.9987 7/7 - 0s - loss: 0.0346 - accuracy: 0.9904 Epoch 1/10 14/14 - 2s - loss: 1.8552 - accuracy: 0.5075 Epoch 2/10 14/14 - 2s - loss: 0.6009 - accuracy: 0.7980 Epoch 3/10 14/14 - 2s - loss: 0.3816 - accuracy: 0.8763 Epoch 4/10 14/14 - 2s - loss: 0.2012 - accuracy: 0.9353 Epoch 5/10 14/14 - 2s - loss: 0.0930 - accuracy: 0.9740 Epoch 6/10 14/14 - 2s - loss: 0.0489 - accuracy: 0.9865 Epoch 7/10 14/14 - 2s - loss: 0.0268 - accuracy: 0.9936 Epoch 8/10 14/14 - 2s - loss: 0.0156 - accuracy: 0.9971 Epoch 9/10 14/14 - 2s - loss: 0.0104 - accuracy: 0.9981 Epoch 10/10 14/14 - 2s - loss: 0.0068 - accuracy: 0.9989 7/7 - 0s - loss: 0.0302 - accuracy: 0.9923 Epoch 1/10 14/14 - 2s - loss: 2.1718 - accuracy: 0.4654 Epoch 2/10 14/14 - 2s - loss: 0.8183 - accuracy: 0.7235 Epoch 3/10 14/14 - 2s - loss: 0.4146 - accuracy: 0.8510 Epoch 4/10 14/14 - 2s - loss: 0.3472 - accuracy: 0.9009 Epoch 5/10 14/14 - 2s - loss: 0.1561 - accuracy: 0.9558 Epoch 6/10 14/14 - 2s - loss: 0.0796 - accuracy: 0.9794 Epoch 7/10 14/14 - 2s - loss: 0.0451 - accuracy: 0.9894 Epoch 8/10 14/14 - 2s - loss: 0.0333 - accuracy: 0.9921 Epoch 9/10 14/14 - 2s - loss: 0.0209 - accuracy: 0.9955 Epoch 10/10 14/14 - 2s - loss: 0.0165 - accuracy: 0.9965 7/7 - 0s - loss: 0.0314 - accuracy: 0.9901 Simple CNN Cross validation score : 0.9909
history = model.fit(x_train, y_train,validation_data=(x_test, y_test),epochs=epoch,batch_size=batch_size)
Epoch 1/15 41/41 - 71s - loss: 1.3179 - accuracy: 0.6493 - val_loss: 0.5494 - val_accuracy: 0.7907 Epoch 2/15 41/41 - 47s - loss: 0.3257 - accuracy: 0.8911 - val_loss: 0.1759 - val_accuracy: 0.9370 Epoch 3/15 41/41 - 47s - loss: 0.0729 - accuracy: 0.9803 - val_loss: 0.0612 - val_accuracy: 0.9819 Epoch 4/15 41/41 - 50s - loss: 0.0261 - accuracy: 0.9941 - val_loss: 0.0342 - val_accuracy: 0.9892 Epoch 5/15 41/41 - 50s - loss: 0.0155 - accuracy: 0.9968 - val_loss: 0.0294 - val_accuracy: 0.9916 Epoch 6/15 41/41 - 45s - loss: 0.0106 - accuracy: 0.9983 - val_loss: 0.0268 - val_accuracy: 0.9913 Epoch 7/15 41/41 - 45s - loss: 0.0070 - accuracy: 0.9987 - val_loss: 0.0267 - val_accuracy: 0.9917 Epoch 8/15 41/41 - 45s - loss: 0.0052 - accuracy: 0.9989 - val_loss: 0.0358 - val_accuracy: 0.9905 Epoch 9/15 41/41 - 45s - loss: 0.0054 - accuracy: 0.9988 - val_loss: 0.0332 - val_accuracy: 0.9914 Epoch 10/15 41/41 - 45s - loss: 0.0127 - accuracy: 0.9985 - val_loss: 0.0260 - val_accuracy: 0.9930 Epoch 11/15 41/41 - 45s - loss: 0.0049 - accuracy: 0.9990 - val_loss: 0.0268 - val_accuracy: 0.9901 Epoch 12/15 41/41 - 45s - loss: 0.0039 - accuracy: 0.9994 - val_loss: 0.0476 - val_accuracy: 0.9890 Epoch 13/15 41/41 - 45s - loss: 0.4950 - accuracy: 0.8910 - val_loss: 0.1404 - val_accuracy: 0.9473 Epoch 14/15 41/41 - 48s - loss: 0.0441 - accuracy: 0.9881 - val_loss: 0.0305 - val_accuracy: 0.9907 Epoch 15/15 41/41 - 49s - loss: 0.0112 - accuracy: 0.9976 - val_loss: 0.0219 - val_accuracy: 0.9938
score = model.score(x_test, y_test)
#print('Test Loss:', score[0])
#print('Test accuracy:', score[1])
print('Testing Accuracy:',score)
10/10 - 48s - loss: 0.0219 - accuracy: 0.9938 Testing Accuracy: 0.9937660694122314
def plot_model__hist(hist):
plt.figure(figsize=(6,6))
plt.style.use("ggplot")
plt.plot(hist.history['loss'], color='b', label="Training loss")
plt.plot(hist.history['val_loss'], color='r', label="Validation loss")
plt.legend()
plt.show()
plt.figure()
plt.figure(figsize=(6,6))
plt.style.use("ggplot")
plt.plot(hist.history['accuracy'], color='b', label="Training accuracy")
plt.plot(hist.history['val_accuracy'], color='r',label="Validation accuracy")
plt.legend(loc = "lower right")
plt.show()
plot_model__hist(history)
print("wafer defect 탐지 모델의 정확도: {:5.2f}%".format(100*round(score,2)))
<Figure size 432x288 with 0 Axes>
wafer defect 탐지 모델의 정확도: 99.00%
인공지능 경진대회 우수상 (0) | 2021.11.17 |
---|---|
인공지능 경진대회 - Kaggle Cat&Dog Dataset 이진분류 (0) | 2021.11.17 |
딥러닝용 데이터셋 생성기 만들기 - labelpix YOLO Bounding BOX 라벨링 오류코드 해결 (0) | 2021.06.30 |
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from tensorflow.keras.preprocessing.image import ImageDataGenerator,img_to_array,load_img
- 데이터셋 주소: https://www.kaggle.com/shaunthesheep/microsoft-catsvsdogs-dataset
import shutil
import os
# 입력한 경로에 폴더를 생성하는 메소드
def make_dir(target_dir): # 입력값 :처리 대상 폴더 경로
try:
if not os.path.exists(target_dir): # 경로 내에서 설명 이름으로 된 폴더가 없다면
os.makedirs(target_dir) #설명 이름으로 된 폴더 생성
except OSError:
print ('Error: Creating directory. ' + target_dir)
# data를 from_path에서 target_path로 이동시키는 메소드
def transfer(from_path,target_path):
shutil.move(from_path, target_path)
def preprocessing_datasets(classes,from_path, target_path): # 클래스 (*리스트), 대상 폴더, 파일(클래스)이름, 타겟 폴더
# 학습, 검증, test용 경로 생성
datasets_dir = [os.path.join(target_path,"train"), os.path.join(target_path,"val"), os.path.join(target_path,"test")]
for path in datasets_dir:
make_dir(path)
#
for class_name in classes: # 각 클래스명마다
name = os.listdir(from_path) # 데이터셋 지정 경로 받아오기
class_data = [os.path.join(from_path,i) for i in name if "{}".format(class_name) in i] # 데이터셋에서 해당 클래스 네임을 포함한 경로들을 절대경로로 받아옴
print("class({class_name})_num:",len(class_data))
val_num = int(len(class_data)*0.8) # 해당 클래스 데이터 갯수중 80%는 학습용, 20%는 검증용
train_data = class_data[ : val_num] # 맨앞~ 80%를 학습용으로 지정
print("trian_num:",len(train_data))
val_data = class_data[val_num : ] # 80% ~ 맨 뒤 순서까지 검증용 지정
print("val_num:",len(val_data))
train_data_dir = os.path.join(datasets_dir[0], class_name)
make_dir(train_data_dir) # train forder에 해당 클래스명 폴더 생성 // keras preprocessing 으로 데이터셋 정형화 시킬 거임
val_data_dir = os.path.join(datasets_dir[1], class_name)
make_dir(val_data_dir) # val forder에 해당 클래스명 폴더 생성
for train in train_data: # 옮기기
if len(os.listdir(train_data_dir))< len(train_data):
transfer(train, train_data_dir)
for val in val_data:
if len(os.listdir(val_data_dir))<len(val_data):
transfer(val, val_data_dir)
# 다 옮겨졌으면 validation set에서 test dataset 분할
val_list = os.listdir(val_data_dir) # val폴더 내 class명 가진 폴더 안에 있는거 다 가져오기
test_list = [os.path.join(val_data_dir,i) for i in val_list if "{}".format(class_name) in i] #절대경로는 val_data_dir/해당파일
test_num = int(len(test_list)*0.2) # 그 개수중 20%를 테스트용으로 쓸 것이다
print("test_num:",test_num)
test_data = test_list[ : test_num] # 0~20%까지 지정
test_data_dir = os.path.join(datasets_dir[2],class_name) # 테스트셋 폴더 경로 지정 및 생성
make_dir(test_data_dir)
for test in test_data:
if len(os.listdir(test_data_dir)) < test_num: # 테스트셋으로 분리를 하고 났으면 파일 개수가 test_num과 같아지므로 중복분리 방지
transfer(test, test_data_dir)
# 학습 된 모델의 학습 과정 시각화
def plot_model__hist(hist):
plt.figure(figsize=(6,6))
plt.style.use("ggplot")
plt.plot(hist.history['loss'], color='b', label="Training loss")
plt.plot(hist.history['val_loss'], color='r', label="Validation loss")
plt.legend()
plt.show()
plt.figure()
plt.figure(figsize=(6,6))
plt.style.use("ggplot")
plt.plot(hist.history['accuracy'], color='b', label="Training accuracy")
plt.plot(hist.history['val_accuracy'], color='r',label="Validation accuracy")
plt.legend(loc = "lower right")
plt.show()
from_path = r"C:\Users\cvLab\Desktop\from_dataset" #데이터셋 받아져있는 경로
# from_path = r"C:\Users\cvLab\Downloads\archive(1)\train\train" #데이터셋 받아져있는 경로
target_path = r"C:\Users\cvLab\Desktop\dataset" # 데이터셋을 생성할 경로
# target_path = r"D:\Project(2)\cat&dog_set" # 데이터셋을 생성할 경로
classes = ['cat', 'dog']
# preprocessing_datasets(classes,from_path,target_path)
#데이터셋 리턴하는 메소드
def get_dataset(dataset_path=r"D:\Project(2)\cat&dog_set",size=128, aug=False, crawl=False,batch_size=32,kfold=False): #이미지 어그먼테이션, 크롤링된 데이터셋도 포함할지 선택
if aug :
train_datagen = ImageDataGenerator(
rescale=1./255,
rotation_range = 30,
shear_range = 0.2,
zoom_range = 0.2,
vertical_flip = True)
else:
train_datagen = ImageDataGenerator(rescale=1./255)
val_datagen = ImageDataGenerator(rescale=1/255)
test_datagen = ImageDataGenerator(rescale=1/255)
if crawl:
train_path = os.path.join(dataset_path,"additional_train")
if kfold:
train_path = os.path.join(dataset_path,"k-ford_train")
else:
train_path = os.path.join(dataset_path,"train")
train_set = train_datagen.flow_from_directory(directory=train_path,target_size=(size,size),batch_size=batch_size,color_mode="rgb",class_mode='binary')
val_path = os.path.join(dataset_path,"val")
val_set = val_datagen.flow_from_directory(directory=val_path,target_size=(size,size),batch_size=int(batch_size*0.8),color_mode="rgb",class_mode='binary')
test_path = os.path.join(dataset_path,"test")
test_set = test_datagen.flow_from_directory(directory=test_path,target_size=(size,size),batch_size=10,color_mode="rgb",class_mode='binary')
return train_set, val_set, test_set
train_set, val_set, test_set = get_dataset(size=128)
Found 20000 images belonging to 2 classes. Found 4000 images belonging to 2 classes. Found 1000 images belonging to 2 classes.
from tensorflow.keras import Model
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Conv2D,Dense,MaxPooling2D,Flatten,Dropout
model = Sequential([
Conv2D(filters = 64, kernel_size = (5,5), activation = "relu", input_shape = (128,128,3)),
MaxPooling2D(pool_size = (2,2)),
Conv2D(filters = 32, kernel_size = (5,5), activation = "relu"),
MaxPooling2D(pool_size = (2,2)),
Dropout(0.25),
Conv2D(filters = 16, kernel_size = (5,5), activation = "relu"),
MaxPooling2D(pool_size = (2,2)),
Dropout(0.25),
Flatten(),
Dense(units = 256, activation = "relu"),
Dropout(0.5),
Dense(units = 1, activation = "sigmoid")
])
# rmsprop 기법으로 최적화, logistic regression을 위해 binary CrossEntropy loss를 적용 froma
from tensorflow.keras.optimizers import RMSprop
opt = RMSprop()
model.compile(optimizer=opt,loss='binary_crossentropy',metrics=['accuracy'])
hist = model.fit(train_set, validation_data = val_set, epochs = 10)
Epoch 1/10 625/625 [==============================] - 138s 220ms/step - loss: 0.6942 - accuracy: 0.5321 - val_loss: 0.6687 - val_accuracy: 0.5840 Epoch 2/10 625/625 [==============================] - 32s 51ms/step - loss: 0.6693 - accuracy: 0.5929 - val_loss: 0.6449 - val_accuracy: 0.6350 Epoch 3/10 625/625 [==============================] - 32s 51ms/step - loss: 0.6232 - accuracy: 0.6622 - val_loss: 0.5713 - val_accuracy: 0.7105 Epoch 4/10 625/625 [==============================] - 32s 51ms/step - loss: 0.5853 - accuracy: 0.6985 - val_loss: 0.5488 - val_accuracy: 0.7265 Epoch 5/10 625/625 [==============================] - 32s 51ms/step - loss: 0.5455 - accuracy: 0.7311 - val_loss: 0.5487 - val_accuracy: 0.7418 Epoch 6/10 625/625 [==============================] - 32s 50ms/step - loss: 0.5101 - accuracy: 0.7532 - val_loss: 0.4859 - val_accuracy: 0.7623 Epoch 7/10 625/625 [==============================] - 32s 50ms/step - loss: 0.4745 - accuracy: 0.7783 - val_loss: 0.4606 - val_accuracy: 0.7918 Epoch 8/10 625/625 [==============================] - 32s 50ms/step - loss: 0.4517 - accuracy: 0.7929 - val_loss: 0.4182 - val_accuracy: 0.8045 Epoch 9/10 625/625 [==============================] - 32s 50ms/step - loss: 0.4289 - accuracy: 0.8081 - val_loss: 0.4358 - val_accuracy: 0.7993 Epoch 10/10 625/625 [==============================] - 32s 51ms/step - loss: 0.4096 - accuracy: 0.8196 - val_loss: 0.3833 - val_accuracy: 0.8355
plot_model__hist(hist)
loss,acc = model.evaluate(test_set, verbose=2)
print("10 epochs 학습 후 모델의 정확도: {:5.2f}%".format(100*acc))
print("10 epochs 학습 후 모델의 Loss: {}".format(loss))
<Figure size 432x288 with 0 Axes>
100/100 - 1s - loss: 0.3695 - accuracy: 0.8510 10 epochs 학습 후 모델의 정확도: 85.10% 10 epochs 학습 후 모델의 Loss: 0.36947640776634216
from tensorflow import keras
from tensorflow.keras import Model
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Conv2D,Dense,MaxPooling2D,Flatten,Dropout
# from tensorflow.python.keras.applications.resnet import ResNet50
from tensorflow.python.keras.applications.resnet_v2 import ResNet50V2
from tensorflow.keras.callbacks import EarlyStopping , ReduceLROnPlateau
from tensorflow.keras.layers import GlobalAveragePooling2D
import tensorflow as tf
def get_ResNet50V2(size=128,trainable=False):
base_model = ResNet50V2(input_shape=(size,size,3), include_top=False, weights='imagenet') # 백본 설정
base_model.trainable = trainable # 백본 학습 불가능하도록 freezing
global_average_layer = GlobalAveragePooling2D() # 전체 채널을 평균내어 이동하며 학습
ResNet50V2model = tf.keras.Sequential([ #back born + global avg Pooling2D 층 + FC 설정
base_model,
global_average_layer,
Flatten()
])
return ResNet50V2model
def get_callbacks(checkpoint_path, patience = 5):
earlystop = EarlyStopping(
monitor='val_accuracy', min_delta=0.0001,
patience=patience)
cp_callback = tf.keras.callbacks.ModelCheckpoint(filepath=checkpoint_path,
save_weights_only=True,
verbose=1)
callbacks = [earlystop, cp_callback]
return callbacks
# adam으로 해보기
ResNet50V2_model_1 = Sequential([
get_ResNet50V2(size=128),
Dense(256, activation='relu'),
Dropout(0.5),
Dense(128, activation='relu'),
Dropout(0.25),
Dense(1,activation='sigmoid')
])
checkpoint_path_1 = r"D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1/cp-{epoch:04d}.ckpt"
callbacks = get_callbacks(checkpoint_path_1)
from tensorflow.keras.optimizers import Adam
opt = Adam(learning_rate=0.001)
ResNet50V2_model_1.compile(optimizer=opt, loss='binary_crossentropy',metrics=['accuracy'])
ResNet50V2_model_hist_1 = ResNet50V2_model_1.fit(train_set,
validation_data=val_set,
epochs=100,
callbacks = [callbacks])
Epoch 1/100 625/625 [==============================] - 138s 201ms/step - loss: 0.2764 - accuracy: 0.8995 - val_loss: 0.1285 - val_accuracy: 0.9490 Epoch 00001: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0001.ckpt Epoch 2/100 625/625 [==============================] - 34s 55ms/step - loss: 0.1411 - accuracy: 0.9448 - val_loss: 0.1271 - val_accuracy: 0.9488 Epoch 00002: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0002.ckpt Epoch 3/100 625/625 [==============================] - 35s 56ms/step - loss: 0.1258 - accuracy: 0.9491 - val_loss: 0.1181 - val_accuracy: 0.9510 Epoch 00003: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0003.ckpt Epoch 4/100 625/625 [==============================] - 35s 56ms/step - loss: 0.1172 - accuracy: 0.9561 - val_loss: 0.1191 - val_accuracy: 0.9470 Epoch 00004: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0004.ckpt Epoch 5/100 625/625 [==============================] - 36s 57ms/step - loss: 0.1079 - accuracy: 0.9586 - val_loss: 0.1142 - val_accuracy: 0.9532 Epoch 00005: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0005.ckpt Epoch 6/100 625/625 [==============================] - 35s 56ms/step - loss: 0.0947 - accuracy: 0.9622 - val_loss: 0.1146 - val_accuracy: 0.9563 Epoch 00006: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0006.ckpt Epoch 7/100 625/625 [==============================] - 35s 56ms/step - loss: 0.0895 - accuracy: 0.9661 - val_loss: 0.1175 - val_accuracy: 0.9548 Epoch 00007: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0007.ckpt Epoch 8/100 625/625 [==============================] - 35s 55ms/step - loss: 0.0905 - accuracy: 0.9651 - val_loss: 0.1201 - val_accuracy: 0.9545 Epoch 00008: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0008.ckpt Epoch 9/100 625/625 [==============================] - 37s 59ms/step - loss: 0.0761 - accuracy: 0.9711 - val_loss: 0.1183 - val_accuracy: 0.9557 Epoch 00009: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0009.ckpt
plot_model__hist(ResNet50V2_model_hist_1)
loss_1,acc_1 = ResNet50V2_model_1.evaluate(test_set, verbose=2)
print("ResNet50V2_model_1 백본 프리징 후 모델의 정확도: {:5.2f}%".format(100*acc_1))
print("ResNet50V2_model_1 백본 프리징 후 모델의 Loss: {}".format(loss_1))
<Figure size 432x288 with 0 Axes>
100/100 - 6s - loss: 0.1386 - accuracy: 0.9510 ResNet50V2_model_1 백본 프리징 후 모델의 정확도: 95.10% ResNet50V2_model_1 백본 프리징 후 모델의 Loss: 0.138584166765213
# SGD로 해보기
ResNet50V2_model_1 = keras.Sequential([
get_ResNet50V2(size=128),
Dense(256, activation='relu'),
Dropout(0.5),
Dense(128, activation='relu'),
Dropout(0.25),
Dense(1,activation='sigmoid')
])
checkpoint_path_1 = r"D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1/cp-{epoch:04d}.ckpt"
callbacks = get_callbacks(checkpoint_path_1)
from tensorflow.keras.optimizers import Adam, SGD
opt = SGD(lr=0.01, decay=1e-6, momentum=0.001,nesterov=True)
ResNet50V2_model_1.compile(optimizer=opt, loss='binary_crossentropy',metrics=['accuracy'])
ResNet50V2_model_hist_1 = ResNet50V2_model_1.fit(train_set,
validation_data=val_set,
epochs=100,
callbacks = [callbacks])
plot_model__hist(ResNet50V2_model_hist_1)
loss_1,acc_1 = ResNet50V2_model_1.evaluate(test_set, verbose=2)
print("ResNet50V2_model_1 백본 프리징 후 모델의 정확도: {:5.2f}%".format(100*acc_1))
print("ResNet50V2_model_1 백본 프리징 후 모델의 Loss: {}".format(loss_1))
<Figure size 432x288 with 0 Axes>
100/100 - 2s - loss: 0.1326 - accuracy: 0.9450 ResNet50V2_model_1 백본 프리징 후 모델의 정확도: 94.50% ResNet50V2_model_1 백본 프리징 후 모델의 Loss: 0.1326497346162796
# Adadelta로 해보기
ResNet50V2_model_1 = keras.Sequential([
get_ResNet50V2(size=128),
Dense(256, activation='relu'),
Dropout(0.5),
Dense(128, activation='relu'),
Dropout(0.25),
Dense(1,activation='sigmoid')
])
checkpoint_path_1 = r"D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1/cp-{epoch:04d}.ckpt"
callbacks = get_callbacks(checkpoint_path_1)
from tensorflow.keras.optimizers import Adam, SGD, Adadelta
opt = Adadelta(rho=0.95)
ResNet50V2_model_1.compile(optimizer=opt, loss='binary_crossentropy',metrics=['accuracy'])
ResNet50V2_model_hist_1 = ResNet50V2_model_1.fit(train_set,
validation_data=val_set,
epochs=100,
callbacks = [callbacks])
Epoch 1/100 625/625 [==============================] - 38s 57ms/step - loss: 1.3201 - accuracy: 0.5187 - val_loss: 0.5449 - val_accuracy: 0.7308 Epoch 00001: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0001.ckpt Epoch 2/100 625/625 [==============================] - 34s 54ms/step - loss: 0.9460 - accuracy: 0.6148 - val_loss: 0.4102 - val_accuracy: 0.8152 Epoch 00002: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0002.ckpt Epoch 3/100 625/625 [==============================] - 34s 54ms/step - loss: 0.7657 - accuracy: 0.6805 - val_loss: 0.3356 - val_accuracy: 0.8530 Epoch 00003: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0003.ckpt Epoch 4/100 625/625 [==============================] - 34s 54ms/step - loss: 0.6358 - accuracy: 0.7278 - val_loss: 0.2884 - val_accuracy: 0.8758 Epoch 00004: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0004.ckpt Epoch 5/100 625/625 [==============================] - 33s 52ms/step - loss: 0.5586 - accuracy: 0.7632 - val_loss: 0.2576 - val_accuracy: 0.8895 Epoch 00005: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0005.ckpt Epoch 6/100 625/625 [==============================] - 33s 53ms/step - loss: 0.5035 - accuracy: 0.7899 - val_loss: 0.2361 - val_accuracy: 0.9010 Epoch 00006: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0006.ckpt Epoch 7/100 625/625 [==============================] - 33s 53ms/step - loss: 0.4554 - accuracy: 0.8061 - val_loss: 0.2208 - val_accuracy: 0.9060 Epoch 00007: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0007.ckpt Epoch 8/100 625/625 [==============================] - 33s 52ms/step - loss: 0.4379 - accuracy: 0.8194 - val_loss: 0.2095 - val_accuracy: 0.9110 Epoch 00008: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0008.ckpt Epoch 9/100 625/625 [==============================] - 33s 52ms/step - loss: 0.4106 - accuracy: 0.8257 - val_loss: 0.2009 - val_accuracy: 0.9160 Epoch 00009: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0009.ckpt Epoch 10/100 625/625 [==============================] - 33s 53ms/step - loss: 0.3891 - accuracy: 0.8427 - val_loss: 0.1937 - val_accuracy: 0.9187 Epoch 00010: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0010.ckpt Epoch 11/100 625/625 [==============================] - 35s 56ms/step - loss: 0.3543 - accuracy: 0.8524 - val_loss: 0.1883 - val_accuracy: 0.9197 Epoch 00011: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0011.ckpt Epoch 12/100 625/625 [==============================] - 36s 58ms/step - loss: 0.3569 - accuracy: 0.8513 - val_loss: 0.1836 - val_accuracy: 0.9205 Epoch 00012: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0012.ckpt Epoch 13/100 625/625 [==============================] - 35s 56ms/step - loss: 0.3457 - accuracy: 0.8584 - val_loss: 0.1798 - val_accuracy: 0.9200 Epoch 00013: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0013.ckpt Epoch 14/100 625/625 [==============================] - 33s 53ms/step - loss: 0.3363 - accuracy: 0.8616 - val_loss: 0.1771 - val_accuracy: 0.9212 Epoch 00014: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0014.ckpt Epoch 15/100 625/625 [==============================] - 33s 53ms/step - loss: 0.3261 - accuracy: 0.8705 - val_loss: 0.1742 - val_accuracy: 0.9225 Epoch 00015: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0015.ckpt Epoch 16/100 625/625 [==============================] - 33s 52ms/step - loss: 0.3186 - accuracy: 0.8702 - val_loss: 0.1717 - val_accuracy: 0.9235 Epoch 00016: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0016.ckpt Epoch 17/100 625/625 [==============================] - 33s 52ms/step - loss: 0.3046 - accuracy: 0.8736 - val_loss: 0.1693 - val_accuracy: 0.9243 Epoch 00017: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0017.ckpt Epoch 18/100 625/625 [==============================] - 33s 53ms/step - loss: 0.2908 - accuracy: 0.8800 - val_loss: 0.1675 - val_accuracy: 0.9258 Epoch 00018: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0018.ckpt Epoch 19/100 625/625 [==============================] - 39s 62ms/step - loss: 0.2917 - accuracy: 0.8808 - val_loss: 0.1659 - val_accuracy: 0.9280 Epoch 00019: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0019.ckpt Epoch 20/100 625/625 [==============================] - 34s 55ms/step - loss: 0.2935 - accuracy: 0.8795 - val_loss: 0.1644 - val_accuracy: 0.9300 Epoch 00020: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0020.ckpt Epoch 21/100 625/625 [==============================] - 33s 53ms/step - loss: 0.2887 - accuracy: 0.8839 - val_loss: 0.1630 - val_accuracy: 0.9298 Epoch 00021: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0021.ckpt Epoch 22/100 625/625 [==============================] - 33s 53ms/step - loss: 0.2839 - accuracy: 0.8817 - val_loss: 0.1617 - val_accuracy: 0.9302 Epoch 00022: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0022.ckpt Epoch 23/100 625/625 [==============================] - 33s 53ms/step - loss: 0.2843 - accuracy: 0.8884 - val_loss: 0.1604 - val_accuracy: 0.9305 Epoch 00023: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0023.ckpt Epoch 24/100 625/625 [==============================] - 33s 53ms/step - loss: 0.2698 - accuracy: 0.8910 - val_loss: 0.1594 - val_accuracy: 0.9295 Epoch 00024: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0024.ckpt Epoch 25/100 625/625 [==============================] - 33s 53ms/step - loss: 0.2755 - accuracy: 0.8899 - val_loss: 0.1585 - val_accuracy: 0.9302 Epoch 00025: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0025.ckpt Epoch 26/100 625/625 [==============================] - 34s 54ms/step - loss: 0.2663 - accuracy: 0.8908 - val_loss: 0.1577 - val_accuracy: 0.9310 Epoch 00026: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0026.ckpt Epoch 27/100 625/625 [==============================] - 34s 54ms/step - loss: 0.2617 - accuracy: 0.8931 - val_loss: 0.1565 - val_accuracy: 0.9317 Epoch 00027: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0027.ckpt Epoch 28/100 625/625 [==============================] - 33s 52ms/step - loss: 0.2679 - accuracy: 0.8914 - val_loss: 0.1557 - val_accuracy: 0.9317 Epoch 00028: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0028.ckpt Epoch 29/100 625/625 [==============================] - 33s 53ms/step - loss: 0.2637 - accuracy: 0.8914 - val_loss: 0.1549 - val_accuracy: 0.9333 Epoch 00029: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0029.ckpt Epoch 30/100 625/625 [==============================] - 35s 55ms/step - loss: 0.2468 - accuracy: 0.9009 - val_loss: 0.1541 - val_accuracy: 0.9335 Epoch 00030: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0030.ckpt Epoch 31/100 625/625 [==============================] - 34s 54ms/step - loss: 0.2569 - accuracy: 0.8963 - val_loss: 0.1534 - val_accuracy: 0.9337 Epoch 00031: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0031.ckpt Epoch 32/100 625/625 [==============================] - 33s 52ms/step - loss: 0.2467 - accuracy: 0.8990 - val_loss: 0.1528 - val_accuracy: 0.9333 Epoch 00032: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0032.ckpt Epoch 33/100 625/625 [==============================] - 31s 50ms/step - loss: 0.2544 - accuracy: 0.8979 - val_loss: 0.1521 - val_accuracy: 0.9335 Epoch 00033: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0033.ckpt Epoch 34/100 625/625 [==============================] - 32s 50ms/step - loss: 0.2508 - accuracy: 0.8992 - val_loss: 0.1516 - val_accuracy: 0.9337 Epoch 00034: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0034.ckpt
plot_model__hist(ResNet50V2_model_hist_1)
loss_1,acc_1 = ResNet50V2_model_1.evaluate(test_set, verbose=2)
print("ResNet50V2_model_1 백본 프리징 후 모델의 정확도: {:5.2f}%".format(100*acc_1))
print("ResNet50V2_model_1 백본 프리징 후 모델의 Loss: {}".format(loss_1))
<Figure size 432x288 with 0 Axes>
100/100 - 2s - loss: 0.1535 - accuracy: 0.9270 ResNet50V2_model_1 백본 프리징 후 모델의 정확도: 92.70% ResNet50V2_model_1 백본 프리징 후 모델의 Loss: 0.15354347229003906
ResNet50V2_model = keras.Sequential([
get_ResNet50V2(size=128,trainable=True), # 백본 학습 가능하게 설정
Dense(256, activation='relu'),
Dropout(0.5),
Dense(128, activation='relu'),
Dropout(0.25),
Dense(1,activation='sigmoid')
])
checkpoint_path_1 = r"D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1/cp-{epoch:04d}.ckpt"
callbacks = get_callbacks(checkpoint_path_1)
from tensorflow.keras.optimizers import Adam
opt = Adam(learning_rate=0.001)
ResNet50V2_model.compile(optimizer=opt, loss='binary_crossentropy',metrics=['accuracy'])
ResNet50V2_model_hist = ResNet50V2_model.fit(train_set,
validation_data=val_set,
epochs=100,
callbacks = [callbacks])
Epoch 1/100 625/625 [==============================] - 86s 127ms/step - loss: 0.5450 - accuracy: 0.7480 - val_loss: 0.9595 - val_accuracy: 0.6102 Epoch 00001: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0001.ckpt Epoch 2/100 625/625 [==============================] - 79s 126ms/step - loss: 0.2457 - accuracy: 0.8989 - val_loss: 0.4350 - val_accuracy: 0.8120 Epoch 00002: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0002.ckpt Epoch 3/100 625/625 [==============================] - 80s 128ms/step - loss: 0.2239 - accuracy: 0.9120 - val_loss: 0.3559 - val_accuracy: 0.8455 Epoch 00003: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0003.ckpt Epoch 4/100 625/625 [==============================] - 80s 128ms/step - loss: 0.1643 - accuracy: 0.9362 - val_loss: 0.2788 - val_accuracy: 0.8795 Epoch 00004: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0004.ckpt Epoch 5/100 625/625 [==============================] - 79s 126ms/step - loss: 0.1315 - accuracy: 0.9489 - val_loss: 0.2229 - val_accuracy: 0.9107 Epoch 00005: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0005.ckpt Epoch 6/100 625/625 [==============================] - 78s 125ms/step - loss: 0.1084 - accuracy: 0.9575 - val_loss: 0.2236 - val_accuracy: 0.9080 Epoch 00006: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0006.ckpt Epoch 7/100 625/625 [==============================] - 79s 126ms/step - loss: 0.0961 - accuracy: 0.9638 - val_loss: 0.6200 - val_accuracy: 0.8652 Epoch 00007: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0007.ckpt Epoch 8/100 625/625 [==============================] - 80s 128ms/step - loss: 0.1001 - accuracy: 0.9615 - val_loss: 0.1769 - val_accuracy: 0.9350 Epoch 00008: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0008.ckpt Epoch 9/100 625/625 [==============================] - 79s 126ms/step - loss: 0.1278 - accuracy: 0.9484 - val_loss: 0.4366 - val_accuracy: 0.8183 Epoch 00009: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0009.ckpt Epoch 10/100 625/625 [==============================] - 79s 127ms/step - loss: 0.2388 - accuracy: 0.9044 - val_loss: 0.1700 - val_accuracy: 0.9330 Epoch 00010: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0010.ckpt Epoch 11/100 625/625 [==============================] - 82s 132ms/step - loss: 0.0936 - accuracy: 0.9654 - val_loss: 0.4674 - val_accuracy: 0.8263 Epoch 00011: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_1\cp-0011.ckpt
plot_model__hist(ResNet50V2_model_hist)
loss,acc = ResNet50V2_model.evaluate(test_set, verbose=2)
print("ResNet50V2_model(Adam) 백본 프리징 해제 후 모델의 정확도: {:5.2f}%".format(100*acc))
print("ResNet50V2_model(Adam) 백본 프리징 해제 후 모델의 Loss: {}".format(loss))
<Figure size 432x288 with 0 Axes>
100/100 - 6s - loss: 0.4755 - accuracy: 0.8240 ResNet50V2_model(Adam) 백본 프리징 해제 후 모델의 정확도: 82.40% ResNet50V2_model(Adam) 백본 프리징 해제 후 모델의 Loss: 0.4754612147808075
train_set, val_set, test_set = get_dataset(size=128)
ResNet50V2_model_sgd = keras.Sequential([
get_ResNet50V2(size=128,trainable=True), # 백본 학습 가능하게 설정
Dense(256, activation='relu'),
Dropout(0.5),
Dense(128, activation='relu'),
Dropout(0.25),
Dense(1,activation='sigmoid')
])
checkpoint_path_3 = r"D:\Project(2)\cat&dog_set\check_point_ResNet50V2_2/cp-{epoch:04d}.ckpt"
callbacks = get_callbacks(checkpoint_path_3)
opt = SGD(lr=0.01, decay=1e-6, momentum=0.001,nesterov=True)
ResNet50V2_model_sgd.compile(optimizer=opt, loss='binary_crossentropy',metrics=['accuracy'])
Found 20000 images belonging to 2 classes. Found 4000 images belonging to 2 classes. Found 1000 images belonging to 2 classes.
ResNet50V2_model_sgd_hist = ResNet50V2_model_sgd.fit(train_set,
validation_data=val_set,
epochs=100,
callbacks = [callbacks])
Epoch 1/100 625/625 [==============================] - 84s 127ms/step - loss: 0.4003 - accuracy: 0.7940 - val_loss: 0.1246 - val_accuracy: 0.9503 Epoch 00001: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_2\cp-0001.ckpt Epoch 2/100 625/625 [==============================] - 80s 127ms/step - loss: 0.1006 - accuracy: 0.9639 - val_loss: 0.1192 - val_accuracy: 0.9542 Epoch 00002: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_2\cp-0002.ckpt Epoch 3/100 625/625 [==============================] - 80s 128ms/step - loss: 0.0464 - accuracy: 0.9840 - val_loss: 0.1191 - val_accuracy: 0.9563 Epoch 00003: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_2\cp-0003.ckpt Epoch 4/100 625/625 [==============================] - 80s 128ms/step - loss: 0.0265 - accuracy: 0.9912 - val_loss: 0.1431 - val_accuracy: 0.9540 Epoch 00004: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_2\cp-0004.ckpt Epoch 5/100 625/625 [==============================] - 80s 128ms/step - loss: 0.0185 - accuracy: 0.9946 - val_loss: 0.1432 - val_accuracy: 0.9592 Epoch 00005: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_2\cp-0005.ckpt Epoch 6/100 625/625 [==============================] - 80s 128ms/step - loss: 0.0243 - accuracy: 0.9915 - val_loss: 0.1468 - val_accuracy: 0.9607 Epoch 00006: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_2\cp-0006.ckpt Epoch 7/100 625/625 [==============================] - 81s 130ms/step - loss: 0.0138 - accuracy: 0.9956 - val_loss: 0.1537 - val_accuracy: 0.9588 Epoch 00007: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_2\cp-0007.ckpt Epoch 8/100 625/625 [==============================] - 82s 131ms/step - loss: 0.0097 - accuracy: 0.9971 - val_loss: 0.1549 - val_accuracy: 0.9628 Epoch 00008: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_2\cp-0008.ckpt Epoch 9/100 625/625 [==============================] - 82s 130ms/step - loss: 0.0092 - accuracy: 0.9974 - val_loss: 0.1848 - val_accuracy: 0.9578 Epoch 00009: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_2\cp-0009.ckpt Epoch 10/100 625/625 [==============================] - 82s 130ms/step - loss: 0.0055 - accuracy: 0.9988 - val_loss: 0.1579 - val_accuracy: 0.9632 Epoch 00010: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_2\cp-0010.ckpt Epoch 11/100 625/625 [==============================] - 81s 130ms/step - loss: 0.0030 - accuracy: 0.9995 - val_loss: 0.1776 - val_accuracy: 0.9615 Epoch 00011: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_2\cp-0011.ckpt Epoch 12/100 625/625 [==============================] - 82s 130ms/step - loss: 0.0051 - accuracy: 0.9982 - val_loss: 0.1700 - val_accuracy: 0.9643 Epoch 00012: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_2\cp-0012.ckpt Epoch 13/100 625/625 [==============================] - 82s 131ms/step - loss: 0.0036 - accuracy: 0.9985 - val_loss: 0.1924 - val_accuracy: 0.9620 Epoch 00013: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_2\cp-0013.ckpt Epoch 14/100 625/625 [==============================] - 81s 130ms/step - loss: 0.0056 - accuracy: 0.9981 - val_loss: 0.1871 - val_accuracy: 0.9580 Epoch 00014: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_2\cp-0014.ckpt Epoch 15/100 625/625 [==============================] - 82s 130ms/step - loss: 0.0039 - accuracy: 0.9989 - val_loss: 0.1852 - val_accuracy: 0.9628 Epoch 00015: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_2\cp-0015.ckpt
plot_model__hist(ResNet50V2_model_sgd_hist)
loss_sgd,acc_sgd = ResNet50V2_model_sgd.evaluate(test_set, verbose=2)
print("ResNet50V2_model(SGD) 백본 프리징 해제 후 모델의 정확도: {:5.2f}%".format(100*acc_sgd))
print("ResNet50V2_model(SGD) 백본 프리징 해제 후 모델의 Loss: {}".format(loss_sgd))
<Figure size 432x288 with 0 Axes>
100/100 - 6s - loss: 0.1670 - accuracy: 0.9700 ResNet50V2_model(SGD) 백본 프리징 해제 후 모델의 정확도: 97.00% ResNet50V2_model(SGD) 백본 프리징 해제 후 모델의 Loss: 0.16704358160495758
from Crawling_Naver import *
add_dataset_path = r"D:\Project(2)\cat&dog_set\additional_train"
crawl_dog = crawling_NAVER()
crawl_dog.crawling_start(keyword="개",index=2000, directory=add_dataset_path, category="dog_", forderName="dog")
crawl_cat = crawling_NAVER()
crawl_cat.crawling_start(keyword="고양이",index=2000, directory=add_dataset_path, category="cat_", forderName="cat")
Geometry blur Contrast Color ImgCorruptlike Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="main_pack"]/section/div/div[1]/div[1]/div[11]/div/div[1]/a/img"} (Session info: chrome=93.0.4577.63) Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="main_pack"]/section/div/div[1]/div[1]/div[35]/div/div[1]/a/img"} (Session info: chrome=93.0.4577.63) Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="main_pack"]/section/div/div[1]/div[1]/div[61]/div/div[1]/a/img"} (Session info: chrome=93.0.4577.63) Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="main_pack"]/section/div/div[1]/div[1]/div[85]/div/div[1]/a/img"} (Session info: chrome=93.0.4577.63) Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="main_pack"]/section/div/div[1]/div[1]/div[109]/div/div[1]/a/img"} (Session info: chrome=93.0.4577.63) Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="main_pack"]/section/div/div[1]/div[1]/div[133]/div/div[1]/a/img"} (Session info: chrome=93.0.4577.63) Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="main_pack"]/section/div/div[1]/div[1]/div[161]/div/div[1]/a/img"} (Session info: chrome=93.0.4577.63) Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="main_pack"]/section/div/div[1]/div[1]/div[185]/div/div[1]/a/img"} (Session info: chrome=93.0.4577.63) Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="main_pack"]/section/div/div[1]/div[1]/div[209]/div/div[1]/a/img"} (Session info: chrome=93.0.4577.63) Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="main_pack"]/section/div/div[1]/div[1]/div[233]/div/div[1]/a/img"} (Session info: chrome=93.0.4577.63) Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="main_pack"]/section/div/div[1]/div[1]/div[261]/div/div[1]/a/img"} (Session info: chrome=93.0.4577.63) Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="main_pack"]/section/div/div[1]/div[1]/div[285]/div/div[1]/a/img"} (Session info: chrome=93.0.4577.63) Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="main_pack"]/section/div/div[1]/div[1]/div[309]/div/div[1]/a/img"} (Session info: chrome=93.0.4577.63) Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="main_pack"]/section/div/div[1]/div[1]/div[333]/div/div[1]/a/img"} (Session info: chrome=93.0.4577.63) Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="main_pack"]/section/div/div[1]/div[1]/div[361]/div/div[1]/a/img"} (Session info: chrome=93.0.4577.63) Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="main_pack"]/section/div/div[1]/div[1]/div[385]/div/div[1]/a/img"} (Session info: chrome=93.0.4577.63) Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="main_pack"]/section/div/div[1]/div[1]/div[409]/div/div[1]/a/img"} (Session info: chrome=93.0.4577.63) Geometry blur Contrast Color ImgCorruptlike Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="main_pack"]/section/div/div[1]/div[1]/div[11]/div/div[1]/a/img"} (Session info: chrome=93.0.4577.63) Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="main_pack"]/section/div/div[1]/div[1]/div[35]/div/div[1]/a/img"} (Session info: chrome=93.0.4577.63) Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="main_pack"]/section/div/div[1]/div[1]/div[61]/div/div[1]/a/img"} (Session info: chrome=93.0.4577.63) Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="main_pack"]/section/div/div[1]/div[1]/div[85]/div/div[1]/a/img"} (Session info: chrome=93.0.4577.63) Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="main_pack"]/section/div/div[1]/div[1]/div[109]/div/div[1]/a/img"} (Session info: chrome=93.0.4577.63) Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="main_pack"]/section/div/div[1]/div[1]/div[133]/div/div[1]/a/img"} (Session info: chrome=93.0.4577.63) Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="main_pack"]/section/div/div[1]/div[1]/div[161]/div/div[1]/a/img"} (Session info: chrome=93.0.4577.63) Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="main_pack"]/section/div/div[1]/div[1]/div[185]/div/div[1]/a/img"} (Session info: chrome=93.0.4577.63) Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="main_pack"]/section/div/div[1]/div[1]/div[209]/div/div[1]/a/img"} (Session info: chrome=93.0.4577.63) Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="main_pack"]/section/div/div[1]/div[1]/div[233]/div/div[1]/a/img"} (Session info: chrome=93.0.4577.63) Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="main_pack"]/section/div/div[1]/div[1]/div[261]/div/div[1]/a/img"} (Session info: chrome=93.0.4577.63) Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="main_pack"]/section/div/div[1]/div[1]/div[285]/div/div[1]/a/img"} (Session info: chrome=93.0.4577.63) Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="main_pack"]/section/div/div[1]/div[1]/div[309]/div/div[1]/a/img"} (Session info: chrome=93.0.4577.63) Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="main_pack"]/section/div/div[1]/div[1]/div[333]/div/div[1]/a/img"} (Session info: chrome=93.0.4577.63)
True
train_set, val_set, test_set = get_dataset(crawl=True,aug=True,size=128)
# SGD 모델
ResNet50V2_model_sgd_crawl = keras.Sequential([
get_ResNet50V2(size=128,trainable=True), # 백본 학습 가능하게 설정
Dense(256, activation='relu'),
Dropout(0.5),
Dense(128, activation='relu'),
Dropout(0.25),
Dense(1,activation='sigmoid')
])
# 가중치 저장경로 변경
checkpoint_path = r"D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_SGD/cp-{epoch:04d}.ckpt"
callbacks = get_callbacks(checkpoint_path,patience=5)#동일 조건
opt = SGD(lr=0.01, decay=1e-6, momentum=0.001,nesterov=True)
ResNet50V2_model_sgd_crawl.compile(optimizer=opt, loss='binary_crossentropy',metrics=['accuracy'])
ResNet50V2_model_sgd_crawl_hist = ResNet50V2_model_sgd_crawl.fit(train_set,
validation_data=val_set,
epochs=100,
callbacks = [callbacks])
Found 21900 images belonging to 2 classes. Found 4000 images belonging to 2 classes. Found 1000 images belonging to 2 classes. Epoch 1/100 685/685 [==============================] - 237s 337ms/step - loss: 0.4919 - accuracy: 0.7392 - val_loss: 0.1578 - val_accuracy: 0.9362 Epoch 00001: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_SGD\cp-0001.ckpt Epoch 2/100 685/685 [==============================] - 111s 162ms/step - loss: 0.2244 - accuracy: 0.9087 - val_loss: 0.1378 - val_accuracy: 0.9445 Epoch 00002: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_SGD\cp-0002.ckpt Epoch 3/100 685/685 [==============================] - 113s 165ms/step - loss: 0.1749 - accuracy: 0.9329 - val_loss: 0.1892 - val_accuracy: 0.9230 Epoch 00003: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_SGD\cp-0003.ckpt Epoch 4/100 685/685 [==============================] - 111s 162ms/step - loss: 0.1392 - accuracy: 0.9486 - val_loss: 0.1417 - val_accuracy: 0.9470 Epoch 00004: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_SGD\cp-0004.ckpt Epoch 5/100 685/685 [==============================] - 108s 157ms/step - loss: 0.1208 - accuracy: 0.9533 - val_loss: 0.1082 - val_accuracy: 0.9567 Epoch 00005: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_SGD\cp-0005.ckpt Epoch 6/100 685/685 [==============================] - 112s 163ms/step - loss: 0.1131 - accuracy: 0.9594 - val_loss: 0.1126 - val_accuracy: 0.9532 Epoch 00006: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_SGD\cp-0006.ckpt Epoch 7/100 685/685 [==============================] - 115s 167ms/step - loss: 0.0921 - accuracy: 0.9663 - val_loss: 0.1147 - val_accuracy: 0.9597 Epoch 00007: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_SGD\cp-0007.ckpt Epoch 8/100 685/685 [==============================] - 114s 166ms/step - loss: 0.0859 - accuracy: 0.9671 - val_loss: 0.1083 - val_accuracy: 0.9610 Epoch 00008: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_SGD\cp-0008.ckpt Epoch 9/100 685/685 [==============================] - 118s 172ms/step - loss: 0.0857 - accuracy: 0.9688 - val_loss: 0.1157 - val_accuracy: 0.9567 Epoch 00009: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_SGD\cp-0009.ckpt Epoch 10/100 685/685 [==============================] - 110s 160ms/step - loss: 0.0714 - accuracy: 0.9730 - val_loss: 0.1000 - val_accuracy: 0.9625 Epoch 00010: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_SGD\cp-0010.ckpt Epoch 11/100 685/685 [==============================] - 109s 159ms/step - loss: 0.0706 - accuracy: 0.9753 - val_loss: 0.1534 - val_accuracy: 0.9480 Epoch 00011: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_SGD\cp-0011.ckpt Epoch 12/100 685/685 [==============================] - 108s 157ms/step - loss: 0.0588 - accuracy: 0.9796 - val_loss: 0.1014 - val_accuracy: 0.9628 Epoch 00012: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_SGD\cp-0012.ckpt Epoch 13/100 685/685 [==============================] - 112s 163ms/step - loss: 0.0525 - accuracy: 0.9813 - val_loss: 0.1365 - val_accuracy: 0.9575 Epoch 00013: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_SGD\cp-0013.ckpt Epoch 14/100 685/685 [==============================] - 110s 160ms/step - loss: 0.0539 - accuracy: 0.9807 - val_loss: 0.1091 - val_accuracy: 0.9632 Epoch 00014: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_SGD\cp-0014.ckpt Epoch 15/100 685/685 [==============================] - 111s 162ms/step - loss: 0.0540 - accuracy: 0.9806 - val_loss: 0.1008 - val_accuracy: 0.9660 Epoch 00015: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_SGD\cp-0015.ckpt Epoch 16/100 685/685 [==============================] - 111s 162ms/step - loss: 0.0470 - accuracy: 0.9830 - val_loss: 0.1152 - val_accuracy: 0.9595 Epoch 00016: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_SGD\cp-0016.ckpt Epoch 17/100 685/685 [==============================] - 107s 157ms/step - loss: 0.0460 - accuracy: 0.9841 - val_loss: 0.1203 - val_accuracy: 0.9613 Epoch 00017: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_SGD\cp-0017.ckpt Epoch 18/100 685/685 [==============================] - 110s 160ms/step - loss: 0.0390 - accuracy: 0.9855 - val_loss: 0.1396 - val_accuracy: 0.9567 Epoch 00018: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_SGD\cp-0018.ckpt Epoch 19/100 685/685 [==============================] - 108s 158ms/step - loss: 0.0385 - accuracy: 0.9871 - val_loss: 0.1227 - val_accuracy: 0.9610 Epoch 00019: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_SGD\cp-0019.ckpt Epoch 20/100 685/685 [==============================] - 110s 160ms/step - loss: 0.0374 - accuracy: 0.9870 - val_loss: 0.1113 - val_accuracy: 0.9660 Epoch 00020: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_SGD\cp-0020.ckpt
plot_model__hist(ResNet50V2_model_sgd_crawl_hist)
loss_sgd,acc_sgd = ResNet50V2_model_sgd_crawl.evaluate(test_set, verbose=2)
print("ResNet50V2_model(SGD) 이미지 크롤링,증강 후 모델의 정확도: {:5.2f}%".format(100*acc_sgd))
print("ResNet50V2_model(SGD) 이미지 크롤링,증강 후 모델의 Loss: {}".format(loss_sgd))
<Figure size 432x288 with 0 Axes>
100/100 - 8s - loss: 0.0836 - accuracy: 0.9750 ResNet50V2_model(SGD) 이미지 크롤링,증강 후 모델의 정확도: 97.50% ResNet50V2_model(SGD) 이미지 크롤링,증강 후 모델의 Loss: 0.083615742623806
from tensorflow.keras.optimizers import Adam
train_set, val_set, test_set = get_dataset(crawl=True,aug=True,size=128)
# Adam 모델
ResNet50V2_model_adam_crawl = keras.Sequential([
get_ResNet50V2(size=128,trainable=True), # 백본 학습 가능하게 설정
Dense(256, activation='relu'),
Dropout(0.5),
Dense(128, activation='relu'),
Dropout(0.25),
Dense(1,activation='sigmoid')
])
# 가중치 저장경로 변경
checkpoint_path = r"D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam/cp-{epoch:04d}.ckpt"
callbacks = get_callbacks(checkpoint_path,patience=50)#동일 조건
opt = Adam(learning_rate=0.001)
ResNet50V2_model_adam_crawl.compile(optimizer=opt, loss='binary_crossentropy',metrics=['accuracy'])
ResNet50V2_model_adam_crawl_hist = ResNet50V2_model_adam_crawl.fit(train_set,
validation_data=val_set,
epochs=500,
callbacks = [callbacks])
Found 20000 images belonging to 2 classes. Found 4000 images belonging to 2 classes. Found 1000 images belonging to 2 classes. Epoch 1/500 625/625 [==============================] - 202s 317ms/step - loss: 0.6546 - accuracy: 0.6484 - val_loss: 0.6594 - val_accuracy: 0.7147 Epoch 00001: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0001.ckpt Epoch 2/500 625/625 [==============================] - 104s 166ms/step - loss: 0.5193 - accuracy: 0.7574 - val_loss: 0.6010 - val_accuracy: 0.7243 Epoch 00002: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0002.ckpt Epoch 3/500 625/625 [==============================] - 104s 166ms/step - loss: 0.4368 - accuracy: 0.8022 - val_loss: 0.7599 - val_accuracy: 0.6888 Epoch 00003: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0003.ckpt Epoch 4/500 625/625 [==============================] - 104s 166ms/step - loss: 0.3874 - accuracy: 0.8318 - val_loss: 0.5589 - val_accuracy: 0.8027 Epoch 00004: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0004.ckpt Epoch 5/500 625/625 [==============================] - 104s 166ms/step - loss: 0.3638 - accuracy: 0.8490 - val_loss: 0.6252 - val_accuracy: 0.7490 Epoch 00005: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0005.ckpt Epoch 6/500 625/625 [==============================] - 105s 168ms/step - loss: 0.3249 - accuracy: 0.8627 - val_loss: 0.4346 - val_accuracy: 0.7883 Epoch 00006: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0006.ckpt Epoch 7/500 625/625 [==============================] - 104s 166ms/step - loss: 0.3152 - accuracy: 0.8654 - val_loss: 0.3762 - val_accuracy: 0.8455 Epoch 00007: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0007.ckpt Epoch 8/500 625/625 [==============================] - 104s 166ms/step - loss: 0.2858 - accuracy: 0.8799 - val_loss: 0.4503 - val_accuracy: 0.8120 Epoch 00008: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0008.ckpt Epoch 9/500 625/625 [==============================] - 104s 166ms/step - loss: 0.3160 - accuracy: 0.8656 - val_loss: 0.2513 - val_accuracy: 0.8985 Epoch 00009: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0009.ckpt Epoch 10/500 625/625 [==============================] - 104s 167ms/step - loss: 0.2629 - accuracy: 0.8916 - val_loss: 0.3425 - val_accuracy: 0.8370 Epoch 00010: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0010.ckpt Epoch 11/500 625/625 [==============================] - 104s 166ms/step - loss: 0.3055 - accuracy: 0.8748 - val_loss: 0.3927 - val_accuracy: 0.8307 Epoch 00011: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0011.ckpt Epoch 12/500 625/625 [==============================] - 106s 170ms/step - loss: 0.2610 - accuracy: 0.8908 - val_loss: 0.8189 - val_accuracy: 0.6535 Epoch 00012: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0012.ckpt Epoch 13/500 625/625 [==============================] - 104s 166ms/step - loss: 0.2555 - accuracy: 0.8949 - val_loss: 0.2603 - val_accuracy: 0.8865 Epoch 00013: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0013.ckpt Epoch 14/500 625/625 [==============================] - 104s 166ms/step - loss: 0.2233 - accuracy: 0.9058 - val_loss: 0.2366 - val_accuracy: 0.9047 Epoch 00014: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0014.ckpt Epoch 15/500 625/625 [==============================] - 105s 168ms/step - loss: 0.2176 - accuracy: 0.9143 - val_loss: 0.3208 - val_accuracy: 0.8447 Epoch 00015: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0015.ckpt Epoch 16/500 625/625 [==============================] - 105s 168ms/step - loss: 0.2697 - accuracy: 0.8875 - val_loss: 0.4351 - val_accuracy: 0.8428 Epoch 00016: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0016.ckpt Epoch 17/500 625/625 [==============================] - 108s 172ms/step - loss: 0.2640 - accuracy: 0.8890 - val_loss: 0.2558 - val_accuracy: 0.8913 Epoch 00017: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0017.ckpt Epoch 18/500 625/625 [==============================] - 105s 168ms/step - loss: 0.2393 - accuracy: 0.9059 - val_loss: 0.2567 - val_accuracy: 0.8810 Epoch 00018: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0018.ckpt Epoch 19/500 625/625 [==============================] - 106s 169ms/step - loss: 0.2181 - accuracy: 0.9114 - val_loss: 0.3141 - val_accuracy: 0.8593 Epoch 00019: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0019.ckpt Epoch 20/500 625/625 [==============================] - 105s 168ms/step - loss: 0.2157 - accuracy: 0.9196 - val_loss: 0.1916 - val_accuracy: 0.9222 Epoch 00020: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0020.ckpt Epoch 21/500 625/625 [==============================] - 106s 169ms/step - loss: 0.1864 - accuracy: 0.9270 - val_loss: 0.2959 - val_accuracy: 0.8712 Epoch 00021: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0021.ckpt Epoch 22/500 625/625 [==============================] - 105s 168ms/step - loss: 0.1806 - accuracy: 0.9287 - val_loss: 0.2371 - val_accuracy: 0.9078 Epoch 00022: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0022.ckpt Epoch 23/500 625/625 [==============================] - 107s 172ms/step - loss: 0.1842 - accuracy: 0.9273 - val_loss: 0.2146 - val_accuracy: 0.9120 Epoch 00023: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0023.ckpt Epoch 24/500 625/625 [==============================] - 107s 171ms/step - loss: 0.1710 - accuracy: 0.9325 - val_loss: 0.3586 - val_accuracy: 0.8715 Epoch 00024: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0024.ckpt Epoch 25/500 625/625 [==============================] - 105s 168ms/step - loss: 0.1955 - accuracy: 0.9224 - val_loss: 0.2243 - val_accuracy: 0.9087 Epoch 00025: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0025.ckpt Epoch 26/500 625/625 [==============================] - 106s 169ms/step - loss: 0.1736 - accuracy: 0.9307 - val_loss: 0.4214 - val_accuracy: 0.8313 Epoch 00026: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0026.ckpt Epoch 27/500 625/625 [==============================] - 105s 169ms/step - loss: 0.2260 - accuracy: 0.9108 - val_loss: 0.2034 - val_accuracy: 0.9195 Epoch 00027: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0027.ckpt Epoch 28/500 625/625 [==============================] - 106s 169ms/step - loss: 0.1654 - accuracy: 0.9331 - val_loss: 1.0227 - val_accuracy: 0.5900 Epoch 00028: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0028.ckpt Epoch 29/500 625/625 [==============================] - 106s 170ms/step - loss: 0.1936 - accuracy: 0.9235 - val_loss: 0.1998 - val_accuracy: 0.9150 Epoch 00029: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0029.ckpt Epoch 30/500 625/625 [==============================] - 106s 169ms/step - loss: 0.1540 - accuracy: 0.9390 - val_loss: 0.5147 - val_accuracy: 0.7600 Epoch 00030: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0030.ckpt Epoch 31/500 625/625 [==============================] - 105s 168ms/step - loss: 0.1644 - accuracy: 0.9352 - val_loss: 0.2664 - val_accuracy: 0.9038 Epoch 00031: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0031.ckpt Epoch 32/500 625/625 [==============================] - 106s 169ms/step - loss: 0.1491 - accuracy: 0.9393 - val_loss: 0.2045 - val_accuracy: 0.9212 Epoch 00032: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0032.ckpt Epoch 33/500 625/625 [==============================] - 106s 169ms/step - loss: 0.1487 - accuracy: 0.9411 - val_loss: 0.2565 - val_accuracy: 0.9078 Epoch 00033: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0033.ckpt Epoch 34/500 625/625 [==============================] - 108s 172ms/step - loss: 0.1579 - accuracy: 0.9376 - val_loss: 0.2028 - val_accuracy: 0.9233 Epoch 00034: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0034.ckpt Epoch 35/500 625/625 [==============================] - 105s 168ms/step - loss: 0.1388 - accuracy: 0.9440 - val_loss: 0.2212 - val_accuracy: 0.9015 Epoch 00035: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0035.ckpt Epoch 36/500 625/625 [==============================] - 105s 168ms/step - loss: 0.1583 - accuracy: 0.9370 - val_loss: 0.1724 - val_accuracy: 0.9270 Epoch 00036: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0036.ckpt Epoch 37/500 625/625 [==============================] - 106s 169ms/step - loss: 0.1296 - accuracy: 0.9481 - val_loss: 0.1730 - val_accuracy: 0.9358 Epoch 00037: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0037.ckpt Epoch 38/500 625/625 [==============================] - 105s 168ms/step - loss: 0.1322 - accuracy: 0.9500 - val_loss: 0.1665 - val_accuracy: 0.9350 Epoch 00038: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0038.ckpt Epoch 39/500 625/625 [==============================] - 105s 168ms/step - loss: 0.1233 - accuracy: 0.9519 - val_loss: 0.2274 - val_accuracy: 0.9137 Epoch 00039: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0039.ckpt Epoch 40/500 625/625 [==============================] - 107s 171ms/step - loss: 0.1224 - accuracy: 0.9527 - val_loss: 0.1730 - val_accuracy: 0.9315 Epoch 00040: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0040.ckpt Epoch 41/500 625/625 [==============================] - 105s 168ms/step - loss: 0.1221 - accuracy: 0.9538 - val_loss: 0.2472 - val_accuracy: 0.8995 Epoch 00041: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0041.ckpt Epoch 42/500 625/625 [==============================] - 105s 168ms/step - loss: 0.1234 - accuracy: 0.9525 - val_loss: 0.1568 - val_accuracy: 0.9373 Epoch 00042: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0042.ckpt Epoch 43/500 625/625 [==============================] - 105s 169ms/step - loss: 0.1123 - accuracy: 0.9548 - val_loss: 0.1778 - val_accuracy: 0.9237 Epoch 00043: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0043.ckpt Epoch 44/500 625/625 [==============================] - 105s 168ms/step - loss: 0.1122 - accuracy: 0.9573 - val_loss: 0.2323 - val_accuracy: 0.9162 Epoch 00044: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0044.ckpt Epoch 45/500 625/625 [==============================] - 107s 170ms/step - loss: 0.1227 - accuracy: 0.9509 - val_loss: 0.2668 - val_accuracy: 0.8863 Epoch 00045: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0045.ckpt Epoch 46/500 625/625 [==============================] - 105s 168ms/step - loss: 0.1157 - accuracy: 0.9554 - val_loss: 0.1586 - val_accuracy: 0.9345 Epoch 00046: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0046.ckpt Epoch 47/500 625/625 [==============================] - 105s 168ms/step - loss: 0.1002 - accuracy: 0.9621 - val_loss: 0.2078 - val_accuracy: 0.9237 Epoch 00047: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0047.ckpt Epoch 48/500 625/625 [==============================] - 105s 168ms/step - loss: 0.1066 - accuracy: 0.9592 - val_loss: 0.4060 - val_accuracy: 0.8175 Epoch 00048: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0048.ckpt Epoch 49/500 625/625 [==============================] - 105s 168ms/step - loss: 0.1049 - accuracy: 0.9585 - val_loss: 0.2185 - val_accuracy: 0.9233 Epoch 00049: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0049.ckpt Epoch 50/500 625/625 [==============================] - 106s 170ms/step - loss: 0.0966 - accuracy: 0.9610 - val_loss: 0.3210 - val_accuracy: 0.8630 Epoch 00050: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0050.ckpt Epoch 51/500 625/625 [==============================] - 107s 172ms/step - loss: 0.1017 - accuracy: 0.9598 - val_loss: 0.2293 - val_accuracy: 0.9218 Epoch 00051: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0051.ckpt Epoch 52/500 625/625 [==============================] - 105s 168ms/step - loss: 0.0920 - accuracy: 0.9664 - val_loss: 0.5627 - val_accuracy: 0.8235 Epoch 00052: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0052.ckpt Epoch 53/500 625/625 [==============================] - 105s 168ms/step - loss: 0.1009 - accuracy: 0.9612 - val_loss: 0.2185 - val_accuracy: 0.9120 Epoch 00053: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0053.ckpt Epoch 54/500 625/625 [==============================] - 106s 169ms/step - loss: 0.0919 - accuracy: 0.9656 - val_loss: 0.2101 - val_accuracy: 0.9150 Epoch 00054: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0054.ckpt Epoch 55/500 625/625 [==============================] - 105s 168ms/step - loss: 0.0936 - accuracy: 0.9620 - val_loss: 0.1538 - val_accuracy: 0.9433 Epoch 00055: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0055.ckpt Epoch 56/500 625/625 [==============================] - 106s 169ms/step - loss: 0.0837 - accuracy: 0.9686 - val_loss: 0.2299 - val_accuracy: 0.9370 Epoch 00056: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0056.ckpt Epoch 57/500 625/625 [==============================] - 111s 177ms/step - loss: 0.1115 - accuracy: 0.9546 - val_loss: 0.2215 - val_accuracy: 0.9130 Epoch 00057: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0057.ckpt Epoch 58/500 625/625 [==============================] - 105s 167ms/step - loss: 0.1702 - accuracy: 0.9345 - val_loss: 0.1531 - val_accuracy: 0.9385 Epoch 00058: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0058.ckpt Epoch 59/500 625/625 [==============================] - 105s 167ms/step - loss: 0.1170 - accuracy: 0.9550 - val_loss: 0.1769 - val_accuracy: 0.9358 Epoch 00059: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0059.ckpt Epoch 60/500 625/625 [==============================] - 105s 168ms/step - loss: 0.0940 - accuracy: 0.9628 - val_loss: 0.1408 - val_accuracy: 0.9442 Epoch 00060: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0060.ckpt Epoch 61/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0820 - accuracy: 0.9688 - val_loss: 0.1525 - val_accuracy: 0.9463 Epoch 00061: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0061.ckpt Epoch 62/500 625/625 [==============================] - 107s 170ms/step - loss: 0.0799 - accuracy: 0.9696 - val_loss: 0.1426 - val_accuracy: 0.9457 Epoch 00062: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0062.ckpt Epoch 63/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0756 - accuracy: 0.9713 - val_loss: 0.1500 - val_accuracy: 0.9435 Epoch 00063: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0063.ckpt Epoch 64/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0834 - accuracy: 0.9693 - val_loss: 0.2452 - val_accuracy: 0.9165 Epoch 00064: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0064.ckpt Epoch 65/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0781 - accuracy: 0.9716 - val_loss: 0.1516 - val_accuracy: 0.9405 Epoch 00065: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0065.ckpt Epoch 66/500 625/625 [==============================] - 105s 167ms/step - loss: 0.0738 - accuracy: 0.9730 - val_loss: 0.3240 - val_accuracy: 0.8783 Epoch 00066: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0066.ckpt Epoch 67/500 625/625 [==============================] - 105s 168ms/step - loss: 0.0767 - accuracy: 0.9713 - val_loss: 0.2161 - val_accuracy: 0.9193 Epoch 00067: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0067.ckpt Epoch 68/500 625/625 [==============================] - 106s 170ms/step - loss: 0.0784 - accuracy: 0.9706 - val_loss: 0.2817 - val_accuracy: 0.9000 Epoch 00068: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0068.ckpt Epoch 69/500 625/625 [==============================] - 104s 166ms/step - loss: 0.0807 - accuracy: 0.9688 - val_loss: 0.1969 - val_accuracy: 0.9268 Epoch 00069: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0069.ckpt Epoch 70/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0732 - accuracy: 0.9723 - val_loss: 0.2965 - val_accuracy: 0.8925 Epoch 00070: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0070.ckpt Epoch 71/500 625/625 [==============================] - 104s 166ms/step - loss: 0.0717 - accuracy: 0.9733 - val_loss: 0.2526 - val_accuracy: 0.9118 Epoch 00071: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0071.ckpt Epoch 72/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0679 - accuracy: 0.9748 - val_loss: 0.2147 - val_accuracy: 0.9210 Epoch 00072: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0072.ckpt Epoch 73/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0676 - accuracy: 0.9748 - val_loss: 0.1885 - val_accuracy: 0.9330 Epoch 00073: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0073.ckpt Epoch 74/500 625/625 [==============================] - 106s 170ms/step - loss: 0.0708 - accuracy: 0.9720 - val_loss: 0.1928 - val_accuracy: 0.9325 Epoch 00074: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0074.ckpt Epoch 75/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0638 - accuracy: 0.9753 - val_loss: 0.3218 - val_accuracy: 0.8995 Epoch 00075: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0075.ckpt Epoch 76/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0668 - accuracy: 0.9756 - val_loss: 0.2725 - val_accuracy: 0.9060 Epoch 00076: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0076.ckpt Epoch 77/500 625/625 [==============================] - 105s 167ms/step - loss: 0.0680 - accuracy: 0.9731 - val_loss: 0.1870 - val_accuracy: 0.9380 Epoch 00077: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0077.ckpt Epoch 78/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0668 - accuracy: 0.9754 - val_loss: 0.2758 - val_accuracy: 0.9262 Epoch 00078: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0078.ckpt Epoch 79/500 625/625 [==============================] - 106s 170ms/step - loss: 0.0645 - accuracy: 0.9760 - val_loss: 0.1899 - val_accuracy: 0.9435 Epoch 00079: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0079.ckpt Epoch 80/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0599 - accuracy: 0.9768 - val_loss: 0.2627 - val_accuracy: 0.9185 Epoch 00080: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0080.ckpt Epoch 81/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0595 - accuracy: 0.9784 - val_loss: 0.2172 - val_accuracy: 0.9367 Epoch 00081: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0081.ckpt Epoch 82/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0610 - accuracy: 0.9780 - val_loss: 0.2161 - val_accuracy: 0.9335 Epoch 00082: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0082.ckpt Epoch 83/500 625/625 [==============================] - 105s 168ms/step - loss: 0.0615 - accuracy: 0.9737 - val_loss: 0.1572 - val_accuracy: 0.9435 Epoch 00083: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0083.ckpt Epoch 84/500 625/625 [==============================] - 105s 167ms/step - loss: 0.0578 - accuracy: 0.9763 - val_loss: 0.1662 - val_accuracy: 0.9490 Epoch 00084: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0084.ckpt Epoch 85/500 625/625 [==============================] - 107s 171ms/step - loss: 0.0548 - accuracy: 0.9779 - val_loss: 0.2449 - val_accuracy: 0.9087 Epoch 00085: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0085.ckpt Epoch 86/500 625/625 [==============================] - 105s 167ms/step - loss: 0.0527 - accuracy: 0.9804 - val_loss: 0.2897 - val_accuracy: 0.8873 Epoch 00086: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0086.ckpt Epoch 87/500 625/625 [==============================] - 105s 167ms/step - loss: 0.0549 - accuracy: 0.9782 - val_loss: 0.1784 - val_accuracy: 0.9488 Epoch 00087: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0087.ckpt Epoch 88/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0495 - accuracy: 0.9819 - val_loss: 0.1811 - val_accuracy: 0.9392 Epoch 00088: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0088.ckpt Epoch 89/500 625/625 [==============================] - 105s 167ms/step - loss: 0.0586 - accuracy: 0.9797 - val_loss: 0.2152 - val_accuracy: 0.9350 Epoch 00089: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0089.ckpt Epoch 90/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0523 - accuracy: 0.9813 - val_loss: 0.4403 - val_accuracy: 0.8863 Epoch 00090: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0090.ckpt Epoch 91/500 625/625 [==============================] - 109s 175ms/step - loss: 0.0483 - accuracy: 0.9828 - val_loss: 0.2882 - val_accuracy: 0.9187 Epoch 00091: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0091.ckpt Epoch 92/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0562 - accuracy: 0.9779 - val_loss: 0.2222 - val_accuracy: 0.9345 Epoch 00092: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0092.ckpt Epoch 93/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0513 - accuracy: 0.9797 - val_loss: 0.1993 - val_accuracy: 0.9310 Epoch 00093: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0093.ckpt Epoch 94/500 625/625 [==============================] - 106s 170ms/step - loss: 0.0549 - accuracy: 0.9796 - val_loss: 0.1915 - val_accuracy: 0.9477 Epoch 00094: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0094.ckpt Epoch 95/500 625/625 [==============================] - 113s 180ms/step - loss: 0.0576 - accuracy: 0.9805 - val_loss: 0.2244 - val_accuracy: 0.9463 Epoch 00095: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0095.ckpt Epoch 96/500 625/625 [==============================] - 114s 183ms/step - loss: 0.0550 - accuracy: 0.9800 - val_loss: 0.3378 - val_accuracy: 0.8985 Epoch 00096: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0096.ckpt Epoch 97/500 625/625 [==============================] - 105s 168ms/step - loss: 0.0441 - accuracy: 0.9840 - val_loss: 0.1558 - val_accuracy: 0.9473 Epoch 00097: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0097.ckpt Epoch 98/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0437 - accuracy: 0.9847 - val_loss: 0.1626 - val_accuracy: 0.9448 Epoch 00098: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0098.ckpt Epoch 99/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0464 - accuracy: 0.9832 - val_loss: 0.2103 - val_accuracy: 0.9333 Epoch 00099: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0099.ckpt Epoch 100/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0484 - accuracy: 0.9819 - val_loss: 0.1700 - val_accuracy: 0.9475 Epoch 00100: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0100.ckpt Epoch 101/500 625/625 [==============================] - 105s 168ms/step - loss: 0.0444 - accuracy: 0.9833 - val_loss: 0.2528 - val_accuracy: 0.9268 Epoch 00101: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0101.ckpt Epoch 102/500 625/625 [==============================] - 107s 171ms/step - loss: 0.0483 - accuracy: 0.9823 - val_loss: 0.2666 - val_accuracy: 0.9233 Epoch 00102: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0102.ckpt Epoch 103/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0413 - accuracy: 0.9842 - val_loss: 0.1725 - val_accuracy: 0.9490 Epoch 00103: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0103.ckpt Epoch 104/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0437 - accuracy: 0.9829 - val_loss: 0.2275 - val_accuracy: 0.9237 Epoch 00104: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0104.ckpt Epoch 105/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0682 - accuracy: 0.9772 - val_loss: 0.1648 - val_accuracy: 0.9365 Epoch 00105: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0105.ckpt Epoch 106/500 625/625 [==============================] - 105s 167ms/step - loss: 0.0876 - accuracy: 0.9676 - val_loss: 0.1563 - val_accuracy: 0.9500 Epoch 00106: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0106.ckpt Epoch 107/500 625/625 [==============================] - 106s 169ms/step - loss: 0.0443 - accuracy: 0.9831 - val_loss: 0.1679 - val_accuracy: 0.9535 Epoch 00107: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0107.ckpt Epoch 108/500 625/625 [==============================] - 105s 168ms/step - loss: 0.0406 - accuracy: 0.9861 - val_loss: 0.1549 - val_accuracy: 0.9507 Epoch 00108: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0108.ckpt Epoch 109/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0333 - accuracy: 0.9883 - val_loss: 0.2104 - val_accuracy: 0.9390 Epoch 00109: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0109.ckpt Epoch 110/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0313 - accuracy: 0.9880 - val_loss: 0.2171 - val_accuracy: 0.9352 Epoch 00110: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0110.ckpt Epoch 111/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0322 - accuracy: 0.9878 - val_loss: 0.2522 - val_accuracy: 0.9438 Epoch 00111: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0111.ckpt Epoch 112/500 625/625 [==============================] - 104s 166ms/step - loss: 0.0377 - accuracy: 0.9870 - val_loss: 0.2101 - val_accuracy: 0.9400 Epoch 00112: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0112.ckpt Epoch 113/500 625/625 [==============================] - 106s 170ms/step - loss: 0.0369 - accuracy: 0.9847 - val_loss: 0.2389 - val_accuracy: 0.9312 Epoch 00113: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0113.ckpt Epoch 114/500 625/625 [==============================] - 105s 168ms/step - loss: 0.0402 - accuracy: 0.9853 - val_loss: 0.2874 - val_accuracy: 0.9028 Epoch 00114: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0114.ckpt Epoch 115/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0387 - accuracy: 0.9862 - val_loss: 0.5950 - val_accuracy: 0.8512 Epoch 00115: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0115.ckpt Epoch 116/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0402 - accuracy: 0.9858 - val_loss: 0.1802 - val_accuracy: 0.9498 Epoch 00116: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0116.ckpt Epoch 117/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0498 - accuracy: 0.9814 - val_loss: 0.2324 - val_accuracy: 0.9330 Epoch 00117: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0117.ckpt Epoch 118/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0384 - accuracy: 0.9862 - val_loss: 0.4130 - val_accuracy: 0.8850 Epoch 00118: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0118.ckpt Epoch 119/500 625/625 [==============================] - 108s 172ms/step - loss: 0.0365 - accuracy: 0.9870 - val_loss: 0.1825 - val_accuracy: 0.9440 Epoch 00119: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0119.ckpt Epoch 120/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0365 - accuracy: 0.9856 - val_loss: 0.1991 - val_accuracy: 0.9450 Epoch 00120: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0120.ckpt Epoch 121/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0374 - accuracy: 0.9870 - val_loss: 0.2471 - val_accuracy: 0.9180 Epoch 00121: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0121.ckpt Epoch 122/500 625/625 [==============================] - 105s 167ms/step - loss: 0.0439 - accuracy: 0.9827 - val_loss: 0.2234 - val_accuracy: 0.9427 Epoch 00122: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0122.ckpt Epoch 123/500 625/625 [==============================] - 105s 167ms/step - loss: 0.0373 - accuracy: 0.9869 - val_loss: 0.2133 - val_accuracy: 0.9417 Epoch 00123: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0123.ckpt Epoch 124/500 625/625 [==============================] - 105s 169ms/step - loss: 0.0373 - accuracy: 0.9867 - val_loss: 0.1884 - val_accuracy: 0.9467 Epoch 00124: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0124.ckpt Epoch 125/500 625/625 [==============================] - 108s 172ms/step - loss: 0.0444 - accuracy: 0.9858 - val_loss: 0.2377 - val_accuracy: 0.9290 Epoch 00125: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0125.ckpt Epoch 126/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0317 - accuracy: 0.9883 - val_loss: 0.2489 - val_accuracy: 0.9258 Epoch 00126: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0126.ckpt Epoch 127/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0337 - accuracy: 0.9893 - val_loss: 0.2841 - val_accuracy: 0.9230 Epoch 00127: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0127.ckpt Epoch 128/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0359 - accuracy: 0.9858 - val_loss: 0.1829 - val_accuracy: 0.9490 Epoch 00128: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0128.ckpt Epoch 129/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0351 - accuracy: 0.9881 - val_loss: 0.1904 - val_accuracy: 0.9513 Epoch 00129: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0129.ckpt Epoch 130/500 625/625 [==============================] - 106s 170ms/step - loss: 0.0362 - accuracy: 0.9885 - val_loss: 0.2333 - val_accuracy: 0.9310 Epoch 00130: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0130.ckpt Epoch 131/500 625/625 [==============================] - 106s 170ms/step - loss: 0.0340 - accuracy: 0.9877 - val_loss: 0.1658 - val_accuracy: 0.9528 Epoch 00131: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0131.ckpt Epoch 132/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0312 - accuracy: 0.9879 - val_loss: 0.1793 - val_accuracy: 0.9438 Epoch 00132: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0132.ckpt Epoch 133/500 625/625 [==============================] - 105s 167ms/step - loss: 0.0337 - accuracy: 0.9874 - val_loss: 0.1878 - val_accuracy: 0.9425 Epoch 00133: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0133.ckpt Epoch 134/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0299 - accuracy: 0.9889 - val_loss: 0.2172 - val_accuracy: 0.9417 Epoch 00134: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0134.ckpt Epoch 135/500 625/625 [==============================] - 105s 168ms/step - loss: 0.1117 - accuracy: 0.9659 - val_loss: 0.1820 - val_accuracy: 0.9302 Epoch 00135: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0135.ckpt Epoch 136/500 625/625 [==============================] - 106s 170ms/step - loss: 0.1009 - accuracy: 0.9596 - val_loss: 0.1620 - val_accuracy: 0.9467 Epoch 00136: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0136.ckpt Epoch 137/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0517 - accuracy: 0.9825 - val_loss: 0.1605 - val_accuracy: 0.9510 Epoch 00137: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0137.ckpt Epoch 138/500 625/625 [==============================] - 105s 168ms/step - loss: 0.0361 - accuracy: 0.9871 - val_loss: 0.1805 - val_accuracy: 0.9595 Epoch 00138: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0138.ckpt Epoch 139/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0299 - accuracy: 0.9898 - val_loss: 0.2388 - val_accuracy: 0.9500 Epoch 00139: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0139.ckpt Epoch 140/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0281 - accuracy: 0.9905 - val_loss: 0.2196 - val_accuracy: 0.9465 Epoch 00140: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0140.ckpt Epoch 141/500 625/625 [==============================] - 106s 169ms/step - loss: 0.0262 - accuracy: 0.9906 - val_loss: 0.2247 - val_accuracy: 0.9455 Epoch 00141: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0141.ckpt Epoch 142/500 625/625 [==============================] - 105s 167ms/step - loss: 0.0194 - accuracy: 0.9941 - val_loss: 0.2295 - val_accuracy: 0.9485 Epoch 00142: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0142.ckpt Epoch 143/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0220 - accuracy: 0.9926 - val_loss: 0.2068 - val_accuracy: 0.9445 Epoch 00143: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0143.ckpt Epoch 144/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0244 - accuracy: 0.9909 - val_loss: 0.1596 - val_accuracy: 0.9560 Epoch 00144: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0144.ckpt Epoch 145/500 625/625 [==============================] - 105s 168ms/step - loss: 0.0262 - accuracy: 0.9913 - val_loss: 0.1860 - val_accuracy: 0.9467 Epoch 00145: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0145.ckpt Epoch 146/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0271 - accuracy: 0.9883 - val_loss: 0.3543 - val_accuracy: 0.9290 Epoch 00146: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0146.ckpt Epoch 147/500 625/625 [==============================] - 106s 170ms/step - loss: 0.0324 - accuracy: 0.9879 - val_loss: 0.3320 - val_accuracy: 0.9258 Epoch 00147: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0147.ckpt Epoch 148/500 625/625 [==============================] - 105s 168ms/step - loss: 0.0302 - accuracy: 0.9893 - val_loss: 0.3184 - val_accuracy: 0.9280 Epoch 00148: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0148.ckpt Epoch 149/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0338 - accuracy: 0.9870 - val_loss: 0.2088 - val_accuracy: 0.9442 Epoch 00149: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0149.ckpt Epoch 150/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0244 - accuracy: 0.9916 - val_loss: 0.2526 - val_accuracy: 0.9345 Epoch 00150: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0150.ckpt Epoch 151/500 625/625 [==============================] - 104s 166ms/step - loss: 0.0274 - accuracy: 0.9898 - val_loss: 0.2173 - val_accuracy: 0.9475 Epoch 00151: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0151.ckpt Epoch 152/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0278 - accuracy: 0.9908 - val_loss: 0.2885 - val_accuracy: 0.9137 Epoch 00152: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0152.ckpt Epoch 153/500 625/625 [==============================] - 106s 170ms/step - loss: 0.0315 - accuracy: 0.9892 - val_loss: 0.3286 - val_accuracy: 0.9128 Epoch 00153: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0153.ckpt Epoch 154/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0334 - accuracy: 0.9893 - val_loss: 0.2239 - val_accuracy: 0.9425 Epoch 00154: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0154.ckpt Epoch 155/500 625/625 [==============================] - 105s 167ms/step - loss: 0.0294 - accuracy: 0.9897 - val_loss: 0.5084 - val_accuracy: 0.8650 Epoch 00155: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0155.ckpt Epoch 156/500 625/625 [==============================] - 105s 167ms/step - loss: 0.0295 - accuracy: 0.9899 - val_loss: 0.1657 - val_accuracy: 0.9505 Epoch 00156: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0156.ckpt Epoch 157/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0335 - accuracy: 0.9888 - val_loss: 0.2306 - val_accuracy: 0.9417 Epoch 00157: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0157.ckpt Epoch 158/500 625/625 [==============================] - 107s 171ms/step - loss: 0.0279 - accuracy: 0.9909 - val_loss: 0.2741 - val_accuracy: 0.9287 Epoch 00158: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0158.ckpt Epoch 159/500 625/625 [==============================] - 108s 172ms/step - loss: 0.0296 - accuracy: 0.9896 - val_loss: 0.2595 - val_accuracy: 0.9352 Epoch 00159: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0159.ckpt Epoch 160/500 625/625 [==============================] - 105s 167ms/step - loss: 0.0247 - accuracy: 0.9915 - val_loss: 0.2616 - val_accuracy: 0.9405 Epoch 00160: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0160.ckpt Epoch 161/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0260 - accuracy: 0.9927 - val_loss: 0.2511 - val_accuracy: 0.9283 Epoch 00161: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0161.ckpt Epoch 162/500 625/625 [==============================] - 105s 167ms/step - loss: 0.0268 - accuracy: 0.9902 - val_loss: 0.2517 - val_accuracy: 0.9427 Epoch 00162: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0162.ckpt Epoch 163/500 625/625 [==============================] - 105s 167ms/step - loss: 0.0316 - accuracy: 0.9891 - val_loss: 0.1930 - val_accuracy: 0.9457 Epoch 00163: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0163.ckpt Epoch 164/500 625/625 [==============================] - 106s 170ms/step - loss: 0.0258 - accuracy: 0.9900 - val_loss: 0.2445 - val_accuracy: 0.9440 Epoch 00164: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0164.ckpt Epoch 165/500 625/625 [==============================] - 105s 167ms/step - loss: 0.0284 - accuracy: 0.9911 - val_loss: 0.2076 - val_accuracy: 0.9450 Epoch 00165: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0165.ckpt Epoch 166/500 625/625 [==============================] - 105s 167ms/step - loss: 0.0291 - accuracy: 0.9890 - val_loss: 0.2824 - val_accuracy: 0.9262 Epoch 00166: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0166.ckpt Epoch 167/500 625/625 [==============================] - 104s 166ms/step - loss: 0.0269 - accuracy: 0.9907 - val_loss: 0.2446 - val_accuracy: 0.9333 Epoch 00167: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0167.ckpt Epoch 168/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0282 - accuracy: 0.9898 - val_loss: 0.2266 - val_accuracy: 0.9333 Epoch 00168: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0168.ckpt Epoch 169/500 625/625 [==============================] - 105s 169ms/step - loss: 0.0255 - accuracy: 0.9920 - val_loss: 0.4030 - val_accuracy: 0.9230 Epoch 00169: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0169.ckpt Epoch 170/500 625/625 [==============================] - 107s 171ms/step - loss: 0.0224 - accuracy: 0.9930 - val_loss: 0.2135 - val_accuracy: 0.9427 Epoch 00170: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0170.ckpt Epoch 171/500 625/625 [==============================] - 105s 167ms/step - loss: 0.0276 - accuracy: 0.9907 - val_loss: 0.5118 - val_accuracy: 0.8662 Epoch 00171: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0171.ckpt Epoch 172/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0265 - accuracy: 0.9911 - val_loss: 0.2305 - val_accuracy: 0.9475 Epoch 00172: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0172.ckpt Epoch 173/500 625/625 [==============================] - 105s 167ms/step - loss: 0.0224 - accuracy: 0.9909 - val_loss: 0.2885 - val_accuracy: 0.9295 Epoch 00173: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0173.ckpt Epoch 174/500 625/625 [==============================] - 105s 167ms/step - loss: 0.0259 - accuracy: 0.9907 - val_loss: 0.5019 - val_accuracy: 0.8685 Epoch 00174: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0174.ckpt Epoch 175/500 625/625 [==============================] - 106s 170ms/step - loss: 0.0358 - accuracy: 0.9866 - val_loss: 0.3013 - val_accuracy: 0.9358 Epoch 00175: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0175.ckpt Epoch 176/500 625/625 [==============================] - 105s 168ms/step - loss: 0.0221 - accuracy: 0.9924 - val_loss: 0.3179 - val_accuracy: 0.9240 Epoch 00176: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0176.ckpt Epoch 177/500 625/625 [==============================] - 105s 168ms/step - loss: 0.0257 - accuracy: 0.9905 - val_loss: 0.2625 - val_accuracy: 0.9335 Epoch 00177: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0177.ckpt Epoch 178/500 625/625 [==============================] - 105s 167ms/step - loss: 0.0308 - accuracy: 0.9894 - val_loss: 0.3477 - val_accuracy: 0.8633 Epoch 00178: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0178.ckpt Epoch 179/500 625/625 [==============================] - 105s 167ms/step - loss: 0.1004 - accuracy: 0.9629 - val_loss: 0.2047 - val_accuracy: 0.9400 Epoch 00179: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0179.ckpt Epoch 180/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0320 - accuracy: 0.9890 - val_loss: 0.6238 - val_accuracy: 0.9398 Epoch 00180: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0180.ckpt Epoch 181/500 625/625 [==============================] - 107s 171ms/step - loss: 0.0267 - accuracy: 0.9913 - val_loss: 0.2127 - val_accuracy: 0.9520 Epoch 00181: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0181.ckpt Epoch 182/500 625/625 [==============================] - 105s 168ms/step - loss: 0.0192 - accuracy: 0.9941 - val_loss: 0.2383 - val_accuracy: 0.9423 Epoch 00182: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0182.ckpt Epoch 183/500 625/625 [==============================] - 105s 167ms/step - loss: 0.0184 - accuracy: 0.9931 - val_loss: 0.3910 - val_accuracy: 0.9463 Epoch 00183: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0183.ckpt Epoch 184/500 625/625 [==============================] - 104s 167ms/step - loss: 0.0208 - accuracy: 0.9929 - val_loss: 0.2701 - val_accuracy: 0.9390 Epoch 00184: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0184.ckpt Epoch 185/500 625/625 [==============================] - 105s 167ms/step - loss: 0.0216 - accuracy: 0.9928 - val_loss: 0.2123 - val_accuracy: 0.9460 Epoch 00185: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0185.ckpt Epoch 186/500 625/625 [==============================] - 105s 168ms/step - loss: 0.0296 - accuracy: 0.9904 - val_loss: 0.3197 - val_accuracy: 0.9185 Epoch 00186: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0186.ckpt Epoch 187/500 625/625 [==============================] - 107s 171ms/step - loss: 0.0278 - accuracy: 0.9900 - val_loss: 0.2555 - val_accuracy: 0.9153 Epoch 00187: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0187.ckpt Epoch 188/500 625/625 [==============================] - 105s 167ms/step - loss: 0.0258 - accuracy: 0.9913 - val_loss: 0.2735 - val_accuracy: 0.9465 Epoch 00188: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0188.ckpt
plot_model__hist(ResNet50V2_model_adam_crawl_hist)
loss_adam,acc_adam = ResNet50V2_model_adam_crawl.evaluate(test_set, verbose=2)
print("ResNet50V2_model(Adam) 이미지 크롤링,증강 후 모델의 정확도: {:5.2f}%".format(100*acc_adam))
print("ResNet50V2_model(Adam) 이미지 크롤링,증강 후 모델의 Loss: {}".format(loss_adam))
<Figure size 432x288 with 0 Axes>
100/100 - 2s - loss: 0.2050 - accuracy: 0.9610 ResNet50V2_model(Adam) 이미지 크롤링,증강 후 모델의 정확도: 96.10% ResNet50V2_model(Adam) 이미지 크롤링,증강 후 모델의 Loss: 0.20497991144657135
train_set, val_set, test_set = get_dataset(aug=True,size=128)
# SGD 모델
ResNet50V2_model_sgd_aug = keras.Sequential([
get_ResNet50V2(size=128,trainable=True), # 백본 학습 가능하게 설정
Dense(256, activation='relu'),
Dropout(0.5),
Dense(128, activation='relu'),
Dropout(0.25),
Dense(1,activation='sigmoid')
])
# 가중치 저장경로 변경
checkpoint_path = r"D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_aug/cp-{epoch:04d}.ckpt"
callbacks = get_callbacks(checkpoint_path,patience=5)#동일 조건
opt = SGD(lr=0.01, decay=1e-6, momentum=0.001,nesterov=True)
ResNet50V2_model_sgd_aug.compile(optimizer=opt, loss='binary_crossentropy',metrics=['accuracy'])
ResNet50V2_model_sgd_aug_hist = ResNet50V2_model_sgd_aug.fit(train_set,
validation_data=val_set,
epochs=100,
callbacks = [callbacks])
Found 20000 images belonging to 2 classes. Found 4000 images belonging to 2 classes. Found 1000 images belonging to 2 classes. Epoch 1/100 625/625 [==============================] - 99s 152ms/step - loss: 0.5215 - accuracy: 0.7165 - val_loss: 0.2015 - val_accuracy: 0.9220 Epoch 00001: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_aug\cp-0001.ckpt Epoch 2/100 625/625 [==============================] - 96s 153ms/step - loss: 0.2286 - accuracy: 0.9050 - val_loss: 0.1621 - val_accuracy: 0.9352 Epoch 00002: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_aug\cp-0002.ckpt Epoch 3/100 625/625 [==============================] - 96s 153ms/step - loss: 0.1743 - accuracy: 0.9326 - val_loss: 0.1187 - val_accuracy: 0.9528 Epoch 00003: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_aug\cp-0003.ckpt Epoch 4/100 625/625 [==============================] - 96s 153ms/step - loss: 0.1478 - accuracy: 0.9438 - val_loss: 0.1145 - val_accuracy: 0.9550 Epoch 00004: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_aug\cp-0004.ckpt Epoch 5/100 625/625 [==============================] - 100s 160ms/step - loss: 0.1345 - accuracy: 0.9465 - val_loss: 0.1173 - val_accuracy: 0.9538 Epoch 00005: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_aug\cp-0005.ckpt Epoch 6/100 625/625 [==============================] - 96s 153ms/step - loss: 0.1205 - accuracy: 0.9537 - val_loss: 0.0977 - val_accuracy: 0.9603 Epoch 00006: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_aug\cp-0006.ckpt Epoch 7/100 625/625 [==============================] - 96s 153ms/step - loss: 0.1042 - accuracy: 0.9591 - val_loss: 0.1013 - val_accuracy: 0.9622 Epoch 00007: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_aug\cp-0007.ckpt Epoch 8/100 625/625 [==============================] - 96s 154ms/step - loss: 0.0893 - accuracy: 0.9652 - val_loss: 0.1345 - val_accuracy: 0.9473 Epoch 00008: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_aug\cp-0008.ckpt Epoch 9/100 625/625 [==============================] - 95s 153ms/step - loss: 0.0836 - accuracy: 0.9686 - val_loss: 0.1029 - val_accuracy: 0.9640 Epoch 00009: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_aug\cp-0009.ckpt Epoch 10/100 625/625 [==============================] - 96s 153ms/step - loss: 0.0759 - accuracy: 0.9706 - val_loss: 0.1140 - val_accuracy: 0.9610 Epoch 00010: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_aug\cp-0010.ckpt Epoch 11/100 625/625 [==============================] - 98s 157ms/step - loss: 0.0731 - accuracy: 0.9731 - val_loss: 0.1248 - val_accuracy: 0.9500 Epoch 00011: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_aug\cp-0011.ckpt Epoch 12/100 625/625 [==============================] - 96s 154ms/step - loss: 0.0683 - accuracy: 0.9732 - val_loss: 0.1319 - val_accuracy: 0.9532 Epoch 00012: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_aug\cp-0012.ckpt Epoch 13/100 625/625 [==============================] - 96s 153ms/step - loss: 0.0621 - accuracy: 0.9757 - val_loss: 0.1109 - val_accuracy: 0.9572 Epoch 00013: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_aug\cp-0013.ckpt Epoch 14/100 625/625 [==============================] - 95s 152ms/step - loss: 0.0532 - accuracy: 0.9812 - val_loss: 0.1416 - val_accuracy: 0.9523 Epoch 00014: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_aug\cp-0014.ckpt
plot_model__hist(ResNet50V2_model_sgd_aug_hist)
loss_sgd_aug,acc_sgd_aug = ResNet50V2_model_sgd_aug.evaluate(test_set, verbose=2)
print("ResNet50V2_model(SGD) 이미지 증강 후 모델의 정확도: {:5.2f}%".format(100*acc_sgd_aug))
print("ResNet50V2_model(SGD) 이미지 증강 후 모델의 Loss: {}".format(loss_sgd_aug))
<Figure size 432x288 with 0 Axes>
100/100 - 2s - loss: 0.1543 - accuracy: 0.9420 ResNet50V2_model(SGD) 이미지 증강 후 모델의 정확도: 94.20% ResNet50V2_model(SGD) 이미지 증강 후 모델의 Loss: 0.15427251160144806
# Adam 모델
ResNet50V2_model_adam_aug = keras.Sequential([
get_ResNet50V2(size=128,trainable=True), # 백본 학습 가능하게 설정
Dense(256, activation='relu'),
Dropout(0.5),
Dense(128, activation='relu'),
Dropout(0.25),
Dense(1,activation='sigmoid')
])
# 가중치 저장경로 변경
checkpoint_path = r"D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam/cp-{epoch:04d}.ckpt"
callbacks = get_callbacks(checkpoint_path,patience=50)#동일 조건
opt = Adam(learning_rate=0.001)
ResNet50V2_model_adam_aug.compile(optimizer=opt, loss='binary_crossentropy',metrics=['accuracy'])
ResNet50V2_model_adam_aug_hist = ResNet50V2_model_adam_aug.fit(train_set,
validation_data=val_set,
epochs=500,
callbacks = [callbacks])
Epoch 1/500 625/625 [==============================] - 99s 152ms/step - loss: 0.6789 - accuracy: 0.6105 - val_loss: 13.8396 - val_accuracy: 0.5213 Epoch 00001: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0001.ckpt Epoch 2/500 625/625 [==============================] - 95s 152ms/step - loss: 0.5492 - accuracy: 0.7288 - val_loss: 7.0202 - val_accuracy: 0.5680 Epoch 00002: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0002.ckpt Epoch 3/500 625/625 [==============================] - 97s 155ms/step - loss: 0.5217 - accuracy: 0.7530 - val_loss: 0.9208 - val_accuracy: 0.6313 Epoch 00003: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0003.ckpt Epoch 4/500 625/625 [==============================] - 95s 152ms/step - loss: 0.4469 - accuracy: 0.8005 - val_loss: 0.8475 - val_accuracy: 0.7092 Epoch 00004: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0004.ckpt Epoch 5/500 625/625 [==============================] - 95s 152ms/step - loss: 0.3896 - accuracy: 0.8332 - val_loss: 0.3060 - val_accuracy: 0.8700 Epoch 00005: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0005.ckpt Epoch 6/500 625/625 [==============================] - 95s 151ms/step - loss: 0.3368 - accuracy: 0.8559 - val_loss: 0.6258 - val_accuracy: 0.7903 Epoch 00006: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0006.ckpt Epoch 7/500 625/625 [==============================] - 95s 152ms/step - loss: 0.3508 - accuracy: 0.8521 - val_loss: 0.5851 - val_accuracy: 0.7055 Epoch 00007: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0007.ckpt Epoch 8/500 625/625 [==============================] - 95s 151ms/step - loss: 0.3153 - accuracy: 0.8658 - val_loss: 0.5025 - val_accuracy: 0.7408 Epoch 00008: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0008.ckpt Epoch 9/500 625/625 [==============================] - 98s 157ms/step - loss: 0.3448 - accuracy: 0.8564 - val_loss: 0.4017 - val_accuracy: 0.8125 Epoch 00009: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0009.ckpt Epoch 10/500 625/625 [==============================] - 96s 153ms/step - loss: 0.2711 - accuracy: 0.8854 - val_loss: 0.3517 - val_accuracy: 0.8388 Epoch 00010: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0010.ckpt Epoch 11/500 625/625 [==============================] - 95s 151ms/step - loss: 0.2741 - accuracy: 0.8858 - val_loss: 0.2661 - val_accuracy: 0.8900 Epoch 00011: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0011.ckpt Epoch 12/500 625/625 [==============================] - 95s 152ms/step - loss: 0.2697 - accuracy: 0.8905 - val_loss: 0.2745 - val_accuracy: 0.8815 Epoch 00012: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0012.ckpt Epoch 13/500 625/625 [==============================] - 95s 151ms/step - loss: 0.2429 - accuracy: 0.8985 - val_loss: 0.5356 - val_accuracy: 0.7853 Epoch 00013: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0013.ckpt Epoch 14/500 625/625 [==============================] - 95s 152ms/step - loss: 0.2283 - accuracy: 0.9077 - val_loss: 0.2876 - val_accuracy: 0.8813 Epoch 00014: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0014.ckpt Epoch 15/500 625/625 [==============================] - 97s 154ms/step - loss: 0.2241 - accuracy: 0.9091 - val_loss: 0.2593 - val_accuracy: 0.8888 Epoch 00015: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0015.ckpt Epoch 16/500 625/625 [==============================] - 95s 152ms/step - loss: 0.2103 - accuracy: 0.9143 - val_loss: 0.3032 - val_accuracy: 0.8635 Epoch 00016: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0016.ckpt Epoch 17/500 625/625 [==============================] - 95s 152ms/step - loss: 0.2527 - accuracy: 0.9006 - val_loss: 0.2277 - val_accuracy: 0.8988 Epoch 00017: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0017.ckpt Epoch 18/500 625/625 [==============================] - 95s 152ms/step - loss: 0.2186 - accuracy: 0.9115 - val_loss: 0.3183 - val_accuracy: 0.8505 Epoch 00018: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0018.ckpt Epoch 19/500 625/625 [==============================] - 95s 152ms/step - loss: 0.2083 - accuracy: 0.9138 - val_loss: 0.1932 - val_accuracy: 0.9172 Epoch 00019: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0019.ckpt Epoch 20/500 625/625 [==============================] - 95s 152ms/step - loss: 0.2141 - accuracy: 0.9144 - val_loss: 0.5673 - val_accuracy: 0.6975 Epoch 00020: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0020.ckpt Epoch 21/500 625/625 [==============================] - 95s 152ms/step - loss: 0.2128 - accuracy: 0.9120 - val_loss: 0.2766 - val_accuracy: 0.8960 Epoch 00021: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0021.ckpt Epoch 22/500 625/625 [==============================] - 98s 156ms/step - loss: 0.1808 - accuracy: 0.9272 - val_loss: 0.3229 - val_accuracy: 0.8612 Epoch 00022: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0022.ckpt Epoch 23/500 625/625 [==============================] - 95s 152ms/step - loss: 0.1749 - accuracy: 0.9289 - val_loss: 0.7760 - val_accuracy: 0.7032 Epoch 00023: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0023.ckpt Epoch 24/500 625/625 [==============================] - 95s 152ms/step - loss: 0.1776 - accuracy: 0.9304 - val_loss: 0.3591 - val_accuracy: 0.8585 Epoch 00024: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0024.ckpt Epoch 25/500 625/625 [==============================] - 95s 151ms/step - loss: 0.1628 - accuracy: 0.9331 - val_loss: 0.4409 - val_accuracy: 0.8123 Epoch 00025: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0025.ckpt Epoch 26/500 625/625 [==============================] - 95s 151ms/step - loss: 0.2411 - accuracy: 0.9035 - val_loss: 0.2518 - val_accuracy: 0.8865 Epoch 00026: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0026.ckpt Epoch 27/500 625/625 [==============================] - 95s 152ms/step - loss: 0.1962 - accuracy: 0.9215 - val_loss: 0.2472 - val_accuracy: 0.8935 Epoch 00027: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0027.ckpt Epoch 28/500 625/625 [==============================] - 98s 156ms/step - loss: 0.1549 - accuracy: 0.9393 - val_loss: 0.4941 - val_accuracy: 0.7818 Epoch 00028: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0028.ckpt Epoch 29/500 625/625 [==============================] - 97s 156ms/step - loss: 0.1733 - accuracy: 0.9333 - val_loss: 0.1753 - val_accuracy: 0.9323 Epoch 00029: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0029.ckpt Epoch 30/500 625/625 [==============================] - 94s 151ms/step - loss: 0.1502 - accuracy: 0.9385 - val_loss: 0.1724 - val_accuracy: 0.9285 Epoch 00030: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0030.ckpt Epoch 31/500 625/625 [==============================] - 95s 152ms/step - loss: 0.1484 - accuracy: 0.9433 - val_loss: 0.1920 - val_accuracy: 0.9287 Epoch 00031: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0031.ckpt Epoch 32/500 625/625 [==============================] - 95s 151ms/step - loss: 0.1501 - accuracy: 0.9396 - val_loss: 0.5099 - val_accuracy: 0.8202 Epoch 00032: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0032.ckpt Epoch 33/500 625/625 [==============================] - 95s 151ms/step - loss: 0.1544 - accuracy: 0.9357 - val_loss: 0.2111 - val_accuracy: 0.9153 Epoch 00033: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0033.ckpt Epoch 34/500 625/625 [==============================] - 97s 155ms/step - loss: 0.1358 - accuracy: 0.9460 - val_loss: 0.1870 - val_accuracy: 0.9208 Epoch 00034: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0034.ckpt Epoch 35/500 625/625 [==============================] - 95s 153ms/step - loss: 0.1363 - accuracy: 0.9478 - val_loss: 0.2436 - val_accuracy: 0.9062 Epoch 00035: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0035.ckpt Epoch 36/500 625/625 [==============================] - 95s 152ms/step - loss: 0.1360 - accuracy: 0.9473 - val_loss: 0.1595 - val_accuracy: 0.9330 Epoch 00036: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0036.ckpt Epoch 37/500 625/625 [==============================] - 95s 152ms/step - loss: 0.1290 - accuracy: 0.9482 - val_loss: 0.1550 - val_accuracy: 0.9380 Epoch 00037: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0037.ckpt Epoch 38/500 625/625 [==============================] - 95s 152ms/step - loss: 0.1242 - accuracy: 0.9511 - val_loss: 0.1919 - val_accuracy: 0.9165 Epoch 00038: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0038.ckpt Epoch 39/500 625/625 [==============================] - 95s 152ms/step - loss: 0.1219 - accuracy: 0.9543 - val_loss: 0.1999 - val_accuracy: 0.9168 Epoch 00039: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0039.ckpt Epoch 40/500 625/625 [==============================] - 98s 156ms/step - loss: 0.1747 - accuracy: 0.9322 - val_loss: 0.1791 - val_accuracy: 0.9252 Epoch 00040: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0040.ckpt Epoch 41/500 625/625 [==============================] - 95s 152ms/step - loss: 0.1309 - accuracy: 0.9497 - val_loss: 0.2490 - val_accuracy: 0.8940 Epoch 00041: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0041.ckpt Epoch 42/500 625/625 [==============================] - 95s 153ms/step - loss: 0.2099 - accuracy: 0.9164 - val_loss: 0.2947 - val_accuracy: 0.8790 Epoch 00042: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0042.ckpt Epoch 43/500 625/625 [==============================] - 95s 152ms/step - loss: 0.1785 - accuracy: 0.9285 - val_loss: 0.1518 - val_accuracy: 0.9367 Epoch 00043: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0043.ckpt Epoch 44/500 625/625 [==============================] - 95s 151ms/step - loss: 0.1281 - accuracy: 0.9487 - val_loss: 0.1881 - val_accuracy: 0.9205 Epoch 00044: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0044.ckpt Epoch 45/500 625/625 [==============================] - 95s 152ms/step - loss: 0.1173 - accuracy: 0.9542 - val_loss: 0.1499 - val_accuracy: 0.9423 Epoch 00045: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0045.ckpt Epoch 46/500 625/625 [==============================] - 96s 154ms/step - loss: 0.1091 - accuracy: 0.9581 - val_loss: 0.1740 - val_accuracy: 0.9373 Epoch 00046: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0046.ckpt Epoch 47/500 625/625 [==============================] - 96s 154ms/step - loss: 0.1065 - accuracy: 0.9584 - val_loss: 0.1693 - val_accuracy: 0.9375 Epoch 00047: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0047.ckpt Epoch 48/500 625/625 [==============================] - 95s 152ms/step - loss: 0.1092 - accuracy: 0.9571 - val_loss: 0.1878 - val_accuracy: 0.9333 Epoch 00048: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0048.ckpt Epoch 49/500 625/625 [==============================] - 95s 152ms/step - loss: 0.1055 - accuracy: 0.9604 - val_loss: 0.1727 - val_accuracy: 0.9317 Epoch 00049: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0049.ckpt Epoch 50/500 625/625 [==============================] - 95s 152ms/step - loss: 0.1078 - accuracy: 0.9588 - val_loss: 0.1579 - val_accuracy: 0.9330 Epoch 00050: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0050.ckpt Epoch 51/500 625/625 [==============================] - 95s 152ms/step - loss: 0.1029 - accuracy: 0.9600 - val_loss: 0.1902 - val_accuracy: 0.9183 Epoch 00051: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0051.ckpt Epoch 52/500 625/625 [==============================] - 95s 152ms/step - loss: 0.1052 - accuracy: 0.9602 - val_loss: 0.1569 - val_accuracy: 0.9410 Epoch 00052: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0052.ckpt Epoch 53/500 625/625 [==============================] - 97s 156ms/step - loss: 0.1019 - accuracy: 0.9618 - val_loss: 0.2001 - val_accuracy: 0.9205 Epoch 00053: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0053.ckpt Epoch 54/500 625/625 [==============================] - 95s 152ms/step - loss: 0.1088 - accuracy: 0.9579 - val_loss: 0.1972 - val_accuracy: 0.9220 Epoch 00054: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0054.ckpt Epoch 55/500 625/625 [==============================] - 95s 152ms/step - loss: 0.0994 - accuracy: 0.9586 - val_loss: 0.2066 - val_accuracy: 0.9170 Epoch 00055: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0055.ckpt Epoch 56/500 625/625 [==============================] - 95s 152ms/step - loss: 0.1057 - accuracy: 0.9606 - val_loss: 0.1782 - val_accuracy: 0.9287 Epoch 00056: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0056.ckpt Epoch 57/500 625/625 [==============================] - 95s 153ms/step - loss: 0.0876 - accuracy: 0.9657 - val_loss: 0.1793 - val_accuracy: 0.9222 Epoch 00057: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0057.ckpt Epoch 58/500 625/625 [==============================] - 95s 151ms/step - loss: 0.0907 - accuracy: 0.9650 - val_loss: 0.1720 - val_accuracy: 0.9350 Epoch 00058: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0058.ckpt Epoch 59/500 625/625 [==============================] - 97s 156ms/step - loss: 0.1210 - accuracy: 0.9556 - val_loss: 0.1775 - val_accuracy: 0.9352 Epoch 00059: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0059.ckpt Epoch 60/500 625/625 [==============================] - 95s 152ms/step - loss: 0.0885 - accuracy: 0.9666 - val_loss: 0.1713 - val_accuracy: 0.9342 Epoch 00060: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0060.ckpt Epoch 61/500 625/625 [==============================] - 95s 152ms/step - loss: 0.0864 - accuracy: 0.9656 - val_loss: 0.1683 - val_accuracy: 0.9310 Epoch 00061: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0061.ckpt Epoch 62/500 625/625 [==============================] - 95s 152ms/step - loss: 0.0864 - accuracy: 0.9679 - val_loss: 0.1734 - val_accuracy: 0.9310 Epoch 00062: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0062.ckpt Epoch 63/500 625/625 [==============================] - 95s 152ms/step - loss: 0.0905 - accuracy: 0.9647 - val_loss: 0.1851 - val_accuracy: 0.9367 Epoch 00063: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0063.ckpt Epoch 64/500 625/625 [==============================] - 95s 152ms/step - loss: 0.1040 - accuracy: 0.9622 - val_loss: 0.2076 - val_accuracy: 0.9227 Epoch 00064: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0064.ckpt Epoch 65/500 625/625 [==============================] - 98s 157ms/step - loss: 0.0839 - accuracy: 0.9687 - val_loss: 0.1538 - val_accuracy: 0.9430 Epoch 00065: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0065.ckpt Epoch 66/500 625/625 [==============================] - 98s 156ms/step - loss: 0.0804 - accuracy: 0.9701 - val_loss: 0.1949 - val_accuracy: 0.9252 Epoch 00066: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0066.ckpt Epoch 67/500 625/625 [==============================] - 95s 152ms/step - loss: 0.0796 - accuracy: 0.9683 - val_loss: 0.2779 - val_accuracy: 0.9040 Epoch 00067: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0067.ckpt Epoch 68/500 625/625 [==============================] - 95s 152ms/step - loss: 0.0774 - accuracy: 0.9710 - val_loss: 0.1928 - val_accuracy: 0.9250 Epoch 00068: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0068.ckpt Epoch 69/500 625/625 [==============================] - 95s 152ms/step - loss: 0.0770 - accuracy: 0.9703 - val_loss: 0.1993 - val_accuracy: 0.9243 Epoch 00069: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0069.ckpt Epoch 70/500 625/625 [==============================] - 95s 152ms/step - loss: 0.0740 - accuracy: 0.9722 - val_loss: 7.0663 - val_accuracy: 0.6507 Epoch 00070: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0070.ckpt Epoch 71/500 625/625 [==============================] - 97s 156ms/step - loss: 0.1479 - accuracy: 0.9413 - val_loss: 0.1738 - val_accuracy: 0.9415 Epoch 00071: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0071.ckpt Epoch 72/500 625/625 [==============================] - 96s 153ms/step - loss: 0.0792 - accuracy: 0.9718 - val_loss: 0.1860 - val_accuracy: 0.9258 Epoch 00072: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0072.ckpt Epoch 73/500 625/625 [==============================] - 95s 153ms/step - loss: 0.0742 - accuracy: 0.9718 - val_loss: 0.1429 - val_accuracy: 0.9467 Epoch 00073: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0073.ckpt Epoch 74/500 625/625 [==============================] - 95s 152ms/step - loss: 0.0636 - accuracy: 0.9786 - val_loss: 0.2485 - val_accuracy: 0.9193 Epoch 00074: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0074.ckpt Epoch 75/500 625/625 [==============================] - 95s 152ms/step - loss: 0.0682 - accuracy: 0.9751 - val_loss: 0.1444 - val_accuracy: 0.9517 Epoch 00075: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0075.ckpt Epoch 76/500 625/625 [==============================] - 95s 152ms/step - loss: 0.0680 - accuracy: 0.9754 - val_loss: 0.1696 - val_accuracy: 0.9450 Epoch 00076: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0076.ckpt Epoch 77/500 625/625 [==============================] - 96s 154ms/step - loss: 0.0728 - accuracy: 0.9746 - val_loss: 0.1712 - val_accuracy: 0.9342 Epoch 00077: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0077.ckpt Epoch 78/500 625/625 [==============================] - 98s 156ms/step - loss: 0.0686 - accuracy: 0.9752 - val_loss: 0.1518 - val_accuracy: 0.9463 Epoch 00078: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0078.ckpt Epoch 79/500 625/625 [==============================] - 95s 152ms/step - loss: 0.0634 - accuracy: 0.9757 - val_loss: 0.2237 - val_accuracy: 0.9047 Epoch 00079: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0079.ckpt Epoch 80/500 625/625 [==============================] - 96s 153ms/step - loss: 0.0659 - accuracy: 0.9747 - val_loss: 0.2143 - val_accuracy: 0.9277 Epoch 00080: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0080.ckpt Epoch 81/500 625/625 [==============================] - 95s 152ms/step - loss: 0.0617 - accuracy: 0.9772 - val_loss: 0.2300 - val_accuracy: 0.9143 Epoch 00081: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0081.ckpt Epoch 82/500 625/625 [==============================] - 95s 152ms/step - loss: 0.0693 - accuracy: 0.9743 - val_loss: 0.1865 - val_accuracy: 0.9302 Epoch 00082: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0082.ckpt Epoch 83/500 625/625 [==============================] - 95s 152ms/step - loss: 0.0601 - accuracy: 0.9770 - val_loss: 0.1918 - val_accuracy: 0.9317 Epoch 00083: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0083.ckpt Epoch 84/500 625/625 [==============================] - 101s 161ms/step - loss: 0.0622 - accuracy: 0.9769 - val_loss: 0.1557 - val_accuracy: 0.9445 Epoch 00084: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0084.ckpt Epoch 85/500 625/625 [==============================] - 99s 158ms/step - loss: 0.0598 - accuracy: 0.9773 - val_loss: 0.3101 - val_accuracy: 0.8988 Epoch 00085: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0085.ckpt Epoch 86/500 625/625 [==============================] - 96s 154ms/step - loss: 0.0624 - accuracy: 0.9757 - val_loss: 0.2430 - val_accuracy: 0.9245 Epoch 00086: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0086.ckpt Epoch 87/500 625/625 [==============================] - 96s 153ms/step - loss: 0.0593 - accuracy: 0.9766 - val_loss: 0.2724 - val_accuracy: 0.9128 Epoch 00087: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0087.ckpt Epoch 88/500 625/625 [==============================] - 96s 154ms/step - loss: 0.0649 - accuracy: 0.9764 - val_loss: 0.1770 - val_accuracy: 0.9333 Epoch 00088: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0088.ckpt Epoch 89/500 625/625 [==============================] - 97s 155ms/step - loss: 0.0584 - accuracy: 0.9791 - val_loss: 0.2046 - val_accuracy: 0.9367 Epoch 00089: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0089.ckpt Epoch 90/500 625/625 [==============================] - 106s 169ms/step - loss: 0.0577 - accuracy: 0.9796 - val_loss: 0.2203 - val_accuracy: 0.9202 Epoch 00090: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0090.ckpt Epoch 91/500 625/625 [==============================] - 95s 152ms/step - loss: 0.0630 - accuracy: 0.9771 - val_loss: 0.2010 - val_accuracy: 0.9355 Epoch 00091: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0091.ckpt Epoch 92/500 625/625 [==============================] - 95s 151ms/step - loss: 0.0508 - accuracy: 0.9789 - val_loss: 0.1837 - val_accuracy: 0.9385 Epoch 00092: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0092.ckpt Epoch 93/500 625/625 [==============================] - 95s 152ms/step - loss: 0.0530 - accuracy: 0.9793 - val_loss: 0.1845 - val_accuracy: 0.9435 Epoch 00093: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0093.ckpt Epoch 94/500 625/625 [==============================] - 95s 151ms/step - loss: 0.0511 - accuracy: 0.9814 - val_loss: 0.2883 - val_accuracy: 0.8997 Epoch 00094: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0094.ckpt Epoch 95/500 625/625 [==============================] - 95s 152ms/step - loss: 0.0492 - accuracy: 0.9818 - val_loss: 0.1858 - val_accuracy: 0.9317 Epoch 00095: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0095.ckpt Epoch 96/500 625/625 [==============================] - 98s 156ms/step - loss: 0.0569 - accuracy: 0.9785 - val_loss: 0.2229 - val_accuracy: 0.9283 Epoch 00096: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0096.ckpt Epoch 97/500 625/625 [==============================] - 95s 152ms/step - loss: 0.0498 - accuracy: 0.9823 - val_loss: 0.1728 - val_accuracy: 0.9373 Epoch 00097: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0097.ckpt Epoch 98/500 625/625 [==============================] - 95s 152ms/step - loss: 0.0472 - accuracy: 0.9825 - val_loss: 0.2010 - val_accuracy: 0.9370 Epoch 00098: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0098.ckpt Epoch 99/500 625/625 [==============================] - 95s 152ms/step - loss: 0.0571 - accuracy: 0.9801 - val_loss: 0.2070 - val_accuracy: 0.9222 Epoch 00099: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0099.ckpt Epoch 100/500 625/625 [==============================] - 95s 152ms/step - loss: 0.0498 - accuracy: 0.9828 - val_loss: 0.2027 - val_accuracy: 0.9452 Epoch 00100: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0100.ckpt Epoch 101/500 625/625 [==============================] - 95s 152ms/step - loss: 0.0494 - accuracy: 0.9803 - val_loss: 0.1947 - val_accuracy: 0.9243 Epoch 00101: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0101.ckpt Epoch 102/500 625/625 [==============================] - 97s 155ms/step - loss: 0.0520 - accuracy: 0.9810 - val_loss: 0.1659 - val_accuracy: 0.9435 Epoch 00102: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0102.ckpt Epoch 103/500 625/625 [==============================] - 98s 156ms/step - loss: 0.0467 - accuracy: 0.9834 - val_loss: 0.3354 - val_accuracy: 0.8978 Epoch 00103: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0103.ckpt Epoch 104/500 625/625 [==============================] - 96s 153ms/step - loss: 0.0508 - accuracy: 0.9812 - val_loss: 0.5619 - val_accuracy: 0.8360 Epoch 00104: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0104.ckpt Epoch 105/500 625/625 [==============================] - 95s 152ms/step - loss: 0.0493 - accuracy: 0.9832 - val_loss: 0.3258 - val_accuracy: 0.8650 Epoch 00105: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0105.ckpt Epoch 106/500 625/625 [==============================] - 95s 152ms/step - loss: 0.0466 - accuracy: 0.9829 - val_loss: 0.2874 - val_accuracy: 0.9273 Epoch 00106: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0106.ckpt Epoch 107/500 625/625 [==============================] - 95s 152ms/step - loss: 0.0481 - accuracy: 0.9830 - val_loss: 0.1911 - val_accuracy: 0.9355 Epoch 00107: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0107.ckpt Epoch 108/500 625/625 [==============================] - 96s 154ms/step - loss: 0.0463 - accuracy: 0.9820 - val_loss: 0.1735 - val_accuracy: 0.9485 Epoch 00108: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0108.ckpt Epoch 109/500 625/625 [==============================] - 96s 153ms/step - loss: 0.0460 - accuracy: 0.9841 - val_loss: 0.2539 - val_accuracy: 0.9185 Epoch 00109: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0109.ckpt Epoch 110/500 625/625 [==============================] - 95s 152ms/step - loss: 0.0454 - accuracy: 0.9823 - val_loss: 0.2024 - val_accuracy: 0.9345 Epoch 00110: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0110.ckpt Epoch 111/500 625/625 [==============================] - 95s 152ms/step - loss: 0.0396 - accuracy: 0.9858 - val_loss: 0.1786 - val_accuracy: 0.9442 Epoch 00111: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0111.ckpt Epoch 112/500 625/625 [==============================] - 94s 151ms/step - loss: 0.0432 - accuracy: 0.9844 - val_loss: 0.1809 - val_accuracy: 0.9377 Epoch 00112: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0112.ckpt Epoch 113/500 625/625 [==============================] - 95s 151ms/step - loss: 0.0427 - accuracy: 0.9843 - val_loss: 0.2156 - val_accuracy: 0.9330 Epoch 00113: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0113.ckpt Epoch 114/500 625/625 [==============================] - 95s 152ms/step - loss: 0.0432 - accuracy: 0.9845 - val_loss: 0.1710 - val_accuracy: 0.9442 Epoch 00114: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0114.ckpt Epoch 115/500 625/625 [==============================] - 98s 156ms/step - loss: 0.0377 - accuracy: 0.9873 - val_loss: 0.1644 - val_accuracy: 0.9448 Epoch 00115: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0115.ckpt Epoch 116/500 625/625 [==============================] - 95s 152ms/step - loss: 0.0423 - accuracy: 0.9845 - val_loss: 0.2065 - val_accuracy: 0.9402 Epoch 00116: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0116.ckpt Epoch 117/500 625/625 [==============================] - 95s 153ms/step - loss: 0.0386 - accuracy: 0.9862 - val_loss: 0.1610 - val_accuracy: 0.9452 Epoch 00117: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0117.ckpt Epoch 118/500 625/625 [==============================] - 95s 152ms/step - loss: 0.0366 - accuracy: 0.9852 - val_loss: 0.3156 - val_accuracy: 0.9047 Epoch 00118: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0118.ckpt Epoch 119/500 625/625 [==============================] - 95s 152ms/step - loss: 0.0436 - accuracy: 0.9840 - val_loss: 0.1731 - val_accuracy: 0.9475 Epoch 00119: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0119.ckpt Epoch 120/500 625/625 [==============================] - 95s 152ms/step - loss: 0.0441 - accuracy: 0.9839 - val_loss: 0.1845 - val_accuracy: 0.9425 Epoch 00120: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0120.ckpt Epoch 121/500 625/625 [==============================] - 97s 155ms/step - loss: 0.0399 - accuracy: 0.9848 - val_loss: 0.2213 - val_accuracy: 0.9340 Epoch 00121: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0121.ckpt Epoch 122/500 625/625 [==============================] - 95s 152ms/step - loss: 0.0345 - accuracy: 0.9879 - val_loss: 0.1736 - val_accuracy: 0.9450 Epoch 00122: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0122.ckpt Epoch 123/500 625/625 [==============================] - 96s 153ms/step - loss: 0.0329 - accuracy: 0.9888 - val_loss: 0.2234 - val_accuracy: 0.9227 Epoch 00123: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0123.ckpt Epoch 124/500 625/625 [==============================] - 95s 151ms/step - loss: 0.0434 - accuracy: 0.9839 - val_loss: 0.2355 - val_accuracy: 0.9230 Epoch 00124: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0124.ckpt Epoch 125/500 625/625 [==============================] - 95s 152ms/step - loss: 0.0359 - accuracy: 0.9876 - val_loss: 0.2075 - val_accuracy: 0.9360 Epoch 00125: saving model to D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_Adam\cp-0125.ckpt
plot_model__hist(ResNet50V2_model_adam_aug_hist)
loss_adam_aug,acc_adam_aug = ResNet50V2_model_adam_aug.evaluate(test_set, verbose=2)
print("ResNet50V2_model(Adam) 이미지 증강 후 모델의 정확도: {:5.2f}%".format(100*acc_adam_aug))
print("ResNet50V2_model(Adam) 이미지 증강 후 모델의 Loss: {}".format(loss_adam_aug))
<Figure size 432x288 with 0 Axes>
100/100 - 2s - loss: 0.1966 - accuracy: 0.9400 ResNet50V2_model(Adam) 이미지 증강 후 모델의 정확도: 94.00% ResNet50V2_model(Adam) 이미지 증강 후 모델의 Loss: 0.19657617807388306
# 모델 생성해서 가중치 복구하여 임의의 이미지에 분류 넣기
# SGD 모델
from tensorflow.keras.optimizers import SGD
model = Sequential([
get_ResNet50V2(size=128,trainable=True), # 백본 학습 가능하게 설정
Dense(256, activation='relu'),
Dropout(0.5),
Dense(128, activation='relu'),
Dropout(0.25),
Dense(1,activation='sigmoid')
])
opt = SGD(lr=0.01, decay=1e-6, momentum=0.001,nesterov=True)
model.compile(optimizer=opt, loss='binary_crossentropy',metrics=['accuracy'])
model.load_weights(r'D:\Project(2)\cat&dog_set\check_point_ResNet50V2_crawl_SGD\cp-0020.ckpt')
<tensorflow.python.training.tracking.util.CheckpointLoadStatus at 0x137f1371a88>
loss,acc = model.evaluate(test_set, verbose=2)
print("ResNet50V2 최종 모델의 정확도: {:5.2f}%".format(100*acc))
print("ResNet50V2 최종 모델의 Loss: {}".format(loss))
100/100 - 2s - loss: 0.0836 - accuracy: 0.9750 ResNet50V2 최종 모델의 정확도: 97.50% ResNet50V2 최종 모델의 Loss: 0.083615742623806
import cv2
import matplotlib.pyplot as plt
import tensorflow as tf
test_path = r"C:\Users\cvLab\Desktop\test"
test = os.listdir(test_path)
test_sample = []
for i in range(9):
test_sample.append(os.path.join(test_path,test[i]))
images = [cv2.imread(i) for i in test_sample]
for i,j in enumerate(images):
images[i] = cv2.resize(j,(128,128), interpolation=cv2.INTER_AREA)
idx=1
plt.figure(figsize=(16,16))
category = {0:'cat', 1:'dog'}
for i,title, test_img in zip(images,test,test_sample):
plt.subplot(3,3,idx)
plt.title(title)
plt.imshow(cv2.cvtColor(i,cv2.COLOR_BGR2RGB))
test_image = load_img(test_img)
test = tf.keras.preprocessing.image.img_to_array(test_image,data_format=None, dtype=None)
test = test.reshape((1,)+test.shape)
result = model.predict(test/255.)
plt.xlabel(category[int(round(result[0][0],0))])
# print(int(round(result[0][0],0)))
idx+=1
인공지능 경진대회 우수상 (0) | 2021.11.17 |
---|---|
인공지능 경진대회 - Kaggle Wafer defect dection (CNN을 이용한 웨이퍼 결함 탐지) (2) | 2021.11.17 |
딥러닝용 데이터셋 생성기 만들기 - labelpix YOLO Bounding BOX 라벨링 오류코드 해결 (0) | 2021.06.30 |
(labelpix 깃허브 주소)
https://github.com/emadboctorx/labelpix
먼저 내가 만들 데이터셋 생성기에 연동시킬 labelpix라는 github에 있는 labeling tool이 있다.
사진을 업로드해서 클래스를 입력한다음 바운딩박스를 마우스로 그려주면 해당하는 정보를 Pascal VOC(xml), YOLO(txt)버전으로 변환하여 이미지 라벨링을 해주는 유용한 툴이다.
이렇게 마우스로 드래그 한 bounding box의 정보가 xml, txt 파일로 저장이 된다
여기서 눈썰미가 좋은사람은 알아채겠지만 txt 파일에 있어선 안될 정보가 담겨있다.
<문제점>
YOLO버전 BBOX의 정보는 class_num, CenterX, CenterY, W, H 순서로 클래스를 표현하는 index, 중심지점, 넓이 ,높이로 이뤄져 있다.
그런데class num 1에 해당하는 CenterX 정보에 음수가 적혀있고 0 에 해당하는 정보의 CenterY에도 좌표가 음수로 나타내져있다.
대충 눈대중으로 봐도 화면 밖에 그려져있는 bbox는 없는데 일단 xml, yolo 버전 라벨을 이용해 bbox를 시각화 해보겠다
xml파일의 라벨링 정보는 제대로 bbox가 그려지는 반면에, txt파일속 정보로 bbox를 그리면 저렇게 어처구니 없는 상자가 나온다.
<원인>
labelpix 코드 내부에 마우스로 드래그를 해서 bbox를 그리면 해당 bbox의 xmin, ymin, xmax, ymax, 그림 전체의 width, height를 받아서 yolo data전용 cx, cy, w, h로 변환시켜주는 메소드를 보았는데 변환해주는 수식 자체가 엉망인데다가
bbox를 우하단, 우상단, 좌하단부터 그리기 시작해 화면 밖으로 넘어가면 xmax, ymax값이 음수로 나와서 계산식 자체가 엉망이 되기때문에
xmax, ymax가 width, height를 넘어가지 않도록 고정시켜 줘야 하며
CenterX = (xmin + xmax)/2
CenterY = (ymin + ymax)/2
bw = xmax - xmin
bh = ymax - ymin
의 식을 만족한채로 어느점부터 시작해서 바운딩박스를 그리던지 return되는 min,max (x,y)값들은 일정해야 하기 때문에 labelpix의 코드를 수정했다.
코드가 수정된 후 YOLO의 라벨링파일을 시각화시킨 사진과 txt파일 내용이다 정상적으로 잘 작동한다.
인공지능 경진대회 우수상 (0) | 2021.11.17 |
---|---|
인공지능 경진대회 - Kaggle Wafer defect dection (CNN을 이용한 웨이퍼 결함 탐지) (2) | 2021.11.17 |
인공지능 경진대회 - Kaggle Cat&Dog Dataset 이진분류 (0) | 2021.11.17 |