class_docstr: A dataset for segmentation tasks.
class_docstr_tok: ["A","dataset","for","segmentation","tasks","."]
docstr: Create dataset for image segmentation task.
  
  The layout the folder should look like following:
      root/image_folder/image_1.jpg
      root/image_folder/image_2.jpg
      ...
      root/mask_folder/image_1.jpg
      root/mask_folder/image_2.jpg
  
  image_folder and the mask_folder should have the same number images in it
  and the corresponding image and mask should have the same prefix.
  
  :param root: the directory to look for image_folder and mask_folder
  :param image_folder: the directory under root containing image files
  :param mask_folder: the directory under root containing mask files
  :param transforms: an optional transforms operating on images and masks
docstr_tok: ["Create","dataset","for","image","segmentation","task",".","The","layout","the","folder","should","look","like","following",":","root\/image_folder\/image_1.jpg","root\/image_folder\/image_2.jpg","...","root\/mask_folder\/image_1.jpg","root\/mask_folder\/image_2.jpg","image_folder","and","the","mask_folder","should","have","the","same","number","images","in","it","and","the","corresponding","image","and","mask","should","have","the","same","prefix",".",":","param","root",":","the","directory","to","look","for","image_folder","and","mask_folder",":","param","image_folder",":","the","directory","under","root","containing","image","files",":","param","mask_folder",":","the","directory","under","root","containing","mask","files",":","param","transforms",":","an","optional","transforms","operating","on","images","and","masks"]
code: def __init__(
      self,
      root: str,
      image_folder: str,
      mask_folder: str,
      transforms: Optional[Callable] = None,
  ):
      """
      Create dataset for image segmentation task.
  
      The layout the folder should look like following:
          root/image_folder/image_1.jpg
          root/image_folder/image_2.jpg
          ...
          root/mask_folder/image_1.jpg
          root/mask_folder/image_2.jpg
  
      image_folder and the mask_folder should have the same number images in it
      and the corresponding image and mask should have the same prefix.
  
      :param root: the directory to look for image_folder and mask_folder
      :param image_folder: the directory under root containing image files
      :param mask_folder: the directory under root containing mask files
      :param transforms: an optional transforms operating on images and masks
      """
      self.image_folder = os.path.join(root, image_folder)
      self.mask_folder = os.path.join(root, mask_folder)
      self.imgs = list(sorted(os.listdir(self.image_folder)))
      self.masks = list(sorted(os.listdir(self.mask_folder)))
      self.transforms = transforms
      try:
          # The following code will fail if `libturbojpeg.so.0.2.0`
          # doesn't exist or load it on windows
          self.jpeg = TurboJPEG(lib_path=local_libturbo_path)
      except Exception as _e:
          warning(f"failed to load {local_libturbo_path}")
          self.jpeg = None
  
file_path: BigDL/python/nano/src/bigdl/nano/pytorch/vision/datasets/datasets.py
imports: from typing import Union, Callable, Optional
  from turbojpeg import TurboJPEG, TJPF_GRAY
  import torchvision
  import cv2
  import os
  import numpy
  import torch
  from logging import warning
  from os.path import split, join, realpath
label_desc: Use image node_id 1 to create a new SegmentationImageFolder object  with example: obj = SegmentationImageFolder(root, image_folder, mask_folder, transforms)