(self, tensor_images, downsample=1)
return pred, part_pred
Generates a segmentation by applying multiresolution voting on
        the segmentation model, using (rounded to 32 pixels) a set of
        resolutions in the example benchmark code.
Generates a segmentation by applying multiresolution voting on
        the segmentation model, using (rounded to 32 pixels) a set of
        resolutions in the example benchmark code.
Generates a segmentation by applying multiresolution voting on the segmentation model using ( rounded to 32 pixels ) a set of resolutions in the example benchmark code .
def raw_seg_prediction(self, tensor_images, downsample=1):
        '''
        Generates a segmentation by applying multiresolution voting on
        the segmentation model, using (rounded to 32 pixels) a set of
        resolutions in the example benchmark code.
        '''
        y, x = tensor_images.shape[2:]
        b = len(tensor_images)
        tensor_images = (tensor_images + 1) / 2 * 255
        tensor_images = torch.flip(tensor_images, (1,)) # BGR!!!?
        tensor_images -= torch.tensor([102.9801, 115.9465, 122.7717]).to(
                   dtype=tensor_images.dtype, device=tensor_images.device
                   )[None,:,None,None]
        seg_shape = (y // downsample, x // downsample)
        # We want these to be multiples of 32 for the model.
        sizes = [(s, s) for s in self.segsizes]
        pred = {category: torch.zeros(
            len(tensor_images), len(self.segmodel.labeldata[category]),
            seg_shape[0], seg_shape[1]).cuda()
            for category in ['object', 'material']}
        part_pred = {partobj_index: torch.zeros(
            len(tensor_images), len(partindex),
            seg_shape[0], seg_shape[1]).cuda()
            for partobj_index, partindex in enumerate(self.part_index)}
        for size in sizes:
            if size == tensor_images.shape[2:]:
                resized = tensor_images
            else:
                resized = torch.nn.AdaptiveAvgPool2d(size)(tensor_images)
            r_pred = self.segmodel(
                dict(img=resized), seg_size=seg_shape)
            for k in pred:
                pred[k] += r_pred[k]
            for k in part_pred:
                part_pred[k] += r_pred['part'][k]
        return pred, part_pred
def raw_seg_prediction ( self , tensor_images , downsample = 1 ) : y , x = tensor_images . shape [ 2 : ] b = len ( tensor_images ) tensor_images = ( tensor_images + 1 ) / 2 * 255 tensor_images = torch . flip ( tensor_images , ( 1 , ) ) # BGR!!!? tensor_images -= torch . tensor ( [ 102.9801 , 115.9465 , 122.7717 ] ) . to ( dtype = tensor_images . dtype , device = tensor_images . device ) [ None , : , None , None ] seg_shape = ( y // downsample , x // downsample ) # We want these to be multiples of 32 for the model. sizes = [ ( s , s ) for s in self . segsizes ] pred = { category : torch . zeros ( len ( tensor_images ) , len ( self . segmodel . labeldata [ category ] ) , seg_shape [ 0 ] , seg_shape [ 1 ] ) . cuda ( ) for category in [ 'object' , 'material' ] } part_pred = { partobj_index : torch . zeros ( len ( tensor_images ) , len ( partindex ) , seg_shape [ 0 ] , seg_shape [ 1 ] ) . cuda ( ) for partobj_index , partindex in enumerate ( self . part_index ) } for size in sizes : if size == tensor_images . shape [ 2 : ] : resized = tensor_images else : resized = torch . nn . AdaptiveAvgPool2d ( size ) ( tensor_images ) r_pred = self . segmodel ( dict ( img = resized ) , seg_size = seg_shape ) for k in pred : pred [ k ] += r_pred [ k ] for k in part_pred : part_pred [ k ] += r_pred [ 'part' ] [ k ] return pred , part_pred