In this project i have been trying to classify 3 hairstyles - Braided , curly and straight …i am using transfer learning to classify the images … vvg16 model is giving roughly same training and testing accuracy … but when trying to predict actual image , its giving wrong result ( predicting different class)…
My Dataset is roughly 400 images for training and 100 for testing ( all are evenly divided )
Please suggest something , and help me out
Attaching model code -
from keras.applications import VGG16
# Load the pre-trained VGG16 model without the top (fully connected) layers
base_model = VGG16(weights='imagenet', include_top=False, input_shape=(224, 224, 3))
# Freeze the base model layers so they are not trainable
for layer in base_model.layers:
layer.trainable = False
# Create a new model by adding custom top layers on top of the base model
model = Sequential()
model.add(base_model)
model.add(Flatten())
model.add(Dense(128, activation='relu'))
model.add(Dropout(0.25))
model.add(Dense(128, activation='relu'))
model.add(Dropout(0.20))
model.add(Dense(3, activation='softmax')) # Assuming 3 classes
# Compile the model
model.compile(optimizer='Adam', loss='categorical_crossentropy', metrics=['accuracy'])
# Print the model summary
model.summary()