更改图像的形状以匹配模型输入形状的尺寸

时间:2021-02-03 22:55:53

标签: python-3.x tensorflow image-processing keras

我训练了一个期望输入形状为 (None, 9, 100, 100, 3) 的模型。当我运行以下代码时:

                    start_frame = 1
                    while success:
                       vid.set(cv2.CAP_PROP_POS_FRAMES, start_frame)
                       success, image = vid.read()

                       image = np.array(image).astype('float32')/255
                       image = image.reshape(1,*image.shape)
                       image = np.expand_dims(image, axis=0)
                       preds = model.predict(image)

我收到以下警告/错误:WARNING:tensorflow:Model was constructed with shape (None, 9, 100, 100, 3) for input Tensor("conv3d_1_input:0", shape=(None, 9, 100, 100, 3), dtype=float32), but it was called on an input with incompatible shape (1, 1, 100, 100, 3).

有什么办法可以解决这个问题吗?

0 个答案:

没有答案