(self, image_id)
return mask, class_ids
Generate instance masks for shapes of the given image ID.
Generate instance masks for shapes of the given image ID.
Generate instance masks for shapes of the given image ID .
def load_mask(self, image_id):
        """Generate instance masks for shapes of the given image ID.
        """
        info = self.image_info[image_id]

        imgDir = os.path.join( self.ROOT_DIR, osmcfg.trainDir,info['id'])
        wildcard = os.path.join( imgDir,"*.png")

        # 00015-american_football-0.png  00015-baseball-0.png  00015-baseball-1.png  00015-baseball-2.png  00015-baseball-3.png  00015-basketball-0.png  00015-basketball-1.png  00015.jpg  00015.txt

        maskCount = 0
        for filePath in glob.glob(wildcard): 
            filename = os.path.split(filePath)[1] 
            parts = filename.split( "-")
            if ( len(parts) == 3) and parts[1] in featureNames: 
                maskCount += 1

        mask = np.zeros([info['height'], info['width'], maskCount], dtype=np.uint8)
        class_ids = np.zeros((maskCount), np.int32)
 
        count = 0
        for filePath in glob.glob(wildcard): 
            filename = os.path.split(filePath)[1] 
            parts = filename.split( "-")
            if ( len(parts) == 3) and parts[1] in featureNames: 
                imgPath = filePath
                mask[:, :, count] = skimage.io.imread(filePath)
                class_ids[count] = featureNames[parts[1]]
                count += 1            
                
        return mask, class_ids
def load_mask ( self , image_id ) : info = self . image_info [ image_id ] imgDir = os . path . join ( self . ROOT_DIR , osmcfg . trainDir , info [ 'id' ] ) wildcard = os . path . join ( imgDir , "*.png" ) # 00015-american_football-0.png  00015-baseball-0.png  00015-baseball-1.png  00015-baseball-2.png  00015-baseball-3.png  00015-basketball-0.png  00015-basketball-1.png  00015.jpg  00015.txt maskCount = 0 for filePath in glob . glob ( wildcard ) : filename = os . path . split ( filePath ) [ 1 ] parts = filename . split ( "-" ) if ( len ( parts ) == 3 ) and parts [ 1 ] in featureNames : maskCount += 1 mask = np . zeros ( [ info [ 'height' ] , info [ 'width' ] , maskCount ] , dtype = np . uint8 ) class_ids = np . zeros ( ( maskCount ) , np . int32 ) count = 0 for filePath in glob . glob ( wildcard ) : filename = os . path . split ( filePath ) [ 1 ] parts = filename . split ( "-" ) if ( len ( parts ) == 3 ) and parts [ 1 ] in featureNames : imgPath = filePath mask [ : , : , count ] = skimage . io . imread ( filePath ) class_ids [ count ] = featureNames [ parts [ 1 ] ] count += 1 return mask , class_ids