class_docstr: ### Text to image class
class_docstr_tok: ["#","#","#","Text","to","image","class"]
docstr: :param checkpoint_path: is the path of the checkpoint
  :param sampler_name: is the name of the [sampler](../sampler/index.html)
  :param n_steps: is the number of sampling steps
  :param ddim_eta: is the [DDIM sampling](../sampler/ddim.html) $\eta$ constant
docstr_tok: [":","param","checkpoint_path",":","is","the","path","of","the","checkpoint",":","param","sampler_name",":","is","the","name","of","the","[","sampler","]","(","..","\/sampler\/index.html",")",":","param","n_steps",":","is","the","number","of","sampling","steps",":","param","ddim_eta",":","is","the","[","DDIM","sampling","]","(","..","\/sampler\/ddim.html",")","$","\\eta","$","constant"]
code: def __init__(
      self,
      *,
      checkpoint_path: Path,
      sampler_name: str,
      n_steps: int = 50,
      ddim_eta: float = 0.0,
  ):
      """
      :param checkpoint_path: is the path of the checkpoint
      :param sampler_name: is the name of the [sampler](../sampler/index.html)
      :param n_steps: is the number of sampling steps
      :param ddim_eta: is the [DDIM sampling](../sampler/ddim.html) $\eta$ constant
      """
      # Load [latent diffusion model](../latent_diffusion.html)
      self.model = load_model(checkpoint_path)
      # Get device
      self.device = (
          torch.device("cuda:0")
          if torch.cuda.is_available()
          else torch.device("cpu")
      )
      # Move the model to device
      self.model.to(self.device)
  
      # Initialize [sampler](../sampler/index.html)
      if sampler_name == "ddim":
          self.sampler = DDIMSampler(
              self.model, n_steps=n_steps, ddim_eta=ddim_eta
          )
      elif sampler_name == "ddpm":
          self.sampler = DDPMSampler(self.model)
  
file_path: annotated_deep_learning_paper_implementations/labml_nn/diffusion/stable_diffusion/scripts/text_to_image.py
imports: import argparse
  import os
  from pathlib import Path
  import torch
  from labml import lab, monit
  from labml_nn.diffusion.stable_diffusion.latent_diffusion import LatentDiffusion
  from labml_nn.diffusion.stable_diffusion.sampler.ddim import DDIMSampler
  from labml_nn.diffusion.stable_diffusion.sampler.ddpm import DDPMSampler
  from labml_nn.diffusion.stable_diffusion.util import load_model, save_images, set_seed
label_desc: Use image node_id 1 to create a new Txt2Img object  with example: obj = Txt2Img()