Example #1
0
def main(argv=None):
    check_args(FLAGS)
    if FLAGS.multigpu == 'n':

        if FLAGS.mode == 'train':
            from train import train_model
            train_model(FLAGS)
        elif FLAGS.mode == 'save_pb':
            from save_model import load_weights_save_pb
            load_weights_save_pb(FLAGS)
        elif FLAGS.mode == 'eval':
            from eval import eval_model
            eval_model(FLAGS)
    elif FLAGS.multigpu == 'y':
        if FLAGS.mode == 'train':
            from multigpu_train import train_model
            train_model(FLAGS)
        elif FLAGS.mode == 'save_pb':
            from save_multigpu_model import load_weights_save_pb
            load_weights_save_pb(FLAGS)
        elif FLAGS.mode == 'eval':
            from eval import eval_model
            eval_model(FLAGS)
    else:
        raise Exception('Please use true option of multigpu')
Example #2
0
def main(argv=None):
    check_args(FLAGS)

    # Create some local cache directories used for transfer data between local path and OBS path
    if not FLAGS.data_url.startswith('s3://'):
        FLAGS.data_local = FLAGS.data_url
    else:
        FLAGS.data_local = os.path.join(FLAGS.local_data_root, 'train_data/')
        if not os.path.exists(FLAGS.data_local):
            mox.file.copy_parallel(FLAGS.data_url, FLAGS.data_local)

            # 如果自己的模型需要加载预训练参数文件,可以先手动将参数文件从外网下载到自己的机器本地,再上传到OBS
            # 然后用下面的代码,将OBS上的预训练参数文件拷贝到 ModelArts 平台训练代码所在的目录
            # 拷贝代码格式为 mox.file.copy(src_path, dst_path),其中dst_path不能是目录,必须是一个具体的文件名
            # mox.file.copy('s3://your_obs_path/imagenet_class_index.json',
            #               os.path.dirname(os.path.abspath(__file__)) + '/models/imagenet_class_index.json')
            # mox.file.copy('s3://your_obs_path/resnet50_weights_tf_dim_ordering_tf_kernels_notop.h5',
            #               os.path.dirname(os.path.abspath(__file__)) + '/models/resnet50_weights_tf_dim_ordering_tf_kernels_notop.h5')
        else:
            print('FLAGS.data_local: %s is already exist, skip copy' %
                  FLAGS.data_local)

    if not FLAGS.train_url.startswith('s3://'):
        FLAGS.train_local = FLAGS.train_url
    else:
        FLAGS.train_local = os.path.join(FLAGS.local_data_root,
                                         'model_snapshots/')
        if not os.path.exists(FLAGS.train_local):
            os.mkdir(FLAGS.train_local)

    if not FLAGS.test_data_url.startswith('s3://'):
        FLAGS.test_data_local = FLAGS.test_data_url
    else:
        FLAGS.test_data_local = os.path.join(FLAGS.local_data_root,
                                             'test_data/')
        if not os.path.exists(FLAGS.test_data_local):
            mox.file.copy_parallel(FLAGS.test_data_url, FLAGS.test_data_local)
        else:
            print('FLAGS.test_data_local: %s is already exist, skip copy' %
                  FLAGS.test_data_local)

    FLAGS.tmp = os.path.join(FLAGS.local_data_root, 'tmp/')
    if not os.path.exists(FLAGS.tmp):
        os.mkdir(FLAGS.tmp)

    if FLAGS.mode == 'train':
        from train import train_model
        train_model(FLAGS)
    elif FLAGS.mode == 'save_pb':
        from save_model import load_weights_save_pb
        load_weights_save_pb(FLAGS)
    elif FLAGS.mode == 'eval':
        from eval import eval_model
        eval_model(FLAGS)
Example #3
0
def main(argv=None):
    check_args(FLAGS)

    # Create some local cache directories used for transfer data between local path and OBS path
    if not FLAGS.data_url.startswith('s3://'):
        FLAGS.data_local = FLAGS.data_url
    else:
        FLAGS.data_local = os.path.join(FLAGS.local_data_root, 'train_data/')
        if not os.path.exists(FLAGS.data_local):
            pass
            # file.copy_parallel(FLAGS.data_url, FLAGS.data_local)
        else:
            print('FLAGS.data_local: %s is already exist, skip copy' %
                  FLAGS.data_local)

    if not FLAGS.train_url.startswith('s3://'):
        FLAGS.train_local = FLAGS.train_url
    else:
        FLAGS.train_local = os.path.join(FLAGS.local_data_root,
                                         'model_snapshots/')
        if not os.path.exists(FLAGS.train_local):
            os.mkdir(FLAGS.train_local)

    if not FLAGS.test_data_url.startswith('s3://'):
        FLAGS.test_data_local = FLAGS.test_data_url
    else:
        FLAGS.test_data_local = os.path.join(FLAGS.local_data_root,
                                             'test_data/')
        if not os.path.exists(FLAGS.test_data_local):
            pass
            #file.copy_parallel(FLAGS.test_data_url, FLAGS.test_data_local)
        else:
            print('FLAGS.test_data_local: %s is already exist, skip copy' %
                  FLAGS.test_data_local)

    FLAGS.tmp = os.path.join(FLAGS.local_data_root, 'tmp/')
    if not os.path.exists(FLAGS.tmp):
        os.mkdir(FLAGS.tmp)

    if FLAGS.mode == 'train':
        from train_eval import train_model
        train_model(FLAGS)
    elif FLAGS.mode == 'save_pb':
        from save_model import load_weights_save_pb
        load_weights_save_pb(FLAGS)
    elif FLAGS.mode == 'eval':
        from eval import eval_model
        eval_model(FLAGS)
Example #4
0
def main(argv=None):
    check_args(FLAGS)

    # Create some local cache directories used for transfer data between local path and OBS path
    FLAGS.data_local = FLAGS.data_url
    FLAGS.train_local = FLAGS.train_url
    FLAGS.test_data_local = FLAGS.test_data_url

    # FLAGS.tmp = os.path.join(FLAGS.local_data_root, 'tmp/')
    # print(FLAGS.tmp)
    # if not os.path.exists(FLAGS.tmp):
    #     os.mkdir(FLAGS.tmp)

    if FLAGS.mode == 'train':
        from train import train_model
        train_model(FLAGS)
    elif FLAGS.mode == 'save_pb':
        from save_model import load_weights_save_pb
        load_weights_save_pb(FLAGS)
    elif FLAGS.mode == 'eval':
        from eval import eval_model
        eval_model(FLAGS)