code: def show_seg_result(img, result, palette=None, is_demo=False):
      if palette is None:
          palette = np.random.randint(0, 255, size=(3, 3))
      palette[0] = [0, 0, 0]
      palette[1] = [0, 255, 0]
      palette[2] = [255, 0, 0]
      palette = np.array(palette)
      assert palette.shape[0] == 3  # len(classes)
      assert palette.shape[1] == 3
      assert len(palette.shape) == 2
  
      if not is_demo:
          color_seg = np.zeros(
              (result.shape[0], result.shape[1], 3), dtype=np.uint8
          )
          for label, color in enumerate(palette):
              color_seg[result == label, :] = color
      else:
          color_area = np.zeros(
              (result[0].shape[0], result[0].shape[1], 3),
              dtype=np.uint8,
          )
  
          color_area[result[0] == 1] = [0, 255, 0]
          color_area[result[1] == 1] = [255, 0, 0]
          color_seg = color_area
  
      # convert to BGR
      color_seg = color_seg[..., ::-1]
      # print(color_seg.shape)
      color_mask = np.mean(color_seg, 2)
      img[color_mask != 0] = (
          img[color_mask != 0] * 0.5 + color_seg[color_mask != 0] * 0.5
      )
  
imports: import glob
  import logging
  import os
  import re
  import time
  from pathlib import Path
  from typing import List
  import cv2
  import numpy
  import torch
  import torchvision
  from norfair import Detection
label_desc: Use image node_id 13 for calling a global function with example usage: show_seg_result(img, result, palette, is_demo) without return types