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/