code: def detect_normal(
      self,
      input_image: np.ndarray,
      a: float = math.pi * 2.0,
      bg_th: float = 0.1,
  ) -> np.ndarray:
      assert input_image.ndim == 3
      image_depth = input_image
      with torch.no_grad():
          image_depth = self.to_self(torch.from_numpy(image_depth))
          image_depth = image_depth / 127.5 - 1.0
          image_depth = (
              image_depth[None].permute(0, 3, 1, 2).contiguous()
          )
          depth = self.model(image_depth)[0]
  
          depth_pt = depth.clone()
          depth_pt -= torch.min(depth_pt)
          depth_pt /= torch.max(depth_pt)
          depth_pt = depth_pt.cpu().numpy()
  
          depth_np = depth.cpu().numpy()
          x = cv2.Sobel(depth_np, cv2.CV_32F, 1, 0, ksize=3)
          y = cv2.Sobel(depth_np, cv2.CV_32F, 0, 1, ksize=3)
          z = np.ones_like(x) * a
          x[depth_pt < bg_th] = 0
          y[depth_pt < bg_th] = 0
          normal = np.stack([x, y, z], axis=2)
          normal /= np.sum(normal**2.0, axis=2, keepdims=True) ** 0.5
          normal_image = (
              (normal * 127.5 + 127.5).clip(0, 255).astype(np.uint8)
          )
  
          return normal_image
  
imports: import math
  import torch
  import numpy
  import torch.nn
  from torchvision.transforms import Compose
  from .core.dpt_depth import DPTDepthModel
  from .core.midas_net import MidasNet
  from .core.midas_net_custom import MidasNet_small
  from .core.transforms import Resize, NormalizeImage, PrepareForNet
  from .....misc.toolkit import download_model
label_desc: Use image node_id 6 for calling the MiDaSAPI obj's underlying member method code with example usage: obj.detect_normal(input_image, a, bg_th) and returns: normal_image