(self, tensor_images, downsample=1)
return segs
Returns a multilabel segmentation for the given batch of (RGB [-1...1])
        images.  Each pixel of the result is a torch.long indicating a
        predicted class number.  Multiple classes can be predicted for
        the same pixel: output shape is (n, multipred, y, x), where
        multipred is 3, 5, or 6, for how many different predicted labels can
        be given for each pixel (depending on whether subdivision is being
        used).  If downsample is specified, then the output y and x dimensions
        are downsampled from the original image.
Returns a multilabel segmentation for the given batch of (RGB [-1...1])
        images.  Each pixel of the result is a torch.long indicating a
        predicted class number.  Multiple classes can be predicted for
        the same pixel: output shape is (n, multipred, y, x), where
        multipred is 3, 5, or 6, for how many different predicted labels can
        be given for each pixel (depending on whether subdivision is being
        used).  If downsample is specified, then the output y and x dimensions
        are downsampled from the original image.
Returns a multilabel segmentation for the given batch of ( RGB [ - 1 ... 1 ] ) images . Each pixel of the result is a torch . long indicating a predicted class number . Multiple classes can be predicted for the same pixel : output shape is ( n multipred y x ) where multipred is 3 5 or 6 for how many different predicted labels can be given for each pixel ( depending on whether subdivision is being used ) . If downsample is specified then the output y and x dimensions are downsampled from the original image .
def segment_batch(self, tensor_images, downsample=1):
        '''
        Returns a multilabel segmentation for the given batch of (RGB [-1...1])
        images.  Each pixel of the result is a torch.long indicating a
        predicted class number.  Multiple classes can be predicted for
        the same pixel: output shape is (n, multipred, y, x), where
        multipred is 3, 5, or 6, for how many different predicted labels can
        be given for each pixel (depending on whether subdivision is being
        used).  If downsample is specified, then the output y and x dimensions
        are downsampled from the original image.
        '''
        pred, part_pred = self.raw_seg_prediction(tensor_images,
                downsample=downsample)
        y, x = tensor_images.shape[2:]
        seg_shape = (y // downsample, x // downsample)
        segs = torch.zeros(len(tensor_images), 3, # objects, materials, parts
                seg_shape[0], seg_shape[1],
                dtype=torch.long, device=tensor_images.device)
        _, segs[:,0] = torch.max(pred['object'], dim=1)
        # Get materials and translate to shared numbering scheme
        _, segs[:,1] = torch.max(pred['material'], dim=1)
        maskout = (segs[:,1] == 0)
        segs[:,1] += (len(self.segmodel.labeldata['object']) - 1)
        segs[:,1][maskout] = 0
        # Now deal with subparts of sky, buildings, people
        for i, object_index in enumerate(self.objects_with_parts):
            trans = self.part_index[i].to(segs.device)
            # Get the argmax, and then translate to shared numbering scheme
            seg = trans[torch.max(part_pred[i], dim=1)[1]]
            # Only trust the parts where the prediction also predicts the
            # owning object.
            mask = (segs[:,0] == object_index)
            segs[:,2][mask] = seg[mask]
        return segs
def segment_batch ( self , tensor_images , downsample = 1 ) : pred , part_pred = self . raw_seg_prediction ( tensor_images , downsample = downsample ) y , x = tensor_images . shape [ 2 : ] seg_shape = ( y // downsample , x // downsample ) segs = torch . zeros ( len ( tensor_images ) , 3 , # objects, materials, parts seg_shape [ 0 ] , seg_shape [ 1 ] , dtype = torch . long , device = tensor_images . device ) _ , segs [ : , 0 ] = torch . max ( pred [ 'object' ] , dim = 1 ) # Get materials and translate to shared numbering scheme _ , segs [ : , 1 ] = torch . max ( pred [ 'material' ] , dim = 1 ) maskout = ( segs [ : , 1 ] == 0 ) segs [ : , 1 ] += ( len ( self . segmodel . labeldata [ 'object' ] ) - 1 ) segs [ : , 1 ] [ maskout ] = 0 # Now deal with subparts of sky, buildings, people for i , object_index in enumerate ( self . objects_with_parts ) : trans = self . part_index [ i ] . to ( segs . device ) # Get the argmax, and then translate to shared numbering scheme seg = trans [ torch . max ( part_pred [ i ] , dim = 1 ) [ 1 ] ] # Only trust the parts where the prediction also predicts the # owning object. mask = ( segs [ : , 0 ] == object_index ) segs [ : , 2 ] [ mask ] = seg [ mask ] return segs