コード例 #1
0
def test_task():
    dataset = Task.Dataset.from_voc('https://autogluon.s3.amazonaws.com/datasets/tiny_motorbike.zip')
    train_data, _, test_data = dataset.random_split()

    detector = Task()
    detector.fit(train_data, num_trials=1, hyperparameters={'batch_size': 4, 'epochs': 5, 'early_stop_max_value': 0.2})
    test_result = detector.predict(test_data)
    print('test result', test_result)
    detector.save('detector.ag')
    detector2 = Task.load('detector.ag')
    fit_summary = detector2.fit_summary()
    test_map = detector2.evaluate(test_data)
    test_result2 = detector2.predict(test_data)
    assert test_result2.equals(test_result)
コード例 #2
0
def test_task():
    dataset = Task.Dataset.from_voc('https://autogluon.s3.amazonaws.com/datasets/tiny_motorbike.zip')
    train_data, _, test_data = dataset.random_split()

    detector = Task()
    detector.fit(train_data, hyperparameters={'batch_size': 4, 'epochs': 5, 'early_stop_max_value': 0.2}, hyperparameter_tune_kwargs={'num_trials': 1})
    test_result = detector.predict(test_data)
    detector.save('detector.ag')
    detector2 = Task.load('detector.ag')
    fit_summary = detector2.fit_summary()
    test_map = detector2.evaluate(test_data)
    test_result2 = detector2.predict(test_data)
    assert test_result2.equals(test_result), f'{test_result2} != \n {test_result}'
    # to numpy
    test_result2 = detector2.predict(test_data, as_pandas=False)
コード例 #3
0
        config = yaml.safe_load(f)  # AutoGluon-specific config

    if args.n_gpus:
        config['num_gpus'] = int(args.n_gpus)

    # ---------------------------------------------------------------- Training

    train_dataset = ObjectDetector.Dataset.from_voc(config['dataset'],
                                                    splits='trainval')

    ag_predictor_args = config['ag_predictor_args']
    ag_predictor_args['path'] = args.model_dir
    ag_fit_args = config['ag_fit_args']

    print('Running training job with the config:')
    pprint(config)

    predictor = ObjectDetector(**ag_predictor_args).fit(
        train_dataset, **ag_fit_args)
    predictor.save(f'{args.model_dir}/predictor.pkl')

    # --------------------------------------------------------------- Inference

    test_dataset = ObjectDetector.Dataset.from_voc(config['dataset'],
                                                   splits='test')
    y_pred = predictor.predict(test_dataset)
    if config.get('output_prediction_format', 'csv') == 'parquet':
        y_pred.to_parquet(f'{args.output_data_dir}/predictions.parquet')
    else:
        y_pred.to_csv(f'{args.output_data_dir}/predictions.csv')
コード例 #4
0
ファイル: benchmark.py プロジェクト: sarah127/autogluon
                           [30, 35], [20]),
            'warmup_iters':
            ag.Int(5, 500),
            'wd':
            ag.Categorical(1e-4, 5e-4, 2.5e-4),
            'syncbn':
            True,
            'label_smooth':
            False,
            'epochs':
            ag.Categorical(30, 40, 50, 60),
            'transfer':
            transfer
        }
        kwargs = {
            'num_trials': args.num_trials,
            'nthreads_per_trial': 16,
            'ngpus_per_trial': 8,
            'time_limit': time_limit,
            'dist_ip_addrs': [],
            'hyperparameters': hyperparameters
        }
    else:
        raise NotImplementedError('%s is not implemented.', args.meta_arch)
    detector = ObjectDetector()
    detector.fit(dataset_train, **kwargs)
    test_map = detector.evaluate(dataset_test)
    print("mAP on test dataset: {}".format(test_map[-1][-1]))
    print(test_map)
    detector.save('final_model.model')
コード例 #5
0
from autogluon.vision import ObjectDetector

dataset_train = ObjectDetector.Dataset.from_voc('train_data', splits='train')

time_limit = 5 * 60 * 60  # 5 hour
detector = ObjectDetector()
hyperparameters = {'batch_size': 4, 'epochs': 2}
detector.fit(dataset_train,
             time_limit=time_limit,
             hyperparameters=hyperparameters)

detector.save('enemy_detector.ag')