导入错误:无法从"scipy"导入名称"imresize"?

fykwrbwg  于 2023-01-26  发布在  其他
关注(0)|答案(1)|浏览(227)

我正在使用scipy,但一次又一次地得到这个错误。我使用枕头,仍然得到同样的错误。
"这是我的准则"

import cv2
import imutils
import numpy as np
from sklearn.metrics import pairwise
from keras.models import load_model
from scipy import imresize
import PIL
#from PIL import Imageresize as imresize
#from skimage.transform import resize
def getPredictedClass(model):

    image = cv2.imread('Temp.png')
    gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
    gray_image = imresize(gray_image, [100, 120])

    gray_image = gray_image.reshape(1, 100, 120, 1)

    prediction = model.predict_on_batch(gray_image)

    predicted_class = np.argmax(prediction)
nqwrtyyt

nqwrtyyt1#

来自scipy github issue(自1.3.0起已删除)

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 <https://docs.scipy.org/doc/scipy-1.1.0/reference/misc.html>__
can be used to track the new import locations for the relocated functions.

您可以降级scipy或按照此处的步骤操作
vis/visualization/saliency.py
替换:from scipy.misc import imresize
至:import cv2
那么

replace: heatmap = imresize(heatmap, input_dims, interp='bicubic', mode='F')

致:

heatmap = cv2.resize(src=heatmap,
                       dsize=input_dims,
                       interpolation=cv2.INTER_CUBIC)

相关问题