class_docstr: `Berkeley Segmentation Data Set and Benchmarks 500 dataset
  <http://www.eecs.berkeley.edu/Research/Projects/CS/vision/grouping/resources.html#bsds500>`_.
  
  Produce ``(image, label)`` pair, where ``image`` has shape (321, 481, 3(BGR)) and
  ranges in [0,255].
  ``Label`` is a floating point image of shape (321, 481) in range [0, 1].
  The value of each pixel is ``number of times it is annotated as edge / total number of annotators for this image``.
class_docstr_tok: ["`","Berkeley","Segmentation","Data","Set","and","Benchmarks","500","dataset","<","http",":","\/\/www.eecs.berkeley.edu\/Research\/Projects\/CS\/vision\/grouping\/resources.html","#","bsds500",">","`","_",".","Produce","``","(","image",",","label",")","``","pair",",","where","``","image","``","has","shape","(","321",",","481",",","3","(","BGR",")",")","and","ranges","in","[","0,255","]",".","``","Label","``","is","a","floating","point","image","of","shape","(","321",",","481",")","in","range","[","0",",","1","]",".","The","value","of","each","pixel","is","``","number","of","times","it","is","annotated","as","edge","\/","total","number","of","annotators","for","this","image","``","."]
code: def _load(self, name):
      image_glob = os.path.join(self.data_root, "images", name, "*.jpg")
      image_files = glob.glob(image_glob)
      gt_dir = os.path.join(self.data_root, "groundTruth", name)
      self.data = np.zeros(
          (len(image_files), IMG_H, IMG_W, 3), dtype="uint8"
      )
      self.label = np.zeros(
          (len(image_files), IMG_H, IMG_W), dtype="float32"
      )
  
      for idx, f in enumerate(image_files):
          im = cv2.imread(f, cv2.IMREAD_COLOR)
          assert im is not None
          if im.shape[0] > im.shape[1]:
              im = np.transpose(im, (1, 0, 2))
          assert im.shape[:2] == (IMG_H, IMG_W), "{} != {}".format(
              im.shape[:2], (IMG_H, IMG_W)
          )
  
          imgid = os.path.basename(f).split(".")[0]
          gt_file = os.path.join(gt_dir, imgid)
          gt = loadmat(gt_file)["groundTruth"][0]
          n_annot = gt.shape[0]
          gt = sum(gt[k]["Boundaries"][0][0] for k in range(n_annot))
          gt = gt.astype("float32")
          gt *= 1.0 / n_annot
          if gt.shape[0] > gt.shape[1]:
              gt = gt.transpose()
          assert gt.shape == (IMG_H, IMG_W)
  
          self.data[idx] = im
          self.label[idx] = gt
  
file_path: tensorpack/tensorpack/dataflow/dataset/bsds500.py
imports: import glob
  import numpy
  import os
  from ...utils.fs import download, get_dataset_path
  from ..base import RNGDataFlow
label_desc: Use image node_id 2 for calling the BSDS500 obj's underlying member method code with example usage: obj._load(name) without return types