AttributeError: module ‘scipy.misc‘ has no attribute ‘imread‘,imresize,imsave等问题

简介: AttributeError: module ‘scipy.misc‘ has no attribute ‘imread‘,imresize,imsave等问题

在复现模型代码时遇到错误:

AttributeError: module ‘scipy.misc’ has no attribute ‘imread’的解决办法

代码如下:

from scipy import misc
img = misc.imread(image_path)

修改如下:

import imageio
img = imageio.imread(image_path)

除此之外,还有另外两个同类错误:

AttributeError: module ‘scipy.misc’ has no attribute 'imresize’的解决方法

代码如下:

from scipy import misc
 
scaled_temp = misc.imresize(cropped_temp, (image_size, image_size), interp='bilinear')

修改如下:

from skimage.transform import resize
scaled_temp = resize(cropped_temp,output_shape=(image_size, image_size))

AttributeError: module ‘scipy.misc’ has no attribute 'imread’的解决方法

代码如下:

from scipy import misc
misc.imsave(output_filename, scaled_temp)

修改如下:

import imageio
imageio.imwrite(output_filename,scaled_temp)

原因解答:原因是scipy在新版本中misc库中弃用了一部函数,其中就包括imread,imresize和imsave。

参考:https://blog.csdn.net/qq_38835585/article/details/105489085

目录
相关文章
|
数据处理 Python
AttributeError: module ‘numpy‘ has no attribute ‘array‘解决办法
AttributeError: module ‘numpy‘ has no attribute ‘array‘解决办法
805 0
|
TensorFlow 算法框架/工具 Python
成功解决AttributeError: module 'numpy' has no attribute 'equal'
成功解决AttributeError: module 'numpy' has no attribute 'equal'
成功解决AttributeError: module 'numpy' has no attribute 'equal'
成功解决AttributeError: module 'numpy' has no attribute 'integer'
成功解决AttributeError: module 'numpy' has no attribute 'integer'
成功解决AttributeError: module 'numpy' has no attribute 'integer'
|
4月前
|
计算机视觉 Python
AttributeError: module ‘cv2‘ has no attribute ‘face‘
AttributeError: module ‘cv2‘ has no attribute ‘face‘
|
6月前
|
Python
AttributeError: module ‘numpy‘ has no attribute ‘int‘.
AttributeError: module ‘numpy‘ has no attribute ‘int‘.
104 0
AttributeError: module ‘torch.utils‘ has no attribute ‘data‘
属性错误:模块的'torch.utils'没有属性'data'
100 0
|
Python
numpy 报错:”AttributeError: module ‘numpy‘ has no attribute ‘bool‘“
numpy 报错:”AttributeError: module ‘numpy‘ has no attribute ‘bool‘“
2277 0
|
TensorFlow 算法框架/工具 计算机视觉
No module named ‘cv2‘ 解决办法 (No module named ‘numpy‘ 等所有报错均可解决)
No module named ‘cv2‘ 解决办法 (No module named ‘numpy‘ 等所有报错均可解决)
|
算法 计算机视觉 Python
【完美解决方案】module ‘cv2.cv2‘ has no attribute ‘xfeatures2d‘
【完美解决方案】module ‘cv2.cv2‘ has no attribute ‘xfeatures2d‘
1192 0
|
TensorFlow API 算法框架/工具
解决AttributeError: module ‘keras.utils‘ has no attribute ‘plot_model‘
解决AttributeError: module ‘keras.utils‘ has no attribute ‘plot_model‘
325 0
解决AttributeError: module ‘keras.utils‘ has no attribute ‘plot_model‘