Ejemplo n.º 1
0
 def segments_pixeldist(self):
     segmdist_fn = os.path.join(self.ds.path, 'cpmc', 'MySegmentsMat', self.name, 'top_masks_dists.mat')    
     if os.path.exists(segmdist_fn):
         data = ml.loadmat(segmdist_fn)
         dist = data['top_masks_dist']
         segm_ids = data["segment_ids"]
     else:    
         prop = self.top_masks
         gt = self.ground_truth
         dist, segm_ids = segments.get_class_distributions(gt, prop, num_classes=self.ds.classnum)
         ml.savemat(segmdist_fn, {'top_masks_dist':dist, 'segment_ids': segm_ids})
     segm_ids = list(np.array(segm_ids).ravel())        
     return dist, segm_ids
Ejemplo n.º 2
0
 def segments_pixeldist(self):
     segmdist_fn = os.path.join(self.ds.path, "cpmc", "MySegmentsMat", self.name, "top_masks_dists.mat")
     if os.path.exists(segmdist_fn):
         data = ml.loadmat(segmdist_fn)
         dist = data["top_masks_dist"]
         segm_ids = data["segment_ids"]
     else:
         prop = self.top_masks
         gt = self.ground_truth
         dist, segm_ids = segments.get_class_distributions(gt, prop, num_classes=self.ds.classnum)
         ml.savemat(segmdist_fn, {"top_masks_dist": dist, "segment_ids": segm_ids})
     segm_ids = list(np.array(segm_ids).ravel())
     return dist, segm_ids
Ejemplo n.º 3
0
 def object_masks(self):
     
     ob_fn = os.path.join(self.ds.path, 'cpmc', 'MySegmentsMat', self.name, 'obj_gt_masks.mat')    
     if os.path.exists(ob_fn):
         data = ml.loadmat(ob_fn)
         masks = data['masks']
         classes = data["classes"]
         
     else:    
         masks = segments.seperate_gt_segments(self.object_ground_truth)
         gt = self.ground_truth
         dists, ids = segments.get_class_distributions(gt, masks)
         classes = np.argmax(dists, axis=0)
         assert masks.shape[2] == len(ids)
         ml.savemat(ob_fn, {'masks':masks, 'classes': classes})
     
     assert masks.shape[2] == classes.size
     return masks, classes
Ejemplo n.º 4
0
 def regions_pixeldist(self):
     """ returns the regions distributions for the given image."""
     regiondist_fn = os.path.join(self.ds.path, 'cpmc', 'MySegmentsMat', self.name, 'region_dists.mat')    
     if os.path.exists(regiondist_fn):
         data = ml.loadmat(regiondist_fn)
         dist = data['dists']
         segm_ids = data["region_ids"]
     else:    
         regions = self.regions
         n_reg = np.max(regions) + 1
         gt = self.ground_truth
         prop = np.zeros((regions.shape[0], regions.shape[1], n_reg), dtype='bool')
         for i in range(n_reg):
             prop[:, :, i] = (regions == i)
         dist, segm_ids = segments.get_class_distributions(gt, prop, num_classes=self.ds.classnum)
         ml.savemat(regiondist_fn, {'dists':dist, 'region_ids': segm_ids})
     segm_ids = list(np.array(segm_ids).ravel())
     return dist, segm_ids
Ejemplo n.º 5
0
    def object_masks(self):

        ob_fn = os.path.join(self.ds.path, "cpmc", "MySegmentsMat", self.name, "obj_gt_masks.mat")
        if os.path.exists(ob_fn):
            data = ml.loadmat(ob_fn)
            masks = data["masks"]
            classes = data["classes"]

        else:
            masks = segments.seperate_gt_segments(self.object_ground_truth)
            gt = self.ground_truth
            dists, ids = segments.get_class_distributions(gt, masks)
            classes = np.argmax(dists, axis=0)
            assert masks.shape[2] == len(ids)
            ml.savemat(ob_fn, {"masks": masks, "classes": classes})

        assert masks.shape[2] == classes.size
        return masks, classes
Ejemplo n.º 6
0
 def regions_pixeldist(self):
     """ returns the regions distributions for the given image."""
     regiondist_fn = os.path.join(self.ds.path, "cpmc", "MySegmentsMat", self.name, "region_dists.mat")
     if os.path.exists(regiondist_fn):
         data = ml.loadmat(regiondist_fn)
         dist = data["dists"]
         segm_ids = data["region_ids"]
     else:
         regions = self.regions
         n_reg = np.max(regions) + 1
         gt = self.ground_truth
         prop = np.zeros((regions.shape[0], regions.shape[1], n_reg), dtype="bool")
         for i in range(n_reg):
             prop[:, :, i] = regions == i
         dist, segm_ids = segments.get_class_distributions(gt, prop, num_classes=self.ds.classnum)
         ml.savemat(regiondist_fn, {"dists": dist, "region_ids": segm_ids})
     segm_ids = list(np.array(segm_ids).ravel())
     return dist, segm_ids