class_docstr: Converts a ``PIL Image`` to a ``torch.LongTensor``.
  Code adapted from: http://pytorch.org/docs/master/torchvision/transforms.html?highlight=totensor
class_docstr_tok: ["Converts","a","``","PIL","Image","``","to","a","``","torch.LongTensor","``",".","Code","adapted","from",":","http",":","\/\/pytorch.org\/docs\/master\/torchvision\/transforms.html","?","highlight=totensor"]
docstr: Encode segmentation label images as pascal classes
  Args:
      mask (np.ndarray): raw segmentation label image of dimension
        (M, N, 3), in which the Pascal classes are encoded as colours.
  Returns:
      (np.ndarray): class map with dimensions (M,N), where the value at
      a given location is the integer denoting the class index.
docstr_tok: ["Encode","segmentation","label","images","as","pascal","classes","Args",":","mask","(","np.ndarray",")",":","raw","segmentation","label","image","of","dimension","(","M",",","N",",","3",")",",","in","which","the","Pascal","classes","are","encoded","as","colours",".","Returns",":","(","np.ndarray",")",":","class","map","with","dimensions","(","M",",","N",")",",","where","the","value","at","a","given","location","is","the","integer","denoting","the","class","index","."]
code: def encode_segmap(self, mask):
      """Encode segmentation label images as pascal classes
      Args:
          mask (np.ndarray): raw segmentation label image of dimension
            (M, N, 3), in which the Pascal classes are encoded as colours.
      Returns:
          (np.ndarray): class map with dimensions (M,N), where the value at
          a given location is the integer denoting the class index.
      """
      mask = mask.astype(int)
      label_mask = np.zeros(
          (mask.shape[0], mask.shape[1]), dtype=np.int16
      )
      for ii, label in enumerate(self.clss):
          label_mask[np.where(np.all(mask == label, axis=-1))[:2]] = ii
      label_mask = label_mask.astype(int)
      return label_mask
  
file_path: baal/baal/utils/transforms.py
imports: import numpy
  import torch
  from PIL import Image
label_desc: Use image node_id 3 for calling the PILToLongTensor obj's underlying member method code with example usage: obj.encode_segmap(mask) and returns: label_mask