code: def read_image(path):
      """Helper function that reads in an image as a
      `NumPy <https://numpy.org/>`_ array. Equivalent to using
      `OpenCV <https://docs.opencv.org/master/>`_'s cv2.imread
      function and converting from BGR to RGB format.
  
      :param path: The path to the image.
      :type path: str
      :return: Image in NumPy array format
      :rtype: ndarray
  
      **Example**::
  
          >>> import matplotlib.pyplot as plt
          >>> from detecto.utils import read_image
  
          >>> image = read_image('image.jpg')
          >>> plt.imshow(image)
          >>> plt.show()
      """
      if not os.path.isfile(path):
          raise ValueError(f"Could not read image {path}")
  
      image = cv2.imread(path)
  
      try:
          rgb_image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
      except cv2.error as e:
          raise ValueError(f"Could not convert image color: {str(e)}")
  
      return rgb_image
  
file_path: detecto/detecto/utils.py
imports: import cv2
  import os
  import pandas
  import torch
  import xml.etree.ElementTree
  from glob import glob
  from torchvision import transforms
label_desc: Use image node_id 4 for calling a global function with example usage: read_image(path) and returns: rgb_image