class_docstr: Dataset class for the PASCAL VOC 2012 dataset
  
  The structure of PASCAL VOC dataset should be like this: ::
  
      pascal_voc/VOCdevkit/VOC2012/Annotations
      pascal_voc/VOCdevkit/VOC2012/JPEGImages
      pascal_voc/VOCdevkit/VOC2012/SegmentationClass
      pascal_voc/VOCdevkit/VOC2012/SegmentationClassAug_Visualization
      pascal_voc/VOCdevkit/VOC2012/ImageSets
      pascal_voc/VOCdevkit/VOC2012/list
      pascal_voc/VOCdevkit/VOC2012/SegmentationClassAug
      pascal_voc/VOCdevkit/VOC2012/SegmentationObject
  
  Args:
      opts: Command-line arguments
class_docstr_tok: ["Dataset","class","for","the","PASCAL","VOC","2012","dataset","The","structure","of","PASCAL","VOC","dataset","should","be","like","this",":",":",":","pascal_voc\/VOCdevkit\/VOC2012\/Annotations","pascal_voc\/VOCdevkit\/VOC2012\/JPEGImages","pascal_voc\/VOCdevkit\/VOC2012\/SegmentationClass","pascal_voc\/VOCdevkit\/VOC2012\/SegmentationClassAug_Visualization","pascal_voc\/VOCdevkit\/VOC2012\/ImageSets","pascal_voc\/VOCdevkit\/VOC2012\/list","pascal_voc\/VOCdevkit\/VOC2012\/SegmentationClassAug","pascal_voc\/VOCdevkit\/VOC2012\/SegmentationObject","Args",":","opts",":","Command-line","arguments"]
code: def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
      super().__init__(opts=opts, *args, **kwargs)
      use_coco_data = getattr(opts, "dataset.pascal.use_coco_data")
      coco_root_dir = getattr(opts, "dataset.pascal.coco_root_dir")
      root = self.root
  
      voc_root_dir = os.path.join(root, "VOC2012")
      voc_list_dir = os.path.join(voc_root_dir, "list")
  
      coco_data_file = None
      if self.is_training:
          # use the PASCAL VOC 2012 train data with augmented data
          data_file = os.path.join(voc_list_dir, "train_aug.txt")
          if use_coco_data and coco_root_dir is not None:
              coco_data_file = os.path.join(
                  coco_root_dir, "train_2017.txt"
              )
              assert os.path.isfile(
                  coco_data_file
              ), "COCO data file does not exist at: {}".format(
                  coco_root_dir
              )
      else:
          data_file = os.path.join(voc_list_dir, "val.txt")
  
      self.images = []
      self.masks = []
      with open(data_file, "r") as lines:
          for line in lines:
              line_split = line.split(" ")
              rgb_img_loc = (
                  voc_root_dir + os.sep + line_split[0].strip()
              )
              mask_img_loc = (
                  voc_root_dir + os.sep + line_split[1].strip()
              )
              assert os.path.isfile(
                  rgb_img_loc
              ), "RGB file does not exist at: {}".format(rgb_img_loc)
              assert os.path.isfile(
                  mask_img_loc
              ), "Mask image does not exist at: {}".format(rgb_img_loc)
              self.images.append(rgb_img_loc)
              self.masks.append(mask_img_loc)
  
      # if COCO data (mapped in PASCAL VOC format) needs to be used during training
      if self.is_training and coco_data_file is not None:
          with open(coco_data_file, "r") as lines:
              for line in lines:
                  line_split = line.split(" ")
                  rgb_img_loc = (
                      coco_root_dir + os.sep + line_split[0].rstrip()
                  )
                  mask_img_loc = (
                      coco_root_dir + os.sep + line_split[1].rstrip()
                  )
                  assert os.path.isfile(rgb_img_loc)
                  assert os.path.isfile(mask_img_loc)
                  self.images.append(rgb_img_loc)
                  self.masks.append(mask_img_loc)
      self.use_coco_data = use_coco_data
      self.ignore_label = 255
      self.background_idx = 0
      self.check_dataset()
  
file_path: ml-cvnets/data/datasets/segmentation/pascal_voc.py
imports: import argparse
  import os
  from typing import List
  import numpy
  from data.datasets import DATASET_REGISTRY
  from data.datasets.segmentation.base_segmentation import BaseImageSegmentationDataset
label_desc: Use image node_id 1 to create a new PascalVOCDataset object from inherited base classes: BaseImageSegmentationDataset with example: obj = PascalVOCDataset(opts)