class_docstr: Cityscapes dataset `https://www.cityscapes-dataset.com/`.
  The folder structure is as follow:
  
      cityscapes/
      |--gtFine/
      |  |--train/
      |  |  |--aachen/
      |  |  |  |--*_color.png, *_instanceIds.png, *_labelIds.png, *_polygons.json,
      |  |  |  |--*_labelTrainIds.png
      |  |  |  |--...
      |  |--val/
      |  |--test/
      |  |--cityscapes_panoptic_train_trainId.json
      |  |--cityscapes_panoptic_train_trainId/
      |  |  |-- *_panoptic.png
      |  |--cityscapes_panoptic_val_trainId.json
      |  |--cityscapes_panoptic_val_trainId/
      |  |  |--  *_panoptic.png
      |--leftImg8bit/
      |  |--train/
      |  |--val/
      |  |--test/
  
  Args:
      transforms (list): Transforms for image.
      dataset_root (str): Cityscapes dataset directory.
      mode (str, optional): Which part of dataset to use. it is one of ('train', 'val'). Default: 'train'.
      ignore_stuff_in_offset (bool, optional): Whether to ignore stuff region when training the offset branch. Default: False.
      small_instance_area (int, optional): Instance which area less than given value is considered small. Default: 0.
      small_instance_weight (int, optional): The loss weight for small instance. Default: 1.
      stuff_area (int, optional): An Integer, remove stuff whose area is less tan stuff_area. Default: 2048.
class_docstr_tok: ["Cityscapes","dataset","`","https",":","\/\/www.cityscapes-dataset.com\/","`",".","The","folder","structure","is","as","follow",":","cityscapes\/","|","--","gtFine\/","|","|","--","train\/","|","|","|","--","aachen\/","|","|","|","|","--","*","_color.png",",","*","_instanceIds.png",",","*","_labelIds.png",",","*","_polygons.json",",","|","|","|","|","--","*","_labelTrainIds.png","|","|","|","|","--","...","|","|","--","val\/","|","|","--","test\/","|","|","--","cityscapes_panoptic_train_trainId.json","|","|","--","cityscapes_panoptic_train_trainId\/","|","|","|","--","*","_panoptic.png","|","|","--","cityscapes_panoptic_val_trainId.json","|","|","--","cityscapes_panoptic_val_trainId\/","|","|","|","--","*","_panoptic.png","|","--","leftImg8bit\/","|","|","--","train\/","|","|","--","val\/","|","|","--","test\/","Args",":","transforms","(","list",")",":","Transforms","for","image",".","dataset_root","(","str",")",":","Cityscapes","dataset","directory",".","mode","(","str",",","optional",")",":","Which","part","of","dataset","to","use",".","it","is","one","of","(","'train","'",",","'val","'",")",".","Default",":","'train","'",".","ignore_stuff_in_offset","(","bool",",","optional",")",":","Whether","to","ignore","stuff","region","when","training","the","offset","branch",".","Default",":","False",".","small_instance_area","(","int",",","optional",")",":","Instance","which","area","less","than","given","value","is","considered","small",".","Default",":","0.","small_instance_weight","(","int",",","optional",")",":","The","loss","weight","for","small","instance",".","Default",":","1.","stuff_area","(","int",",","optional",")",":","An","Integer",",","remove","stuff","whose","area","is","less","tan","stuff_area",".","Default",":","2048","."]
code: def __init__(
      self,
      transforms,
      dataset_root,
      mode="train",
      ignore_stuff_in_offset=False,
      small_instance_area=0,
      small_instance_weight=1,
      stuff_area=2048,
  ):
      self.dataset_root = dataset_root
      self.transforms = Compose(transforms)
      self.file_list = list()
      self.ins_list = []
      mode = mode.lower()
      self.mode = mode
      self.num_classes = 19
      self.ignore_index = 255
      self.thing_list = [11, 12, 13, 14, 15, 16, 17, 18]
      self.label_divisor = 1000
      self.stuff_area = stuff_area
  
      if mode not in ["train", "val"]:
          raise ValueError(
              "mode should be 'train' or 'val' , but got {}.".format(
                  mode
              )
          )
  
      if self.transforms is None:
          raise ValueError("`transforms` is necessary, but it is None.")
  
      img_dir = os.path.join(self.dataset_root, "leftImg8bit")
      label_dir = os.path.join(self.dataset_root, "gtFine")
      if (
          self.dataset_root is None
          or not os.path.isdir(self.dataset_root)
          or not os.path.isdir(img_dir)
          or not os.path.isdir(label_dir)
      ):
          raise ValueError(
              "The dataset is not Found or the folder structure is nonconfoumance."
          )
      json_filename = os.path.join(
          self.dataset_root,
          "gtFine",
          "cityscapes_panoptic_{}_trainId.json".format(mode),
      )
      dataset = json.load(open(json_filename))
      img_files = []
      label_files = []
      for img in dataset["images"]:
          img_file_name = img["file_name"]
          img_files.append(
              os.path.join(
                  self.dataset_root,
                  "leftImg8bit",
                  mode,
                  img_file_name.split("_")[0],
                  img_file_name.replace("_gtFine", ""),
              )
          )
      for ann in dataset["annotations"]:
          ann_file_name = ann["file_name"]
          label_files.append(
              os.path.join(
                  self.dataset_root,
                  "gtFine",
                  "cityscapes_panoptic_{}_trainId".format(mode),
                  ann_file_name,
              )
          )
          self.ins_list.append(ann["segments_info"])
  
      self.file_list = [
          [img_path, label_path]
          for img_path, label_path in zip(img_files, label_files)
      ]
  
      self.target_transform = PanopticTargetGenerator(
          self.ignore_index,
          self.rgb2id,
          self.thing_list,
          sigma=8,
          ignore_stuff_in_offset=ignore_stuff_in_offset,
          small_instance_area=small_instance_area,
          small_instance_weight=small_instance_weight,
      )
  
      self.raw_semantic_generator = SemanticTargetGenerator(
          ignore_index=self.ignore_index, rgb2id=self.rgb2id
      )
      self.raw_instance_generator = InstanceTargetGenerator(self.rgb2id)
      self.raw_panoptic_generator = RawPanopticTargetGenerator(
          ignore_index=self.ignore_index,
          rgb2id=self.rgb2id,
          label_divisor=self.label_divisor,
      )
  
file_path: PaddleSeg/contrib/PanopticDeepLab/datasets/cityscapes_panoptic.py
imports: import json
  import os
  import glob
  import numpy
  import paddle
  from paddleseg.cvlibs import manager
  from paddleseg.transforms import Compose
  import PIL.Image
  from transforms import PanopticTargetGenerator, SemanticTargetGenerator, InstanceTargetGenerator, RawPanopticTargetGenerator
label_desc: Use image node_id 1 to create a new CityscapesPanoptic object from inherited base classes: paddle.io with example: obj = CityscapesPanoptic(transforms, dataset_root, mode, ignore_stuff_in_offset, small_instance_area, small_instance_weight, stuff_area)