# 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():


import os
import time
import tensorflow as tf
from ldif.util import file_util
from ldif.util import path_util


def ensure_synset_valid(synset):
  if synset not in synset_to_cat:
    raise ValueError('Unrecognized synset: %s' % repr(synset))


def ensure_hash_valid(h):
  """This does not guarantee only hashes get through, it's best-effort."""
  passes = True
  if not isinstance(h, str):
    passes = False
  elif [x for x in h if x not in '0123456789abcdef-u']:
    passes = False
  if not passes:
    raise ValueError('Invalid hash: %s' % repr(h))


def parse_xid_to_ckpt(xid_to_ckpt):
  tokens = [int(x) for x in xid_to_ckpt.split(',')]
  xids = tokens[::2]
  ckpts = tokens[1::2]
  return {k: v for (k, v) in zip(xids, ckpts)}


def get_npz_paths(split, category, modifier=''):
  """Returns the list of npz paths for the split's ground truth."""
  t = time.time()
  ensure_split_valid(split)
  filelist = os.path.join(

# 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/inference/util.py
import os
import time
import tensorflow as tf
from ldif.util import file_util
from ldif.util import path_util



def ensure_synset_valid(synset):
  if synset not in synset_to_cat:
    raise ValueError('Unrecognized synset: %s' % repr(synset))


def ensure_hash_valid(h):
  """This does not guarantee only hashes get through, it's best-effort."""
  passes = True
  if not isinstance(h, str):
    passes = False
  elif [x for x in h if x not in '0123456789abcdef-u']:
    passes = False
  if not passes:
    raise ValueError('Invalid hash: %s' % repr(h))


def parse_xid_to_ckpt(xid_to_ckpt):
  tokens = [int(x) for x in xid_to_ckpt.split(',')]
  xids = tokens[::2]
  ckpts = tokens[1::2]
  return {k: v for (k, v) in zip(xids, ckpts)}


def get_npz_paths(split, category, modifier=''):
  """Returns the list of npz paths for the split's ground truth."""
  t = time.time()
  ensure_split_valid(split)
  filelist = os.path.join(

      path_util.get_path_to_ldif_root(),