Ejemplo n.º 1
0
 def regions(self):
     """ regions created for the top proposals"""
     region_fn = os.path.join(self.ds.path, 'cpmc', 'MySegmentsMat', self.name, 'top_regions.mat')    
     if os.path.exists(region_fn):
         regions = ml.loadmat(region_fn)['top_regions']
     else:    
         proposals = self.top_masks
         regions = reg.produce_regions(proposals)
         ml.savemat(region_fn, {'top_regions':regions})
         logging.debug("Storing regions in %s" % region_fn)
         if not np.any(np.isnan(regions)):
             logging.debug("All pixels are covered in one region")
     return regions
Ejemplo n.º 2
0
 def regions(self):
     """ regions created for the top proposals"""
     region_fn = os.path.join(self.ds.path, "cpmc", "MySegmentsMat", self.name, "top_regions.mat")
     if os.path.exists(region_fn):
         regions = ml.loadmat(region_fn)["top_regions"]
     else:
         proposals = self.top_masks
         regions = reg.produce_regions(proposals)
         ml.savemat(region_fn, {"top_regions": regions})
         logging.debug("Storing regions in %s" % region_fn)
         if not np.any(np.isnan(regions)):
             logging.debug("All pixels are covered in one region")
     return regions
Ejemplo n.º 3
0
    num = 12
    for i in range(num):
        ax = prepare_jpg_plot()
        mask = masks[:, :, i]
        mask[mask > 0] = 6
        util.visual.show_image_mask(img, mask, ax, alpha=0.9)
        fn = 'segment_{:0=2d}.jpg'.format(i + 1)
        util.visual.add_inner_title(ax,
                                    "Score: {:.4}".format(scores[i]),
                                    3,
                                    size={
                                        "size": 45,
                                        "color": "w"
                                    })
        save_plot(fn, path)
    regs = regions.produce_regions(masks[:, :, :num])
    ax = prepare_jpg_plot()
    ax.imshow(regs,
              cmap=mpl.colors.ListedColormap(np.random.rand(256, 3)),
              interpolation="nearest")
    save_plot("regions.png", path)

    ax = prepare_jpg_plot()
    reg = img.regions
    ax.imshow(reg,
              cmap=mpl.colors.ListedColormap(np.random.rand(256, 3)),
              interpolation='nearest')
    ax.set_axis_off()
    save_plot("regions_all.png", path)

    ax = prepare_jpg_plot()
Ejemplo n.º 4
0
    n = "2007_005331"
    img = ds.voc2010_trainval[ds.voc2010_trainval.names.index(n)]
    masks = img.top_masks
    scores = img.get_top_scores()
       
 
    num = 12    
    for i in range(num):
        ax = prepare_jpg_plot()
        mask = masks[:,:,i]
        mask[mask > 0] = 6
        util.visual.show_image_mask(img, mask, ax, alpha=0.9)     
        fn = 'segment_{:0=2d}.jpg'.format(i+1)
        util.visual.add_inner_title(ax, "Score: {:.4}".format(scores[i]), 3, size={"size":45, "color":"w"})
        save_plot(fn, path)
    regs = regions.produce_regions(masks[:,:,:num])
    ax = prepare_jpg_plot()
    ax.imshow(regs,cmap=mpl.colors.ListedColormap ( np.random.rand ( 256,3)), interpolation="nearest")
    save_plot("regions.png", path)
    
    ax = prepare_jpg_plot() 
    reg = img.regions
    ax.imshow(reg,cmap=mpl.colors.ListedColormap ( np.random.rand ( 256,3)) ,interpolation='nearest')
    ax.set_axis_off()
    save_plot("regions_all.png", path)    
    
    ax = prepare_jpg_plot() 
    util.visual.show_annotated_image(img, ax, show_bg=True, alpha=1.)    
    save_plot("gt.jpg", path)
    
    ax = prepare_jpg_plot()