简体   繁体   中英

why plt.imshow(predict) shows a fully black image

I set up a mechine learning model to predict a picture based on a given picture(using tensorflow). but when i use matplotlib, and use pyplot.imshow(predict), the picture showed is all black while the predict data is not all zero.

i am a freshman in python.any information would help a lot. the predict data displayed by pycharm debugger

predict = model.predict(np.array(x)).reshape([512, 512, 3])*255

predict=predict[:,:,0]
# # predict=tf.argmax(predict,axis=2)
# with tf.Session() as sess:
#     predict=predict.eval()


predict = np.array(predict.astype('uint8'))
print(predict.dtype)

pyplot.figure(2)
pyplot.imshow(predict)
pyplot.show()

the model.predict will output a possibility that means when the metric is too big, all data is nearly the same zero.

While plotting the image you can set the minimum and maximum value range for the imshow

pyplot.imshow(predict,vmin=0, vmax=255)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM