Lior Bruder
Lior Bruder

Reputation: 61

Trying to train a VGG16 CNN with Tensorflow with no success

I'm try to train a VGG16 empty model to classify 7 types of creatures:

enter image description here

The data in each directory is lots of variations of the same creature (diffrent colors, diffrent angle views from 0 to 10, diffrent face), each training class have ~6500 variations, each testing class have ~2500 variations) enter image description here

I use this code to initialize and empty VGG16 model with 7 cassificatioon on the last layer softmax and train the model:

VGGModel = VGG16(weights=None, include_top=False, input_shape=(224, 224, 3))
model = Sequential([
    VGGModel,
    Flatten(),
    Dense(256, activation='relu'),
    Dense(128, activation='relu'),
    Dense(7, activation='softmax'),
])

trdata = ImageDataGenerator()
traindata = trdata.flow_from_directory(directory="SaveImages/traindata",target_size=(224,224))

tsdata = ImageDataGenerator()
testdata = tsdata.flow_from_directory(directory="SaveImages/testdata",target_size=(224,224))

model.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy'])

model.summary()

hist = model.fit_generator(steps_per_epoch=40,generator=traindata, validation_data= testdata, validation_steps=10,epochs=20)

This is the result: enter image description here

The accuracy is about 14% (even when trying larger step size) which is the same as chance value (100% divided by 7 classes), any ideas how to train the model to clasify these creatures?

Upvotes: 0

Views: 118

Answers (0)

Related Questions