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","``","."]
docstr: Args:
      name (str): 'train', 'test', 'val'
      data_dir (str): a directory containing the original 'BSR' directory.
docstr_tok: ["Args",":","name","(","str",")",":","'train","'",",","'test","'",",","'val'","data_dir","(","str",")",":","a","directory","containing","the","original","'BSR","'","directory","."]
code: def __init__(self, name, data_dir=None, shuffle=True):
      """
      Args:
          name (str): 'train', 'test', 'val'
          data_dir (str): a directory containing the original 'BSR' directory.
      """
      # check and download data
      if data_dir is None:
          data_dir = get_dataset_path("bsds500_data")
      if not os.path.isdir(os.path.join(data_dir, "BSR")):
          download(DATA_URL, data_dir, expect_size=DATA_SIZE)
          filename = DATA_URL.split("/")[-1]
          filepath = os.path.join(data_dir, filename)
          import tarfile
  
          tarfile.open(filepath, "r:gz").extractall(data_dir)
      self.data_root = os.path.join(data_dir, "BSR", "BSDS500", "data")
      assert os.path.isdir(self.data_root)
  
      self.shuffle = shuffle
      assert name in ["train", "test", "val"]
      self._load(name)
  
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 1 to create a new BSDS500 object from inherited base classes: RNGDataFlow with example: obj = BSDS500(name, data_dir, shuffle)