解决bug:module ‘scipy.misc‘ has no attribute ‘imread‘

错误原因:

imread 和 imresize 方法 将在 Scipy1.0.0被弃用,在Scipy1.3.0被移除

DeprecationWarning: `imread` is deprecated!
`imread` is deprecated in SciPy 1.0.0.
Use ``matplotlib.pyplot.imread`` instead.
/opt/conda/lib/python3.6/site-packages/ipykernel_launcher.py:12: DeprecationWarning: `imresize` is deprecated!
`imresize` is deprecated in SciPy 1.0.0, and will be removed in 1.3.0.

解决方法 :
利用 matplotlib库中的 pyplot 中的imread方法解决
报错代码如下:

image = np.array(ndimage.imread(fname, flatten=False))
my_image = scipy.misc.imresize(image, size=(64,64)).reshape((1, 64*64*3)).T

解决方式:把ndimage 替换用 plt

image = np.array(plt.imread(fname))
my_image = scipy.misc.imresize(image, size=(64,64)).reshape((1, 64*64*3)).T

猜你喜欢

转载自blog.csdn.net/qq_35712832/article/details/115010906
今日推荐