image-segmentation-keras
image-segmentation-keras copied to clipboard
Can i train images with different size?
I want train images with different size
model = unet_mini(n_classes=2 , input_height=None, input_width=None )
87 input_width = i_shape[2]
88 n_classes = o_shape[3]
---> 89 o = (Reshape((output_height*output_width, -1)))(o)
90 o = (Activation('softmax'))(o)
91 model = Model(img_input, o)
TypeError: unsupported operand type(s) for *: 'NoneType' and 'NoneType'
Currently, training on diffrent image sizes is not supported.
A short comment about it, because I had a misunderstanding about this issue and I hope it can help someone like me in the future.
The model needs we define a fixed size, height and width (ex., square of 470 pixels):
model = unet_mini(n_classes=2 , input_height=470, input_width=470 )
But, the training process shouldn't need the input images (and segment files) have precisely this dimension. This is because of this library resize internally each example just before the training process: img = cv2.resize(img, (width, height))
In any case, be aware that if the input dimensions are very different (or with a very different aspect ratio) it could affect your result. Furthermore, you would need to resize the model prediction output to adapt it to your original input.
In my experience using input with a very significant difference to the used net results in steps along the segmentation borders because of upscaling.
What happens if your training folder have different image sizes?
Currently, training on diffrent image sizes is not supported.
What happens if your training folder have different image sizes?
Currently, training on diffrent image sizes is not supported.
You can train with different images size in the dataset folders, but the input size of the model should be the same. Therefore, there is a resize function used before the training process.