[PYTHON] Model construction for face image dataset sorting-VGG19 transfer learning (# 2)


Build a model that sorts UTKFace datasets by the following features. ·no problem ·grayscale ・ Multiple people are shown ・ Processed

I tried VGG19 transfer learning using Last created learning data.


Google Colaboratory(GPU)

from keras.layers import Dense, Dropout, Flatten, Input
from keras.applications.vgg19 import VGG19
from keras.models import Model, Sequential
from keras import optimizers

Use the trained model of VGG19.

Although the processing is burdensome, the number of pixels was increased because the accuracy rate could not be increased. There may have been little training data.

#The model uses vgg19 im_size=299
input_tensor = Input(shape=(im_size, im_size, 3))
vgg19 = VGG19(include_top=False, weights='imagenet', input_tensor=input_tensor)

#Defines the layer that receives the output of vgg and classifies it
top_model = Sequential()
top_model.add(Dense(1024, activation='relu'))
top_model.add(Dense(4, activation='softmax'))

#vgg and top_Concatenate models
model = Model(inputs=vgg19.input, outputs=top_model(vgg19.output))

#Makes vgg layer weights immutable
for layer in model.layers[:18]:
    layer.trainable = False

              optimizer=optimizers.SGD(lr=1e-4, momentum=0.9),

#Do learning
model.fit(X_train, y_train,epochs=20, validation_data=(X_test, y_test))

#Displays the evaluation with test data.
model.evaluate(X_test, y_test, verbose=1)

#Save the training model to My Drive.
model.save("/content/drive/My Drive/vggsort_model.h5")

Results of learning

With test data

Hmmm. There seems to be more work to be done, but it is a result for the time being. I would like to sort the image data by folder using this trained model.

Face image data set sorting using machine learning model (# 3)

afterwards… By the way, the learning data used this time was not sufficiently sorted manually, so there was a mixture of data that would make mistakes learned. While utilizing the sorting by the trained model this time, when the training data was manually cleaned and the model learning was performed again, the correct answer rate improved to 96%. It was well understood that creating data for learning was inevitable.

Recommended Posts

Model construction for face image dataset sorting-VGG19 transfer learning (# 2)
Creating learning data for face image dataset sorting (# 1)
Face image dataset sorting using machine learning model (# 3)
Implementation of Deep Learning model for image recognition
Deep learning image recognition 2 model implementation
[AI] Deep Learning for Image Denoising
Create an AI that identifies Zuckerberg's face by deep learning ② (AI model construction)
Image recognition model using deep learning in 2016
[Deep learning] Nogizaka face detection ~ For beginners ~
Deep learning image recognition 3 after model creation
Read & implement Deep Residual Learning for Image Recognition