示例#1
0
def parse_arguments(arguments: List[str] = None):
    parser = argparse.ArgumentParser(description=__doc__)
    subparsers = parser.add_subparsers(title="Model", description="")

    # -- * -- Common Arguments & Each Model's Arguments -- * --
    CNNModel.add_arguments(parser, default_type="matting")
    matting_nets.MattingNetModel.add_arguments(parser)
    for class_name in matting_nets._available_nets:
        subparser = subparsers.add_parser(class_name)
        subparser.add_argument("--model",
                               default=class_name,
                               type=str,
                               help="DO NOT FIX ME")
        add_matting_net_arguments = eval(
            "matting_nets.{}.add_arguments".format(class_name))
        add_matting_net_arguments(subparser)

    Evaluator.add_arguments(parser)
    Base.add_arguments(parser)
    DataWrapperBase.add_arguments(parser)
    MattingDataWrapper.add_arguments(parser)
    MetricManagerBase.add_arguments(parser)

    args = parser.parse_args(arguments)

    model_arguments = utils.get_subparser_argument_list(parser, args.model)
    args.model_arguments = model_arguments

    return args
示例#2
0
def parse_arguments(arguments: List[str] = None):
    parser = argparse.ArgumentParser(description=__doc__)
    subparsers = parser.add_subparsers(title="Model", description="")

    TFModel.add_arguments(parser)
    audio_nets.AudioNetModel.add_arguments(parser)

    for class_name in audio_nets._available_nets:
        subparser = subparsers.add_parser(class_name)
        subparser.add_argument("--model",
                               default=class_name,
                               type=str,
                               help="DO NOT FIX ME")
        add_audio_net_arguments = eval(
            f"audio_nets.{class_name}.add_arguments")
        add_audio_net_arguments(subparser)

    DataWrapperBase.add_arguments(parser)
    AudioDataWrapper.add_arguments(parser)
    Base.add_arguments(parser)
    TrainerBase.add_arguments(parser)
    SingleLabelAudioTrainer.add_arguments(parser)
    MetricManagerBase.add_arguments(parser)

    args = parser.parse_args(arguments)
    return args
示例#3
0
文件: train.py 项目: LGYoung/MMNet
def parse_arguments(arguments: List[str] = None):
    parser = argparse.ArgumentParser(description=__doc__)
    subparsers = parser.add_subparsers(title="Model", description="")

    # -- * -- Common Arguments & Each Model's Arguments -- * --
    CNNModel.add_arguments(parser, default_type="matting")
    matting_nets.MattingNetModel.add_arguments(parser)
    for class_name in matting_nets._available_nets:
        subparser = subparsers.add_parser(class_name)
        subparser.add_argument("--model",
                               default=class_name,
                               type=str,
                               help="DO NOT FIX ME")
        add_matting_net_arguments = eval(
            f"matting_nets.{class_name}.add_arguments")
        add_matting_net_arguments(subparser)

    # -- * -- Parameters & Options for MattingTrainer -- * --
    TrainerBase.add_arguments(parser)
    MattingTrainer.add_arguments(parser)
    Base.add_arguments(parser)
    DataWrapperBase.add_arguments(parser)
    MattingDataWrapper.add_arguments(parser)
    MetricManagerBase.add_arguments(parser)

    # -- Parse arguments
    args = parser.parse_args(arguments)

    # Hack!!! subparser's arguments and dynamically add it to args(Namespace)
    # it will be used for convert.py
    model_arguments = utils.get_subparser_argument_list(parser, args.model)
    args.model_arguments = model_arguments

    return args
示例#4
0
    def __init__(self, model, session, args, dataset, dataset_name, name):
        self.log = get_logger(name)

        self.model = model
        self.session = session
        self.args = args
        self.dataset = dataset
        self.dataset_name = dataset_name

        if Path(self.args.checkpoint_path).is_dir():
            latest_checkpoint = tf.train.latest_checkpoint(
                self.args.checkpoint_path)
            if latest_checkpoint is not None:
                self.args.checkpoint_path = latest_checkpoint
            self.log.info(
                f"Get latest checkpoint and update to it: {self.args.checkpoint_path}"
            )

        self.watch_path = self._build_watch_path()

        self.variables_to_restore = Base.get_variables_to_restore(
            args=self.args, log=self.log, debug=False)
        self.session.run(tf.global_variables_initializer())
        self.session.run(tf.local_variables_initializer())

        self.ckpt_loader = Ckpt(
            session=session,
            variables_to_restore=self.variables_to_restore,
            include_scopes=args.checkpoint_include_scopes,
            exclude_scopes=args.checkpoint_exclude_scopes,
            ignore_missing_vars=args.ignore_missing_vars,
        )
示例#5
0
            "logger": log,
        }

        for ckpt_path in ckpt_iterator(evaluator.watch_path, **kwargs):
            log.info(f"[watch] {ckpt_path}")

            evaluator.evaluate_once(ckpt_path)
    else:
        raise ValueError(f"Undefined valid_type: {args.valid_type}")


if __name__ == "__main__":
    parser = argparse.ArgumentParser(description=__doc__)
    subparsers = parser.add_subparsers(title="Model", description="")

    Base.add_arguments(parser)
    Evaluator.add_arguments(parser)
    DataWrapperBase.add_arguments(parser)
    AudioDataWrapper.add_arguments(parser)
    TFModel.add_arguments(parser)
    audio_nets.AudioNetModel.add_arguments(parser)
    MetricManagerBase.add_arguments(parser)

    for class_name in audio_nets._available_nets:
        subparser = subparsers.add_parser(class_name)
        subparser.add_argument("--model", default=class_name, type=str, help="DO NOT FIX ME")
        add_audio_arguments = eval("audio_nets.{}.add_arguments".format(class_name))
        add_audio_arguments(subparser)

    args = parser.parse_args()