【发布时间】:2017-12-04 03:25:40
【问题描述】:
%matplotlib inline
from keras.preprocessing import image
import matplotlib.pyplot as plt
import numpy as np
img = np.random.rand(224,224,3)
plt.imshow(img)
plt.show()
img_path = "image.jpeg"
img = image.load_img(img_path, target_size=(224, 224))
print(type(img))
x = image.img_to_array(img)
print(type(x))
print(x.shape)
plt.imshow(x)
我有一些这样的代码应该打印图像。但它以错误的通道显示图像。我在这里错过了什么?
【问题讨论】:
-
“但它在错误的通道中显示图像”不是一个充分的问题描述。结果是什么,您希望如何获得它?尤其是
target_size这里的作用是什么,要不要忽略colorchannels?
标签: python numpy matplotlib tensorflow keras