(config_map, data_fn)
Run the infer script.
Run the infer script.
Run the infer script .
def run(config_map, data_fn):
  """Run the infer script."""
  output_dir = os.path.expanduser(FLAGS.output_dir)

  config = config_map[FLAGS.config]
  hparams = config.hparams
  hparams.parse(FLAGS.hparams)

  # Batch size should always be 1 for inference.
  hparams.batch_size = 1

  tf.logging.info(hparams)

  tf.gfile.MakeDirs(output_dir)

  summary_writer = tf.summary.FileWriter(logdir=output_dir)

  with tf.Session():
    run_config = '\n\n'.join([
        'model_dir: ' + FLAGS.model_dir,
        'checkpoint_path: ' + str(FLAGS.checkpoint_path),
        'examples_path: ' + FLAGS.examples_path,
        str(hparams),
    ])
    run_config_summary = tf.summary.text(
        'run_config',
        tf.constant(run_config, name='run_config'),
        collections=[])
    summary_writer.add_summary(run_config_summary.eval())

  model_inference(
      model_fn=config.model_fn,
      model_dir=FLAGS.model_dir,
      checkpoint_path=FLAGS.checkpoint_path,
      data_fn=data_fn,
      hparams=hparams,
      examples_path=FLAGS.examples_path,
      output_dir=output_dir,
      summary_writer=summary_writer,
      preprocess_examples=FLAGS.preprocess_examples,
      master=FLAGS.master,
      shuffle_examples=FLAGS.shuffle_examples)
def run ( config_map , data_fn ) : output_dir = os . path . expanduser ( FLAGS . output_dir ) config = config_map [ FLAGS . config ] hparams = config . hparams hparams . parse ( FLAGS . hparams ) # Batch size should always be 1 for inference. hparams . batch_size = 1 tf . logging . info ( hparams ) tf . gfile . MakeDirs ( output_dir ) summary_writer = tf . summary . FileWriter ( logdir = output_dir ) with tf . Session ( ) : run_config = '\n\n' . join ( [ 'model_dir: ' + FLAGS . model_dir , 'checkpoint_path: ' + str ( FLAGS . checkpoint_path ) , 'examples_path: ' + FLAGS . examples_path , str ( hparams ) , ] ) run_config_summary = tf . summary . text ( 'run_config' , tf . constant ( run_config , name = 'run_config' ) , collections = [ ] ) summary_writer . add_summary ( run_config_summary . eval ( ) ) model_inference ( model_fn = config . model_fn , model_dir = FLAGS . model_dir , checkpoint_path = FLAGS . checkpoint_path , data_fn = data_fn , hparams = hparams , examples_path = FLAGS . examples_path , output_dir = output_dir , summary_writer = summary_writer , preprocess_examples = FLAGS . preprocess_examples , master = FLAGS . master , shuffle_examples = FLAGS . shuffle_examples )