code: def convert_to_pil_image(image, drange=[0, 1]):
      assert image.ndim == 2 or image.ndim == 3
      if image.ndim == 3:
          if image.shape[0] == 1:
              image = image[0]  # grayscale CHW => HW
          else:
              image = image.transpose(1, 2, 0)  # CHW -> HWC
  
      image = adjust_dynamic_range(image, drange, [0, 255])
      image = np.rint(image).clip(0, 255).astype(np.uint8)
      fmt = "RGB" if image.ndim == 3 else "L"
      return PIL.Image.fromarray(image, fmt)
  
file_path: insightface/reconstruction/ostec/external/stylegan2/training/misc.py
imports: import os
  import pickle
  import numpy
  import PIL.Image
  import PIL.ImageFont
  import dnnlib
label_desc: Use image node_id 6 for calling a global function with example usage: convert_to_pil_image(image, drange) and returns: PIL