0
votes

I want to create mobilenet to identify label for images.

My input and mask shapes are:-

Check the data

import matplotlib.pyplot as plt

print(X_train.shape)

print(masks.shape)

(409, 224, 224, 3) (409, 224, 224)

create a model:-

def create_model(trainable=True,ALPHA = 1,HEIGHT_CELLS=28,WIDTH_CELLS=28):
model = MobileNet(input_shape=(IMAGE_HEIGHT, IMAGE_WIDTH, 3), include_top=False, alpha=ALPHA, weights="imagenet")
for layer in model.layers:
    layer.trainable = trainable

block1 = model.get_layer("conv_pw_5_relu").output
block2 = model.get_layer("conv_pw_11_relu").output
block3 = model.get_layer("conv_pw_13_relu").output

x = Concatenate()([UpSampling2D()(block3), block2])
x = Concatenate()([UpSampling2D()(x), block1])

x = Conv2D(1, kernel_size=1, activation="sigmoid")(x)
x = Reshape((HEIGHT_CELLS, WIDTH_CELLS))(x)

return Model(inputs=model.input, outputs=x)

model = create_model(True,1,224,224)

I want to fit my model with training dataset

model.fit(
x=X_train,
y=masks,
batch_size=1,    
epochs=100,    
)

but I got an error:

annot reshape a tensor with 784 elements to shape [1,224,224] (50176 elements) for '{{node model_12/reshape_14/Reshape}} = Reshape[T=DT_FLOAT, Tshape=DT_INT32](model_12/conv2d_12/Sigmoid, model_12/reshape_14/Reshape/shape)' with input shapes: [1,28,28,1], [3] and with input tensors computed as partial shapes: input[1] = [1,224,224].

1
the error is simply because 224*224 is not equal to 784 - learner
thank....I pass 224*224 ............create_model(True,1,224,224).....................and also resize it using this code x = Reshape((HEIGHT_CELLS, WIDTH_CELLS))(x) - SM2019

1 Answers

0
votes

784 is 28 x 28. Somehow the default sizes are being used.

The error states "input shapes: [1,28,28,1]"

def create_model(trainable=True,ALPHA = 1,HEIGHT_CELLS=28,WIDTH_CELLS=28):
model = MobileNet(input_shape=(IMAGE_HEIGHT, IMAGE_WIDTH, 3), include_top=False, alpha=ALPHA, weights="imagenet")

What line is the error on?