# 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
        # multiple synsets.
      mesh_names = set()
      for mesh_path in mesh_paths:
        mesh_hash = os.path.basename(mesh_path).replace('.ply', '')
        synset = mesh_path.split('/')[-2]
        mesh_names.add('%s-%s' % (synset, mesh_hash))
      if all_mesh_names is None:
        all_mesh_names = mesh_names
      else:
        all_mesh_names = all_mesh_names.intersection(mesh_names)
    if ensure_nonempty and not all_mesh_names:
      raise ValueError('There are 0 meshes common to the xids %i for split %s' %
                       (repr(self.experiment.visible_xids), split))
    self._remote_mesh_names = list(all_mesh_names)
    return list(all_mesh_names)

  def copy_meshes(self, mesh_names, split, overwrite_if_present=True):
    """Copies meshes from the remote store to the local cache."""
    for xid in self.experiment.visible_xids:
      log.verbose('Copying filelist for xid #%i...' % xid)
      for mesh_name in mesh_names:
        local_path = self.local_path_to_mesh(mesh_name, xid, split)
        if os.path.isfile(local_path) and not overwrite_if_present:
          continue
        local_dir = os.path.dirname(local_path)
        if not os.path.isdir(local_dir):
          os.makedirs(local_dir)
        remote_path = self.remote_path_to_mesh(mesh_name, xid, split)
        if file_util.exists(local_path):
          file_util.rm(local_path)

# 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

        # multiple synsets.
      mesh_names = set()
      for mesh_path in mesh_paths:
        mesh_hash = os.path.basename(mesh_path).replace('.ply', '')
        synset = mesh_path.split('/')[-2]
        mesh_names.add('%s-%s' % (synset, mesh_hash))
      if all_mesh_names is None:
        all_mesh_names = mesh_names
      else:
        all_mesh_names = all_mesh_names.intersection(mesh_names)
    if ensure_nonempty and not all_mesh_names:
      raise ValueError('There are 0 meshes common to the xids %i for split %s' %
                       (repr(self.experiment.visible_xids), split))
    self._remote_mesh_names = list(all_mesh_names)
    return list(all_mesh_names)

  def copy_meshes(self, mesh_names, split, overwrite_if_present=True):
    """Copies meshes from the remote store to the local cache."""
    for xid in self.experiment.visible_xids:
      log.verbose('Copying filelist for xid #%i...' % xid)
      for mesh_name in mesh_names:
        local_path = self.local_path_to_mesh(mesh_name, xid, split)
        if os.path.isfile(local_path) and not overwrite_if_present:
          continue
        local_dir = os.path.dirname(local_path)
        if not os.path.isdir(local_dir):
          os.makedirs(local_dir)
        remote_path = self.remote_path_to_mesh(mesh_name, xid, split)
        if file_util.exists(local_path):
          file_util.rm(local_path)

        file_util.cp(remote_path, local_path)