class_docstr: CenterNet network using Hourglass from https://arxiv.org/abs/1904.07850S.
class_docstr_tok: ["CenterNet","network","using","Hourglass","from","https",":","\/\/arxiv.org\/abs\/1904.07850S","."]
docstr: Load checkpoint.
docstr_tok: ["Load","checkpoint","."]
code: def load_ckpt(
      self,
      checkpoint_dir_or_checkpoint_file_path,
      network_no_heads=None,
  ):
      """Load checkpoint."""
  
      def _load_ckpt(network, checkpoint_dir_or_checkpoint_file_path):
          """Load checkpoint helper.
  
          Args:
            network: Load weights in this network
            checkpoint_dir_or_checkpoint_file_path: Provide the path to a directory
              for checkpoints saved using save_weights(). Provide the path to a
              checkpoint file for checkpoints saved using tf.Checkpoint()
          Returns:
            A network
          """
          start = time.time()
          print(
              f"Loading pretrained checkpoint from "
              f"{checkpoint_dir_or_checkpoint_file_path}"
          )
          try:
              if checkpoint_dir_or_checkpoint_file_path[-1] != "/":
                  checkpoint_dir = (
                      f"{checkpoint_dir_or_checkpoint_file_path}/"
                  )
              else:
                  checkpoint_dir = (
                      checkpoint_dir_or_checkpoint_file_path
                  )
              network.load_weights(checkpoint_dir)
          except tf.errors.NotFoundError:
              checkpoint = tf.train.Checkpoint(model=network)
              checkpoint.restore(checkpoint_dir_or_checkpoint_file_path)
          print(f"Checkpoint loaded in {time.time() - start} seconds.")
          return network
  
      if network_no_heads is not None:
          network_no_head = _load_ckpt(
              network_no_heads, checkpoint_dir_or_checkpoint_file_path
          )
          tmp_ckpt = tf.train.Checkpoint(model=network_no_head)
          tmp_ckpt_file = os.path.join(
              self._get_ckpt_dir(
                  checkpoint_dir_or_checkpoint_file_path
              ),
              self._get_tmp_name(),
              "tmp",
          )
          tmp_ckpt.save(tmp_ckpt_file)
          checkpoint_dir_or_checkpoint_file_path = f"{tmp_ckpt_file}-1"
      self.network = _load_ckpt(
          self.network, checkpoint_dir_or_checkpoint_file_path
      )
      if network_no_heads is not None:
          gfile.DeleteRecursively(
              os.path.dirname(checkpoint_dir_or_checkpoint_file_path)
          )
          del network_no_heads
  
imports: import collections
  import os
  import random
  import string
  import time
  from absl import logging
  import numpy
  import tensorflow
  from tensorflow_graphics.projects.points_to_3Dobjects.models import centernet_utils
  from tensorflow_graphics.projects.points_to_3Dobjects.networks import hourglass
  from tensorflow_graphics.projects.points_to_3Dobjects.transforms import transforms
  from tensorflow_graphics.projects.points_to_3Dobjects.utils import image
  from google3.pyglib import gfile
label_desc: Use image node_id 4 for calling the CenterNetVID obj's underlying member method code with example usage: obj.load_ckpt(checkpoint_dir_or_checkpoint_file_path, network_no_heads) and returns: network