python - scipy.misc 模块没有属性 imresize
问题描述
我想使用部分代码来更改我的输入图像大小,但 imresize 在 scipy 上已弃用,并且无法在 google colab 上运行。代码的一部分是:
height = 256
width = 256
channels = 3
.....
img = sc.imread(Tr_list[idx])
img = np.double(sc.imresize(img, [height, width, channels], interp='bilinear', mode = 'RGB'))
所以,我正在寻找 numpy.array(Image.fromarray(arr).resize()) 上的等效代码。我应该如何更改我的代码?
确切的错误文本是:
AttributeError: module 'scipy.misc' has no attribute 'imread'
解决方案
如您所说,您应该使用以下Image
模块PIL
:
from PIL import Image
height = 256
width = 256
...
img = ...
img = np.array(Image.fromarray(img).resize((height, width), Image.BILINEAR)).astype(np.double)
推荐阅读
- tensorflow.js - 如何从图像中获取张量
- elasticsearch - 术语弹性查询未找到字母数字关键字文本的匹配项
- javascript - 给定一个已知大小的 ArrayBuffer,获取十六进制对的字符串
- javascript - 使用表单数据并基于它生成 HTML
- django - Django + gunicorn + nginx:502 bad gateway,但有时只有?
- javascript - Angular 6:在 catch => errHandler 中访问“this”
- python - 在 Django Factory Boy 中,是否可以静音特定的接收器(不是所有信号)?
- ios - 如何“松散地”触发功能?
- python - Gunicorn 工作人员在请求后不会缩小内存
- dependency-injection - 在 dotnet core 中使用 DI 为多个实例创建多个范围