In [1]:
%reload_ext autoreload
%autoreload 2
%matplotlib inline
from salicon.salicon import SALICON
import numpy as np
import skimage.io as io
import matplotlib.pyplot as plt
In [4]:
dataDir='..'
dataType='val2014'
annFile='%s/annotations/fixations_%s_examples.json'%(dataDir,dataType)
In [5]:
# initialize COCO api for instance annotations
salicon=SALICON(annFile)
loading annotations into memory...
0:00:00.201333
creating index...
index created!
In [6]:
# get all images 
imgIds = salicon.getImgIds();
img = salicon.loadImgs(imgIds[np.random.randint(0,len(imgIds))])[0]
In [7]:
# load and display image
I = io.imread('%s/images/examples/%s'%(dataDir,img['file_name']))
plt.figure()
plt.imshow(I)
plt.show()
In [8]:
# load and display instance annotations
#plt.imshow(I)
annIds = salicon.getAnnIds(imgIds=img['id'])
anns = salicon.loadAnns(annIds)
salicon.showAnns(anns)
plt.show()
In [ ]: