擅长:python、mysql、java
<p>你可以按照评论中的建议使用枕头。代码的更改如下所述:</p>
<pre><code>import PIL
images.append(np.array(PIL.Image.fromarray(images_real[img]).resize(
[images_real[img].shape[0]//downscale,
images_real[img].shape[1]//downscale],resample=PIL.Image.BICUBIC)))
</code></pre>
<p>如果你的图像被表示为一个浮点数,你会得到一个错误,说“不能处理这个数据类型”。在这种情况下,您需要将图像转换为如下uint格式:</p>
<pre><code>images.append(np.array(PIL.Image.fromarray(
(images_real[img]*255).astype(np.uint8).resize(
[images_real[img].shape[0]//downscale,
images_real[img].shape[1]//downscale],resample=PIL.Image.BICUBIC)))
</code></pre>