How to load an image and show the image using keras?

后端 未结 2 1197
耶瑟儿~
耶瑟儿~ 2021-02-18 23:41
%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()

         


        
2条回答
  •  日久生厌
    2021-02-18 23:53

    This is a image scaling issue. The input to the imshow() expects it to be in the 0-1 range, while you are passing it a [0-255] range input. Try to view it as:

    plt.imshow(x/255.)
    

提交回复
热议问题