class_docstr: Convert RGB or BGR image to grayscale. 
class_docstr_tok: ["Convert","RGB","or","BGR","image","to","grayscale","."]
docstr: Args:
      keepdims (bool): return image of shape [H, W, 1] instead of [H, W]
      rgb (bool): interpret input as RGB instead of the default BGR
      keepshape (bool): whether to duplicate the gray image into 3 channels
          so the result has the same shape as input.
docstr_tok: ["Args",":","keepdims","(","bool",")",":","return","image","of","shape","[","H",",","W",",","1","]","instead","of","[","H",",","W","]","rgb","(","bool",")",":","interpret","input","as","RGB","instead","of","the","default","BGR","keepshape","(","bool",")",":","whether","to","duplicate","the","gray","image","into","3","channels","so","the","result","has","the","same","shape","as","input","."]
code: def __init__(self, keepdims=True, rgb=False, keepshape=False):
      """
      Args:
          keepdims (bool): return image of shape [H, W, 1] instead of [H, W]
          rgb (bool): interpret input as RGB instead of the default BGR
          keepshape (bool): whether to duplicate the gray image into 3 channels
              so the result has the same shape as input.
      """
      mode = cv2.COLOR_RGB2GRAY if rgb else cv2.COLOR_BGR2GRAY
      if keepshape:
          assert keepdims, "keepdims must be True when keepshape==True"
      super(Grayscale, self).__init__(mode, keepdims)
      self.keepshape = keepshape
      self.rgb = rgb
  
file_path: tensorpack/tensorpack/dataflow/imgaug/convert.py
imports: import numpy
  import cv2
  from .base import PhotometricAugmentor
label_desc: Use image node_id 1 to create a new Grayscale object from inherited base classes: ColorSpace with example: obj = Grayscale(keepdims, rgb, keepshape)