matplotlib linux服务器没有GPU 保存图片

版权声明:此文章版权归呆呆所有,转发请注明出处! https://blog.csdn.net/zhangyu4863/article/details/82221704

需添加:

import matplotlib as mpl
mpl.use('Agg')

而且必须添加在import matplotlib.pyplot之前,否则无效

最后在要保存的位置加上:

plt.figure(num=1, figsize=(12, 8))
plt.imshow(image_np)

plt.show() #这句是显示检测好的图片。如果加这句,下面的保存图片时,会是空图,不回,保存的图片是正确的,速度也快

plt.savefig('保存的路径加图片名称')

就可以把绘制的图 保存到当前目录下

猜你喜欢

转载自blog.csdn.net/zhangyu4863/article/details/82221704