我使用google colab运行python代码并尝试缩小图像的比例。
from keras.layers import Lambda
import tensorflow as tf
from skimage import data, io, filters
import numpy as np
from numpy import array
from numpy.random import randint
from scipy.misc import imresize
import os
import sys
import matplotlib.pyplot as plt
plt.switch_backend('agg')
# Takes list of images and provide LR images in form of numpy array
def lr_images(images_real , downscale):
images = []
for img in range(len(images_real)):
images.append(imresize(images_real[img],[images_real[img].shape[0]//downscale,images_real[img].shape[1]//downscale], interp='bicubic', mode=None))
images_lr = array(images)
return images_lr
它应该缩小图像的比例,但显示出这个错误。
from scipy.misc import imresize ImportError: cannot import name 'imresize'
你可以按照评论中的建议使用枕头。代码的更改如下所述:
如果你的图像被表示为一个浮点数,你会得到一个错误,说“不能处理这个数据类型”。在这种情况下,您需要将图像转换为如下uint格式:
你可以试试这个:
skimage.transform.resize
https://scikit-image.org/docs/stable/auto_examples/transform/plot_rescale.html
相关问题 更多 >
编程相关推荐