# Path: ldif/model/hparams.py
# def backwards_compatible_hparam_defaults(ident):
# def tf_hparams_to_dict(tf_hparams):
# def build_ldif_hparams():
# def build_sif_hparams():
# def build_improved_sif_hparams():
# def build_singleview_depth_hparams():
# def write_hparams(hparams, path):
# def read_hparams_with_new_backwards_compatible_additions(path):
# def read_hparams(path):
# 
# Path: ldif/util/file_util.py
# def readlines(p):
# def readbin(p):
# def writebin(p, s):
# def writetxt(p, s):
# def write_np(path, arr):
# def read_grd(path):
# def read_sif_v1(path, verbose=False):
# def read_lines(p):
# def read_image(p):
# def read_npz(p):
# def read_np(p):
# def read_txt_to_np(p):
# def read_py2_pkl(p):
# def write_mesh(path, mesh):
# def read_mesh(path):
# def read_csv(path):
# def read_normals(path_to_dir, im_count=20, leading='_depth'):
# def write_points(path_ext_optional, points):
# def write_grd(path, volume, world2grid=None):
# def write_depth_image(path, depth_image):
# 
# Path: ldif/util/path_util.py
# def get_path_to_ldif_root():
# def get_path_to_ldif_parent():
# def package_to_abs(path):
# def gaps_path():
# def test_data_path():
# def util_test_data_path():
# def create_test_output_dir():
# 
# Path: ldif/util/file_util.py
# def readlines(p):
# def readbin(p):
# def writebin(p, s):
# def writetxt(p, s):
# def write_np(path, arr):
# def read_grd(path):
# def read_sif_v1(path, verbose=False):
# def read_lines(p):
# def read_image(p):
# def read_npz(p):
# def read_np(p):
# def read_txt_to_np(p):
# def read_py2_pkl(p):
# def write_mesh(path, mesh):
# def read_mesh(path):
# def read_csv(path):
# def read_normals(path_to_dir, im_count=20, leading='_depth'):
# def write_points(path_ext_optional, points):
# def write_grd(path, volume, world2grid=None):
# def write_depth_image(path, depth_image):


import importlib
import os
import numpy as np
from ldif.model import hparams as hparams_util
from ldif.util import file_util
from ldif.util import path_util
from ldif.util.file_util import log
  @property
  def newest_checkpoint(self):
    self.ensure_has_at_least_one_checkpoint()
    return self.all_checkpoints[-1]  # Sorted

  def k_evenly_spaced_checkpoints(self, k):
    """Returns k checkpoint objects distributed approximately evenly in step."""
    if k == 1:
      return self.newest_checkpoint
    elif k <= 0:
      raise ValueError('Invalid k: %i. k must be >= 1.' % k)
    elif self.checkpoint_count < 2 * k:
      raise ValueError(
          "Can't selected %i checkpoints when %i < 2*%i are present." %
          (k, self.checkpoint_count, k))
    else:
      chosen = np.linspace(start=0, stop=self.checkpoint_count, num=k)
      chosen = np.clip(chosen.astype(np.int32), 0, self.checkpoint_count - 1)
      chosen = list(chosen)
      return [self.all_checkpoints[i] for i in chosen]

  @property
  def hparams(self):
    """Load a tf.HParams() object based on the serialized hparams file."""
    if self._hparams is None:
      hparam_path = '%s/train/hparam_pickle.txt' % self.root_dir
      if file_util.exists(hparam_path):
        log.info('Found serialized hparams. Loading from %s' % hparam_path)
        # hparams = hparams_util.read_hparams(hparam_path)
        self._hparams = (

# Path: ldif/model/hparams.py
# def backwards_compatible_hparam_defaults(ident):
# def tf_hparams_to_dict(tf_hparams):
# def build_ldif_hparams():
# def build_sif_hparams():
# def build_improved_sif_hparams():
# def build_singleview_depth_hparams():
# def write_hparams(hparams, path):
# def read_hparams_with_new_backwards_compatible_additions(path):
# def read_hparams(path):
# 
# Path: ldif/util/file_util.py
# def readlines(p):
# def readbin(p):
# def writebin(p, s):
# def writetxt(p, s):
# def write_np(path, arr):
# def read_grd(path):
# def read_sif_v1(path, verbose=False):
# def read_lines(p):
# def read_image(p):
# def read_npz(p):
# def read_np(p):
# def read_txt_to_np(p):
# def read_py2_pkl(p):
# def write_mesh(path, mesh):
# def read_mesh(path):
# def read_csv(path):
# def read_normals(path_to_dir, im_count=20, leading='_depth'):
# def write_points(path_ext_optional, points):
# def write_grd(path, volume, world2grid=None):
# def write_depth_image(path, depth_image):
# 
# Path: ldif/util/path_util.py
# def get_path_to_ldif_root():
# def get_path_to_ldif_parent():
# def package_to_abs(path):
# def gaps_path():
# def test_data_path():
# def util_test_data_path():
# def create_test_output_dir():
# 
# Path: ldif/util/file_util.py
# def readlines(p):
# def readbin(p):
# def writebin(p, s):
# def writetxt(p, s):
# def write_np(path, arr):
# def read_grd(path):
# def read_sif_v1(path, verbose=False):
# def read_lines(p):
# def read_image(p):
# def read_npz(p):
# def read_np(p):
# def read_txt_to_np(p):
# def read_py2_pkl(p):
# def write_mesh(path, mesh):
# def read_mesh(path):
# def read_csv(path):
# def read_normals(path_to_dir, im_count=20, leading='_depth'):
# def write_points(path_ext_optional, points):
# def write_grd(path, volume, world2grid=None):
# def write_depth_image(path, depth_image):


# Path: ldif/inference/experiment.py
import importlib
import os
import numpy as np
from ldif.model import hparams as hparams_util
from ldif.util import file_util
from ldif.util import path_util
from ldif.util.file_util import log

  @property
  def newest_checkpoint(self):
    self.ensure_has_at_least_one_checkpoint()
    return self.all_checkpoints[-1]  # Sorted

  def k_evenly_spaced_checkpoints(self, k):
    """Returns k checkpoint objects distributed approximately evenly in step."""
    if k == 1:
      return self.newest_checkpoint
    elif k <= 0:
      raise ValueError('Invalid k: %i. k must be >= 1.' % k)
    elif self.checkpoint_count < 2 * k:
      raise ValueError(
          "Can't selected %i checkpoints when %i < 2*%i are present." %
          (k, self.checkpoint_count, k))
    else:
      chosen = np.linspace(start=0, stop=self.checkpoint_count, num=k)
      chosen = np.clip(chosen.astype(np.int32), 0, self.checkpoint_count - 1)
      chosen = list(chosen)
      return [self.all_checkpoints[i] for i in chosen]

  @property
  def hparams(self):
    """Load a tf.HParams() object based on the serialized hparams file."""
    if self._hparams is None:
      hparam_path = '%s/train/hparam_pickle.txt' % self.root_dir
      if file_util.exists(hparam_path):
        log.info('Found serialized hparams. Loading from %s' % hparam_path)
        # hparams = hparams_util.read_hparams(hparam_path)
        self._hparams = (

            hparams_util.read_hparams_with_new_backwards_compatible_additions(