code: def to_image_color(img: Image, target_mode: str):
      """
      convert images from one color-space to another, like BGR ↔ Gray, BGR ↔ HSV, etc.
      """
      # pylint: disable=import-outside-toplevel
      from towhee.utils.cv2_utils import cv2
  
      if not hasattr(img, "mode"):
          return img
      if img.mode == target_mode:
          return img
  
      flag_name = (
          "COLOR_" + img.mode.upper() + "2" + target_mode.upper()
      )
      flag = getattr(cv2, flag_name, None)
  
      if flag is None:
          raise ValueError(
              "Can not convert image from %s to %s."
              % (img.mode, target_mode)
          )
  
      return Image(cv2.cvtColor(img, flag), target_mode.upper())
  
imports: from towhee.types import Image
label_desc: Use image node_id 1 for calling a global function with example usage: to_image_color(img, target_mode) and returns: Image, img, img