use*_*517 14 python numpy matplotlib keras tensorflow
%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)
我有一些这样的代码应该打印图像.但它在错误的频道中显示图像.我在这里失踪了什么?
vij*_*y m 10
这是图像缩放问题.imshow()的输入要求它在0-1范围内,而你传递的是[0-255]范围输入.尝试将其视为:
plt.imshow(x/255.)
| 归档时间: | 
 | 
| 查看次数: | 20665 次 | 
| 最近记录: |