class_docstr: Pipeline for monocular depth estimation using Marigold: https://marigoldmonodepth.github.io.
  
  This model inherits from [`DiffusionPipeline`]. Check the superclass documentation for the generic methods the
  library implements for all the pipelines (such as downloading or saving, running on a particular device, etc.)
  
  Args:
      unet (`UNet2DConditionModel`):
          Conditional U-Net to denoise the depth latent, conditioned on image latent.
      vae (`AutoencoderKL`):
          Variational Auto-Encoder (VAE) Model to encode and decode images and depth maps
          to and from latent representations.
      scheduler (`DDIMScheduler`):
          A scheduler to be used in combination with `unet` to denoise the encoded image latents.
      text_encoder (`CLIPTextModel`):
          Text-encoder, for empty text embedding.
      tokenizer (`CLIPTokenizer`):
          CLIP tokenizer.
class_docstr_tok: ["Pipeline","for","monocular","depth","estimation","using","Marigold",":","https",":","\/\/marigoldmonodepth.github.io",".","This","model","inherits","from","[","`","DiffusionPipeline","`","]",".","Check","the","superclass","documentation","for","the","generic","methods","the","library","implements","for","all","the","pipelines","(","such","as","downloading","or","saving",",","running","on","a","particular","device",",","etc",".",")","Args",":","unet","(","`","UNet2DConditionModel","`",")",":","Conditional","U-Net","to","denoise","the","depth","latent",",","conditioned","on","image","latent",".","vae","(","`","AutoencoderKL","`",")",":","Variational","Auto-Encoder","(","VAE",")","Model","to","encode","and","decode","images","and","depth","maps","to","and","from","latent","representations",".","scheduler","(","`","DDIMScheduler","`",")",":","A","scheduler","to","be","used","in","combination","with","`","unet","`","to","denoise","the","encoded","image","latents",".","text_encoder","(","`","CLIPTextModel","`",")",":","Text-encoder",",","for","empty","text","embedding",".","tokenizer","(","`","CLIPTokenizer","`",")",":","CLIP","tokenizer","."]
docstr: Perform an individual depth prediction without ensembling.
  
  Args:
      rgb_in (`torch.Tensor`):
          Input RGB image.
      num_inference_steps (`int`):
          Number of diffusion denoisign steps (DDIM) during inference.
      show_pbar (`bool`):
          Display a progress bar of diffusion denoising.
  Returns:
      `torch.Tensor`: Predicted depth map.
docstr_tok: ["Perform","an","individual","depth","prediction","without","ensembling",".","Args",":","rgb_in","(","`","torch.Tensor","`",")",":","Input","RGB","image",".","num_inference_steps","(","`","int","`",")",":","Number","of","diffusion","denoisign","steps","(","DDIM",")","during","inference",".","show_pbar","(","`","bool","`",")",":","Display","a","progress","bar","of","diffusion","denoising",".","Returns",":","`","torch.Tensor","`",":","Predicted","depth","map","."]
code: def single_infer(
      self,
      rgb_in: torch.Tensor,
      num_inference_steps: int,
      show_pbar: bool,
  ) -> torch.Tensor:
      """
      Perform an individual depth prediction without ensembling.
  
      Args:
          rgb_in (`torch.Tensor`):
              Input RGB image.
          num_inference_steps (`int`):
              Number of diffusion denoisign steps (DDIM) during inference.
          show_pbar (`bool`):
              Display a progress bar of diffusion denoising.
      Returns:
          `torch.Tensor`: Predicted depth map.
      """
      device = rgb_in.device
  
      # Set timesteps
      self.scheduler.set_timesteps(num_inference_steps, device=device)
      timesteps = self.scheduler.timesteps  # [T]
  
      # Encode image
      rgb_latent = self._encode_rgb(rgb_in)
  
      # Initial depth map (noise)
      depth_latent = torch.randn(
          rgb_latent.shape, device=device, dtype=self.dtype
      )  # [B, 4, h, w]
  
      # Batched empty text embedding
      if self.empty_text_embed is None:
          self._encode_empty_text()
      batch_empty_text_embed = self.empty_text_embed.repeat(
          (rgb_latent.shape[0], 1, 1)
      )  # [B, 2, 1024]
  
      # Denoising loop
      if show_pbar:
          iterable = tqdm(
              enumerate(timesteps),
              total=len(timesteps),
              leave=False,
              desc=" " * 4 + "Diffusion denoising",
          )
      else:
          iterable = enumerate(timesteps)
  
      for i, t in iterable:
          unet_input = torch.cat(
              [rgb_latent, depth_latent], dim=1
          )  # this order is important
  
          # predict the noise residual
          noise_pred = self.unet(
              unet_input,
              t,
              encoder_hidden_states=batch_empty_text_embed,
          ).sample  # [B, 4, h, w]
  
          # compute the previous noisy sample x_t -> x_t-1
          depth_latent = self.scheduler.step(
              noise_pred, t, depth_latent
          ).prev_sample
      torch.cuda.empty_cache()
      depth = self._decode_depth(depth_latent)
  
      # clip prediction
      depth = torch.clip(depth, -1.0, 1.0)
      # shift to [0, 1]
      depth = (depth + 1.0) / 2.0
  
      return depth
  
imports: import math
  from typing import Dict, Union
  import matplotlib
  import numpy
  import torch
  from PIL import Image
  from scipy.optimize import minimize
  from torch.utils.data import DataLoader, TensorDataset
  from tqdm.auto import tqdm
  from transformers import CLIPTextModel, CLIPTokenizer
  from diffusers import AutoencoderKL, DDIMScheduler, DiffusionPipeline, UNet2DConditionModel
  from diffusers.utils import BaseOutput, check_min_version
label_desc: Use image node_id 4 for calling the MarigoldPipeline obj's underlying member method code with example usage: obj.single_infer(rgb_in, num_inference_steps, show_pbar) and returns: depth