def get_outpainting_composite_mask(video_height: int,
                                   video_width: int,
                                   uncrop_t: int = 0,
                                   uncrop_b: int = 0,
                                   uncrop_l: int = 0,
                                   uncrop_r: int = 0,
                                   blending_pixels: int = 8):
  """Get outpainting composite mask with linear alpha blending.

  Use in this way.
  output = composit_mask * org_video + (1.0 - composit_mask) * gen_video
  for videos of shape (frames, height, width, 3)

  Args:
    video_height: Height of the video
    video_width: Width of the video
    uncrop_t: Number of uncrop pixels from the top
    uncrop_b: Number of uncrop pixels from the bottom
    uncrop_l: Number of uncrop pixels from the left
    uncrop_r: Number of uncrop pixels from the right
    blending_pixels: Number of pixels to do alpha blending

  Returns:
    Composite mask to use to merge original and new video.
  """
  composit_mask = np.zeros((1, video_height, video_width, 3))
  composit_mask[:, uncrop_t:video_height - uncrop_b,
                uncrop_l:video_width - uncrop_r] = 1
  for i in range(blending_pixels):
    if uncrop_t != 0:
      composit_mask[:, uncrop_t + i,
                    uncrop_l:video_width - uncrop_r] = i / blending_pixels
    if uncrop_b != 0:
      composit_mask[:, video_height - uncrop_b - i - 1,
                    uncrop_l:video_width - uncrop_r] = i / blending_pixels
    if uncrop_l != 0:
      composit_mask[:, uncrop_t:video_height - uncrop_b,
                    uncrop_l + i] = i / blending_pixels
    if uncrop_r != 0:
      composit_mask[:, uncrop_t:video_height - uncrop_b,
                    video_width - uncrop_r - i - 1] = i / blending_pixels
  return composit_mask
Get outpainting composite mask with linear alpha blending.

  Use in this way.
  output = composit_mask * org_video + (1.0 - composit_mask) * gen_video
  for videos of shape (frames, height, width, 3)

  Args:
    video_height: Height of the video
    video_width: Width of the video
    uncrop_t: Number of uncrop pixels from the top
    uncrop_b: Number of uncrop pixels from the bottom
    uncrop_l: Number of uncrop pixels from the left
    uncrop_r: Number of uncrop pixels from the right
    blending_pixels: Number of pixels to do alpha blending

  Returns:
    Composite mask to use to merge original and new video.
  
videogvt/interfaces/colab_utils.py