Beispiel #1
0
def __main(default_config_file):
    """
    Run this script to train Timeception.
    """

    # Parse the arguments
    parser = OptionParser()  #创建OptionParser对象,用于设置参数配置文件
    #使用parser.add_option(...)待定义命令行参数,及其帮助文档
    parser.add_option(
        '-c',
        '--config_file',
        dest='config_file',
        default=default_config_file,
        help='Yaml config file that contains all training details.')
    (options, args) = parser.parse_args()
    #option: {'config_file': 'charades_i3d_tc2_f256.yaml'},args: []
    #options 是一个字典,其key字典中的关键字可能会是我们所有的add_option()函数中的dest参数值,其对应的value值,是命令行输入的对应的add_option()函数的参数值。
    #args,它是一个由 positional arguments 组成的列表。
    config_file = options.config_file  #'charades_i3d_tc2_f256.yaml'

    # check if exist,不存在进行警告
    if config_file is None or config_file == '':
        msg = 'Config file not passed, default config is used: %s' % (
            config_file)
        logging.warning(msg)
        config_file = default_config_file

    # path of config file
    config_path = './configs/%s' % (config_file
                                    )  #'./configs/charades_i3d_tc2_f256.yaml'

    # check if file exist不存在进行警告
    if not os.path.exists(config_path):
        msg = 'Sorry, could not find config file with the following path: %s' % (
            config_path)
        logging.error(msg)

    else:
        # read the config from file and copy it to the project configuration "cfg",从文件中读取配置并将其复制到项目配置“config。py”中
        config_utils.cfg_from_file(config_path)

        # choose which training scheme, either 'ete' or 'tco'
        training_scheme = config.cfg.TRAIN.SCHEME  #tco

        # start training
        if training_scheme == 'tco':
            train_tco()
        else:
            train_ete()
Beispiel #2
0
def __main():
    """
    Run this script to train Timeception.
    """

    # 默认的i3d配置文件,位于./configs目录下
    default_config_file = 'charades_i3d_tc4_f1024.yaml'
    default_config_file = 'charades_i3d_tc2_f256.yaml'

    # Parse the arguments
    parser = OptionParser()
    parser.add_option(
        '-c',
        '--config_file',
        dest='config_file',
        default=default_config_file,
        help='Yaml config file that contains all training details.')
    (options, args) = parser.parse_args()
    config_file = options.config_file

    # check if exist
    if config_file is None or config_file == '':
        msg = 'Config file not passed, default config is used: %s' % (
            config_file)
        logging.warning(msg)
        config_file = default_config_file

    # path of config file
    config_path = './configs/%s' % (config_file)

    # check if file exist
    if not os.path.exists(config_path):
        msg = 'Sorry, could not find config file with the following path: %s' % (
            config_path)
        logging.error(msg)
    else:
        # read the config from file and copy it to the project configuration "cfg"
        config_utils.cfg_from_file(config_path)  # 合并配置文件中的参数到配置中

        # choose which training scheme, either 'ete' or 'tco'
        training_scheme = config.cfg.TRAIN.SCHEME

        # start training
        if training_scheme == 'tco':
            train_tco()  # 只训练timecption
        else:
            train_ete()