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.
from keras.layers import Dense, Dropout, Flatten, Input from keras.applications.vgg19 import VGG19 from keras.models import Model, Sequential from keras import optimizers
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(Flatten(input_shape=vgg19.output_shape[1:])) top_model.add(Dense(1024, activation='relu')) top_model.add(Dropout(0.5)) 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 #Compile model.compile(loss='categorical_crossentropy', optimizer=optimizers.SGD(lr=1e-4, momentum=0.9), metrics=['accuracy']) #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")
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.
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.