I have read through other stack overflow but it didnt satisfy my problem. Im doing object localization and I expect my model produce four outputs which are the x1,y1,x2,y2 for the bounding box. But it keeps showing me the value error. Is it something wrong with my model or my datasets are wrong? model:
model = keras.Sequential([
keras.layers.Conv2D(32,(3,3),padding = 'same' ,activation = 'relu', input_shape= (image_width,image_height,image_channels)),
keras.layers.MaxPooling2D(pool_size = (2,2)),
keras.layers.Dropout(0.25),
keras.layers.Conv2D(64,(3,3),padding = 'same',activation = 'relu'),
keras.layers.MaxPooling2D(pool_size = (2,2)),
keras.layers.Dropout(0.25),
keras.layers.Conv2D(64,(3,3),padding = "same",activation = 'relu'),
keras.layers.MaxPooling2D(pool_size = (2,2)),
keras.layers.Dropout(0.25),
keras.layers.Flatten(),
keras.layers.Dense(256, activation = 'relu'),
keras.layers.Dropout(0.25),
keras.layers.Dense(4,activation="relu")
])
model.compile(loss="mse", optimizer='adam', metrics=['accuracy'])
train and validation data generator:
train_datagen = ImageDataGenerator(
rotation_range = 15,
rescale = 1./255,
shear_range = 0.1,
zoom_range = 0.2,
horizontal_flip = True,
width_shift_range = 0.1,
height_shift_range = 0.1
)
train_generator = train_datagen.flow_from_dataframe(
dataframe = train_df,
directory = "/mydrive/Object-Classification-and-Localization-with-TensorFlow-master/training_images",
x_col = 'filename',
y_col = 'name',
target_size = (128,128),
class_mode = 'categorical',
batch_size = batch_size
)
validation_datagen = ImageDataGenerator(rescale = 1./255)
validation_generator = validation_datagen.flow_from_dataframe(
dataframe = validate_df,
directory = "/mydrive/Object-Classification-and-Localization-with-TensorFlow-master/training_images",
x_col = 'filename',
y_col = 'name',
target_size = (128,128),
class_mode = 'categorical',
batch_size = batch_size
)
dataset format(total shape for the dataframe = (1488,9)):
filename width height depth name xmin ymin xmax ymax
cucumber_1.jpg 227 227 3 cucumber 23 42 206 199