Why CIFAR-10 images are not displayed properly using matplotlib?

前端 未结 9 968
独厮守ぢ
独厮守ぢ 2021-02-06 12:28

From the training set I took a image(\'img\') of size (3,32,32). I have used plt.imshow(img.T). The image is not clear. Now changes I have to make to image(\'img\') to make it m

9条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-06 12:59

    code result is: Try below code.

    I found a very useful link about visualization of mnist and cifar images. You can find codes for various images : https://machinelearningmastery.com/how-to-load-and-visualize-standard-computer-vision-datasets-with-keras/ cifar10 image code is below: It works well. Image is above.

    # example of loading the cifar10 dataset
    from matplotlib import pyplot
    from keras.datasets import cifar10
    # load dataset
    (trainX, trainy), (testX, testy) = cifar10.load_data()
    # summarize loaded dataset
    print('Train: X=%s, y=%s' % (trainX.shape, trainy.shape))
    print('Test: X=%s, y=%s' % (testX.shape, testy.shape))
    # plot first few images
    for i in range(9):
        # define subplot
        pyplot.subplot(330 + 1 + i)
        # plot raw pixel data
        pyplot.imshow(trainX[i])
    # show the figure
    pyplot.show()
    

提交回复
热议问题