I was trying to recreate the cocoapi demo script by copy pasting it into my own local script instead of running it on a Jupyter notebook. Everything works fine and there's definitely an image read and can be displayed because I've tested it with openCV's imshow() function (and the image pops up). However, when I tried opening the image with plt.imshow() and plt.show(), the image would not appear.
I went online to search for solution at they suggested its a backend issue? However, when I ran matplotlib.get_backend(), it returned: 'TkAgg'.
I also ran: sudo apt-get install tcl-dev tk-dev python-tk python3-tk with no errors nor issues.
from __future__ import print_function
from pycocotools.coco import COCO
import os, sys, zipfile
import urllib.request
import shutil
import numpy as np
import skimage.io as io
import matplotlib.pyplot as plt
import pylab
pylab.rcParams['figure.figsize'] = (8.0, 10.0)
...
# load and display image
I = io.imread('%s/images/%s/%s'%(dataDir,dataType,img['file_name']))
plt.axis('off')
plt.imshow(I)
plt.show()
Versions
* Operating system: Ubuntu 16.04
* Matplotlib version: 2.2.3
* Matplotlib backend (print(matplotlib.get_backend())
): TkAgg
* Python version: 3.5.2