Tensorflow_models as tfm compatibility issues with matplotlib.pyplot

Good day,

I would like to ask regarding the use of tensorflow models or tfm since I’m trying to load the hardswish activation function


But once I install the tfm as well as import it as shown below

I encounter some compatibility issues in using matplotlib.pyplot in plotting images

Do you have any suggestions in resolving this issue as well as tips in using the Tensorflow backend since it was mentioned when I’m importing the packages that I needed?

Note that I’m using the code for plotting the CIFAR-10 images and it works to other ipynb files without tfm being installed and I’m also using the google colab.

I would appreciate any help regarding this. Thank you!

Hi @luther88

Welcome to the TensorFlow Forum!

I am able to import the given packages without any error in Google Colab. Please have a look at this replicated gist or if you can share the standalone code to replicate the error and understand the issue.

Please try again and let us know if the issue still persists. Thank you.

Hi @Renu_Patel ,

Thank you for your warm welcome!

Yes, there is no problem in loading the packages, but the issue is that I can’t make any visualization of the loss and accuracy as well as some sample images from the CIFAR-10. You can see in this notebook that once I import the package when I’m using matplotlib.pyplot I can’t see any graph, https://drive.google.com/file/d/1SA-UE2kt_SlQ3bYMGbCyhWeCyslksysG/view?usp=sharing.

Here is another example where I load the swish activation function without importing the Tensorflow_models as tfm in which all the code works fine, https://drive.google.com/file/d/1P3N8Lsc2Ev7uksAbuC6-5xr1oqqhGtCw/view?usp=sharing.

Again, thank you for helping me regarding this issue!

The issue lies in this file, specifically on the line matplotlib.use('Agg'). You have to either comment out that line in that file, or add the following line in your file: matplotlib.use(backend) (where backend is one of these).