示例#1
0
文件: get_data.py 项目: MMKrell/demos
def main(unused_argv):
    try:
        for d in ['checkpoint', 'target']:
            # Pull the required training checkpoints and models from GCS.
            dst = os.path.join(FLAGS.dst_dir, d)
            src = os.path.join(FLAGS.src_dir, d)
            utils.ensure_dir_exists(dst)
            utils.wait(utils.checked_run('gsutil', '-m', 'cp', '-r', src, dst))

        # Freeze the target model.
        freeze_graph(os.path.join(FLAGS.dst_dir, 'target', 'target', 'target'))

        # Freeze the training checkpoint models.
        pattern = os.path.join(FLAGS.dst_dir, 'checkpoint', 'checkpoint',
                               'work_dir', 'work_dir', '*.index')
        patterns = glob.glob(pattern)
        if not patterns:
            raise FileNotFoundError("No files found in {}.".format(pattern))
        for path in patterns:
            # Avoid refreezing previously created checkpoint file.
            if "raw.ckpt" not in path:
                freeze_graph(os.path.splitext(path)[0])

    finally:
        asyncio.get_event_loop().close()
示例#2
0
def main(unused_argv):
  try:
    for d in ['checkpoint', 'target']:
      # Pull the required training checkpoints and models from GCS.
      src = os.path.join(FLAGS.src_dir, d, N)
      dst = os.path.join(FLAGS.dst_dir, d)
      utils.ensure_dir_exists(dst)
      utils.wait(utils.checked_run(None, 'gsutil', '-m', 'cp', '-r', src, dst))

    # Freeze the target model.
    freeze_graph(os.path.join(FLAGS.dst_dir, 'target', N, 'target'), 2048)

    # Freeze the training checkpoint models.
    pattern = os.path.join(FLAGS.dst_dir, 'checkpoint', N, 'work_dir', '*.index')
    for path in glob.glob(pattern):
      freeze_graph(os.path.splitext(path)[0], 2048)

  finally:
    asyncio.get_event_loop().close()
示例#3
0
def freeze_graph(path, batch=0):
  utils.wait(utils.checked_run(None,
      'python', 'freeze_graph.py',
      '--model_path={}'.format(path), '--trt_batch={}'.format(batch), '--use_tpu={}'.format(FLAGS.use_tpu)))
示例#4
0
文件: get_data.py 项目: MMKrell/demos
def freeze_graph(path):
    utils.wait(
        utils.checked_run('python', 'freeze_graph.py',
                          '--model_path={}'.format(path),
                          '--use_tpu={}'.format(FLAGS.use_tpu)))