Пример #1
0
def main(unused_argv):
  gan_lib.MODELS.update({
      "MultiGAN": multi_gan.MultiGAN,
      "MultiGANBackground": multi_gan_background.MultiGANBackground
  })
  params.PARAMETERS.update({
      "MultiGAN": multi_gan.MultiGANHyperParams,
      "MultiGANBackground": multi_gan_background.MultiGANBackgroundHyperParams
  })

  gan_lib.DATASETS.update(dataset.get_datasets())
  params.DATASET_PARAMS.update(dataset.get_dataset_params())

  task_workdir = FLAGS.eval_task_workdir

  task = simple_task_pb2.Task()
  with open(os.path.join(task_workdir, "task"), "r") as f:
    text_format.Parse(f.read(), task)

  options = task_utils.ParseOptions(task)

  out_dir = os.path.join(FLAGS.out_dir, GetModelDir(options))
  if not tf.gfile.IsDirectory(out_dir):
    tf.gfile.MakeDirs(out_dir)

  task_string = text_format.MessageToString(task)
  print("\nWill evaluate task\n%s\n\n", task_string)

  EvalTask(options, task_workdir, out_dir)
Пример #2
0
def MakeDimensions(dim_dict, extra_dims=None, base_task=None):
    """Creates a task proto from given dictionary."""
    task = simple_task_pb2.Task()
    if base_task is not None:
        task.MergeFrom(base_task)
    if extra_dims is not None:
        dim_dict = copy.copy(dim_dict)
        dim_dict.update(extra_dims)
    dim_dict = collections.OrderedDict(sorted(dim_dict.items()))
    for key, value in six.iteritems(dim_dict):
        if key in ("_proto", "_prefix"):
            # We skip the special keys.
            continue
        dimension = task.dimensions.add()
        dimension.parameter = key
        if isinstance(value, str):
            dimension.string_value = value
        elif isinstance(value, bool):
            dimension.bool_value = value
        elif isinstance(value, int):
            dimension.int_value = value
        elif isinstance(value, float):
            dimension.float_value = value
        elif isinstance(value, tuple):
            # Convert the tuple in a string
            dimension.string_value = str(value)
        else:
            # We skip the values that are of other type,
            # e.g. proto (this is the case of the "grid" argument that is
            # used in many functions).
            del task.dimensions[-1]
            continue
    return task
Пример #3
0
def GetTaskProtoFromCheckpoint(checkpoint_path):
    task_file = os.path.join(os.path.dirname(checkpoint_path), "../task")
    if not tf.gfile.Exists(task_file):
        logging.warning("Cant find task_file at %s", task_file)
        assert False, "Task file %s not found." % task_file
    content = tf.gfile.Open(task_file, mode="r").read()
    return text_format.Parse(content, simple_task_pb2.Task())