class_docstr: Face data set for model training and validating
  
  Examples:
  
      ./CelebAMask
          |---test
          |---train
              |---images
                  |---0.jpg
                  |---1.jpg
              |---labels
                  |---0.png
                  |---1.png
              |---edges
                  |---0.png
                  |---1.png
          |---valid
          |---label_names.txt
          |---test_list.txt
          |---train_list.txt
              |---images/0.jpg labels/0.png
              |---images/1.jpg labels/1.png
          |---valid_list.txt
  
  Args:
    root: A string, training/validating dataset path, e.g. "./CelebAMask"
    dataset: A string, one of `"train"`, `"test"`, `"valid"`.
    crop_size: A list of two intergers.
    scale_factor: A float number.
    rotation_factor: An integer number.
    ignore_label: An integer number, default is 255.
    transformer: A function of torchvision.transforms.Compose([])
class_docstr_tok: ["Face","data","set","for","model","training","and","validating","Examples",":",".\/CelebAMask","|","--","-test","|","--","-train","|","--","-images","|","--","-0.jpg","|","--","-1.jpg","|","--","-labels","|","--","-0.png","|","--","-1.png","|","--","-edges","|","--","-0.png","|","--","-1.png","|","--","-valid","|","--","-label_names.txt","|","--","-test_list.txt","|","--","-train_list.txt","|","--","-images\/0.jpg","labels\/0.png","|","--","-images\/1.jpg","labels\/1.png","|","--","-valid_list.txt","Args",":","root",":","A","string",",","training\/validating","dataset","path",",","e.g",".","``",".\/CelebAMask","''","dataset",":","A","string",",","one","of","`","``","train","''","`",",","`","``","test","''","`",",","`","``","valid","''","`",".","crop_size",":","A","list","of","two","intergers",".","scale_factor",":","A","float","number",".","rotation_factor",":","An","integer","number",".","ignore_label",":","An","integer","number",",","default","is","255.","transformer",":","A","function","of","torchvision.transforms.Compose","(","[","]",")"]
code: def __getitem__(self, index: int) -> tuple:
      # Load training image
      im_name = self.im_list[index]
      im_path = osp.join(
          self.root, self.dataset, "images", im_name + ".jpg"
      )
      im = cv2.imread(im_path, cv2.IMREAD_COLOR)
      h, w, _ = im.shape
      parsing_anno = np.zeros((h, w), dtype=np.long)
      # Get center and scale
      center, s = self._box2cs([0, 0, w - 1, h - 1])
      r = 0
  
      if self.dataset not in ["test", "valid"]:
          edge_path = osp.join(
              self.root, self.dataset, "edges", im_name + ".png"
          )
          edge = cv2.imread(edge_path, cv2.IMREAD_GRAYSCALE)
          parsing_anno_path = osp.join(
              self.root, self.dataset, "labels", im_name + ".png"
          )
          parsing_anno = cv2.imread(
              parsing_anno_path, cv2.IMREAD_GRAYSCALE
          )
  
          if self.dataset in "train":
              sf = self.scale_factor
              rf = self.rotation_factor
              s = s * np.clip(
                  np.random.randn() * sf + 1, 1 - sf, 1 + sf
              )
              r = (
                  np.clip(np.random.randn() * rf, -rf * 2, rf * 2)
                  if random.random() <= 0.6
                  else 0
              )
  
      trans = transforms.get_affine_transform(
          center, s, r, self.crop_size
      )
      image = cv2.warpAffine(
          im,
          trans,
          (int(self.crop_size[1]), int(self.crop_size[0])),
          flags=cv2.INTER_LINEAR,
          borderMode=cv2.BORDER_CONSTANT,
          borderValue=(0, 0, 0),
      )
  
      if self.dataset not in ["test", "valid"]:
          edge = cv2.warpAffine(
              edge,
              trans,
              (int(self.crop_size[1]), int(self.crop_size[0])),
              flags=cv2.INTER_LINEAR,
              borderMode=cv2.BORDER_CONSTANT,
              borderValue=(0, 0, 0),
          )
  
      if self.transform:
          image = self.transform(image)
  
      meta = {
          "name": im_name,
          "center": center,
          "height": h,
          "width": w,
          "scale": s,
          "rotation": r,
          "origin": image,
      }
  
      if self.dataset not in "train":
          return image, meta
      else:
          label_parsing = cv2.warpAffine(
              parsing_anno,
              trans,
              (int(self.crop_size[1]), int(self.crop_size[0])),
              flags=cv2.INTER_NEAREST,
              borderMode=cv2.BORDER_CONSTANT,
              borderValue=(255),
          )
  
          label_parsing = torch.from_numpy(label_parsing)
  
          return image, label_parsing, edge, meta
  
file_path: insightface/parsing/dml_csr/dataset/datasets.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import cv2
  import numpy
  import os.path
  import pickle
  import random
  import torch
  import torchvision.transforms.functional
  from glob import glob
  from typing import Tuple
  from utils import transforms
label_desc: Use image node_id 5 for calling the FaceDataSet obj's underlying member method code with example usage: obj.__getitem__(index) and returns: image,  meta, image,  label_parsing,  edge,  meta