SciPy最新官方文档的说明(20190730):
Functions from scipy.interpolate (spleval, spline, splmake, and spltopp) and functions from scipy.misc (bytescale, fromimage, imfilter, imread, imresize, imrotate, imsave, imshow, toimage) have been removed. The former set has been deprecated since v0.19.0 and the latter has been deprecated since v1.0.0. Similarly, aliases from scipy.misc (comb, factorial, factorial2, factorialk, logsumexp, pade, info, source, who) which have been deprecated since v1.0.0 are removed. SciPy documentation for v1.1.0 can be used to track the new import locations for the relocated functions.
文档中说明了在scipy的0.19.0版本和1.0.0版本中可以用到的imread,imresize函数在scipy的1.3.0版本中全部被遗弃。
如果在最新版scipy中继续使用这两个函数,会出现如下报错:
AttributeError: module 'scipy.misc' has no attribute 'imread'
AttributeError: module 'scipy.misc' has no attribute 'imresize'
然而网上大多数对这个问题的解决办法都是pip安装PIL或者pillow,这并不能解决到实际问题(因为scipy已经不支持这两个函数,pillow依赖库的安装与否不是根本问题)
img = scipy.misc.imread(myImage)
import imageio
img = imageio.imread(myImage)
img = scipy.misc.imresize(myImage, size=(num_px,num_px))
from PIL import Image
img = np.array(Image.fromarray(myImage).resize((num_px,num_px)))
注:这两个替代方案用到的库请自行安装,可以用pip也可以conda。
这里配合Andre Ng的第一课第四周的作业正好可以用,希望能对遇到这类问题的朋友给予帮助。
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/181967.html原文链接:https://javaforall.cn
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有