I'm trying to implement custom object detection by taking a trained YOLOv2 model in Keras, removing the last layer and retraining it with new data. I'm confused about how to feed the data to Keras, though. I have annotated a bunch of pictures with bounding boxes using the YOLO annotation, and put them in two separate folders (
images where the .jpgs reside and
annots where the .txt annotations are).
I also removed the last layer from the model and added a custom one (I'm trying to predict bounding boxes for 2 classes).
I'm trying to pass my data with an ImageDataGenerator, as my dataset is quite small.
I have the following input objects:
np.shape(train_images) # this contains RGB data from 79 pictures (79, 1, 608, 608, 3) np.shape(train_y) (79,)
I'm trying to pass these to the ImageDataGenerator, but I get an error:
train_datagen = ImageDataGenerator( rotation_range=20, width_shift_range=0.2, height_shift_range=0.2, horizontal_flip=True, fill_mode='nearest') train_generator = train_datagen.flow( train_images, train_y) ValueError: `x` (images tensor) and `y` (labels) should have the same length. Found: x.shape = (1, 608, 608, 3), y.shape = (79,)
I don't understand what the problem is. Somehow the first dimension of my images data is completely gone and thus does not match... What's wrong with it?