code: def overlay(frame, mask):
      mask = np.array(mask)
      frame = np.array(frame)
  
      tmp = cv2.cvtColor(mask, cv2.COLOR_RGB2GRAY)
      _, alpha = cv2.threshold(tmp, 0, 255, cv2.THRESH_BINARY)
      b, g, r = cv2.split(mask)
      rgba = [b, g, r, alpha]
      dst = cv2.merge(rgba, 4)
  
      # overlay mask on frame
      overlaid_image = cv2.addWeighted(frame, 0.4, dst, 0.1, 0)
      return overlaid_image
  
file_path: insightface/reconstruction/ostec/external/graphonomy/FaceHairMask/graphonomy_inference.py
imports: import cv2
  import torch
  import timeit
  import numpy
  from PIL import Image
  import torch.nn.functional
  from torch.autograd import Variable
  from torchvision import transforms
  from FaceHairMask import graph
  from FaceHairMask import graphonomy_process
label_desc: Use image node_id 2 for calling a global function with example usage: overlay(frame, mask) and returns: overlaid_image