(self, anns)
Display the specified annotations.
        :param anns (array of object): annotations to display
        :return: None
Display the specified annotations.
        :param anns (array of object): annotations to display
        :return: None
Display the specified annotations . : param anns ( array of object ) : annotations to display : return : None
def showAnns(self, anns):
        """
        Display the specified annotations.
        :param anns (array of object): annotations to display
        :return: None
        """
        if len(anns) == 0:
            return 0
        if self.dataset['type'] == 'instances':
            ax = plt.gca()
            polygons = []
            color = []
            for ann in anns:
                c = np.random.random((1, 3)).tolist()[0]
                if type(ann['segmentation']) == list:
                    # polygon
                    for seg in ann['segmentation']:
                        poly = np.array(seg).reshape((len(seg)/2, 2))
                        polygons.append(Polygon(poly, True,alpha=0.4))
                        color.append(c)
                else:
                    # mask
                    mask = COCO.decodeMask(ann['segmentation'])
                    img = np.ones( (mask.shape[0], mask.shape[1], 3) )
                    if ann['iscrowd'] == 1:
                        color_mask = np.array([2.0,166.0,101.0])/255
                    if ann['iscrowd'] == 0:
                        color_mask = np.random.random((1, 3)).tolist()[0]
                    for i in range(3):
                        img[:,:,i] = color_mask[i]
                    ax.imshow(np.dstack( (img, mask*0.5) ))
            p = PatchCollection(polygons, facecolors=color, edgecolors=(0,0,0,1), linewidths=3, alpha=0.4)
            ax.add_collection(p)
        if self.dataset['type'] == 'captions':
            for ann in anns:
                print( ann['caption'])
def showAnns ( self , anns ) : if len ( anns ) == 0 : return 0 if self . dataset [ 'type' ] == 'instances' : ax = plt . gca ( ) polygons = [ ] color = [ ] for ann in anns : c = np . random . random ( ( 1 , 3 ) ) . tolist ( ) [ 0 ] if type ( ann [ 'segmentation' ] ) == list : # polygon for seg in ann [ 'segmentation' ] : poly = np . array ( seg ) . reshape ( ( len ( seg ) / 2 , 2 ) ) polygons . append ( Polygon ( poly , True , alpha = 0.4 ) ) color . append ( c ) else : # mask mask = COCO . decodeMask ( ann [ 'segmentation' ] ) img = np . ones ( ( mask . shape [ 0 ] , mask . shape [ 1 ] , 3 ) ) if ann [ 'iscrowd' ] == 1 : color_mask = np . array ( [ 2.0 , 166.0 , 101.0 ] ) / 255 if ann [ 'iscrowd' ] == 0 : color_mask = np . random . random ( ( 1 , 3 ) ) . tolist ( ) [ 0 ] for i in range ( 3 ) : img [ : , : , i ] = color_mask [ i ] ax . imshow ( np . dstack ( ( img , mask * 0.5 ) ) ) p = PatchCollection ( polygons , facecolors = color , edgecolors = ( 0 , 0 , 0 , 1 ) , linewidths = 3 , alpha = 0.4 ) ax . add_collection ( p ) if self . dataset [ 'type' ] == 'captions' : for ann in anns : print ( ann [ 'caption' ] )