class_docstr: Dataset class suitable for segmentation tasks
class_docstr_tok: ["Dataset","class","suitable","for","segmentation","tasks"]
code: def __init__(
      self,
      image_filenames: List[str],
      mask_filenames: Optional[List[str]],
      transform: A.Compose,
      read_image_fn: Callable = read_image_rgb,
      read_mask_fn: Callable = cv2.imread,
      need_weight_mask=False,
      need_supervision_masks=False,
      make_mask_target_fn: Callable = mask_to_ce_target,
      image_ids: Optional[List[str]] = None,
  ):
      if mask_filenames is not None and len(image_filenames) != len(
          mask_filenames
      ):
          raise ValueError(
              "Number of images does not corresponds to number of targets"
          )
  
      if image_ids is None:
          self.image_ids = [
              fs.id_from_fname(fname) for fname in image_filenames
          ]
      else:
          self.image_ids = image_ids
  
      self.need_weight_mask = need_weight_mask
      self.need_supervision_masks = need_supervision_masks
  
      self.images = image_filenames
      self.masks = mask_filenames
      self.read_image = read_image_fn
      self.read_mask = read_mask_fn
  
      self.transform = transform
      self.make_target = make_mask_target_fn
  
file_path: pytorch-toolbelt/pytorch_toolbelt/datasets/segmentation.py
imports: from functools import partial
  from typing import Optional, List, Callable
  import albumentations
  import cv2
  import numpy
  from skimage.measure import block_reduce
  from torch.utils.data import Dataset
  from .common import read_image_rgb, INPUT_IMAGE_KEY, INPUT_IMAGE_ID_KEY, INPUT_INDEX_KEY, TARGET_MASK_WEIGHT_KEY, TARGET_MASK_KEY, name_for_stride
  from ..utils import fs, image_to_tensor
label_desc: Use image node_id 1 to create a new SegmentationDataset object from inherited base classes: Dataset with example: obj = SegmentationDataset(image_filenames, mask_filenames, transform, read_image_fn, read_mask_fn, need_weight_mask, need_supervision_masks, make_mask_target_fn, image_ids)