win10 python3.7 tensorflow-gpu环境下 matplotlib.pyplot.imshow不显示(backends is agg,not GUI )

win10+python3.7+tensorflow-gpu环境下 matplotlib.pyplot.imshow不显示问题
(backends is agg,not GUI )

在运行tensorflow\models\research\object_detection\object_detection_tutorial.py (或者.ipynb)文件时,最后一句plt.imshow(image_np)不显示,并报错 backends is agg …

有很多博主给出解决方法:
https://blog.csdn.net/tanmx219/article/details/88074600
https://blog.csdn.net/wonengguwozai/article/details/79686062
https://blog.csdn.net/orangefly0214/article/details/82692138
还是不行!
其中,安装了wxagg
pip install wxPython
在object_detection_tutorial.py开头
增加:
import matplotlib
matplotlib.use(‘WXagg’)
import matplotlib.pyplot as plt
替换:from matplotlib import pyplot as plt

仍然没有效果。

偶然,在文件最后,新导入matplotlib 进行显示:

#最后两行修改为:
        plt.figure(figsize=IMAGE_SIZE)
        #plt.imshow(image_np)
        
        import matplotlib as mmpl
        mmpl.use('WXAgg')
        import matplotlib.pyplot as mmplp
        mmplp.figure(figsize=(12,8))
        mmplp.ion()
        mmplp.imshow(image_np)
        mmplp.show()

图像显示成功!

你可能感兴趣的:(tensorflow)