mmseg/models/decode_heads/enc_head.py
def _convert_to_onehot_labels(seg_label, num_classes):
        """Convert segmentation label to onehot.

        Args:
            seg_label (Tensor): Segmentation label of shape (N, H, W).
            num_classes (int): Number of classes.

        Returns:
            Tensor: Onehot labels of shape (N, num_classes).
        """

        batch_size = seg_label.size(0)
        onehot_labels = seg_label.new_zeros((batch_size, num_classes))
        for i in range(batch_size):
            hist = seg_label[i].float().histc(
                bins=num_classes, min=0, max=num_classes - 1)
            onehot_labels[i] = hist > 0
        return onehot_labels
Convert segmentation label to onehot.

        Args:
            seg_label (Tensor): Segmentation label of shape (N, H, W).
            num_classes (int): Number of classes.

        Returns:
            Tensor: Onehot labels of shape (N, num_classes).
        
Convert segmentation label to onehot.
Convert segmentation label to onehot .
def _convert_to_onehot_labels(seg_label, num_classes):
        batch_size = seg_label.size(0)
        onehot_labels = seg_label.new_zeros((batch_size, num_classes))
        for i in range(batch_size):
            hist = seg_label[i].float().histc(
                bins=num_classes, min=0, max=num_classes - 1)
            onehot_labels[i] = hist > 0
        return onehot_labels
def _convert_to_onehot_labels ( seg_label , num_classes ) : batch_size = seg_label . size ( 0 ) onehot_labels = seg_label . new_zeros ( ( batch_size , num_classes ) ) for i in range ( batch_size ) : hist = seg_label [ i ] . float ( ) . histc ( bins = num_classes , min = 0 , max = num_classes - 1 ) onehot_labels [ i ] = hist > 0 return onehot_labels
Convert segmentation label to onehot.
Convert segmentation label to onehot .
"""Convert segmentation label to onehot.

        Args:
            seg_label (Tensor): Segmentation label of shape (N, H, W).
            num_classes (int): Number of classes.

        Returns:
            Tensor: Onehot labels of shape (N, num_classes).
        """
Onehot labels of shape (N, num_classes).
Onehot labels of shape ( N num_classes ) .
Tensor
seg_label
Segmentation label of shape (N, H, W).
Segmentation label of shape ( N H W ) .
num_classes
Number of classes.
Number of classes .