python - DeepLab v3-如何处理任何大小比例的图像。 (h * w)

标签 python opencv keras deep-learning deeplab

Deeplab v3仅使用默认比例512 * 512预测如何处理具有不同尺寸比例的图像。

,请检查错误:-

Traceback (most recent call last):

File "", line 35, in predicted = model_dlv3.predict(img[np.newaxis, ...])

File "/home/developer/anaconda2/envs/py36/lib/python3.6/site-packages/keras/engine/training.py", line 1149, in predict x, _, _ = self._standardize_user_data(x)

File "/home/developer/anaconda2/envs/py36/lib/python3.6/site-packages/keras/engine/training.py", line 751, in _standardize_user_data exception_prefix='input')

File "/home/developer/anaconda2/envs/py36/lib/python3.6/site-packages/keras/engine/training_utils.py", line 138, in standardize_input_data str(data_shape))

ValueError: Error when checking input: expected input_3 to have shape (512, 512, 3) but got array with shape (2448, 3264, 3)

最佳答案

您可以将图像的尺寸调整为512 * 512,或者使用填充将图像转换为正方形,然后将其尺寸调整为512 * 512。后一种选项更好,因为它不会更改图像内部对象的形状。您可以使用不同的填充模式,看看什么可以带来最佳效果。

您可以使用opencv或scikit-image调整大小和填充

用于填充的opencv文档:https://docs.opencv.org/2.4/modules/imgproc/doc/filtering.html?highlight=copymakeborder#copymakeborder

用于填充的scikit-image文档:http://scikit-image.org/docs/dev/api/skimage.util.html#skimage.util.pad

关于python - DeepLab v3-如何处理任何大小比例的图像。 (h * w),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53446875/

相关文章:

python - python中的装饰器是猴子修补技术的例子吗?

Python高级切片

python - PyCharm:Py_Initialize:无法初始化 sys 标准流

python - python 的 opencv 2.4 中缺少冲浪

python - 在 Keras 中训练和保存非常大的模型

python - 组合模型时不考虑批量尺寸

python - 训练好的 Keras 模型无法使用 load_model 加载

python Telegram Bot "context.bot.send_message"

c++ - 使用数码相机进行相机校准

python - 如何在OpenCV/Python中的框架上绘制单个圆,同时不断更新x-y位置并重新绘制?