Пример #1
0
def test_frcnn_estimator():
    from gluoncv.auto.estimators import FasterRCNNEstimator
    est = FasterRCNNEstimator({'train': {'epochs': 1}, 'gpus': list(range(get_gpu_count()))})
    res = est.fit(OBJECT_DETCTION_DATASET)
    assert res.get('valid_map', 0) > 0
    _, _, test_data = OBJECT_DETCTION_DATASET.random_split()
    test_result = est.predict(test_data)
    evaluate_result = est.evaluate(test_data)
Пример #2
0
def test_frcnn_estimator():
    from gluoncv.auto.estimators import FasterRCNNEstimator
    est = FasterRCNNEstimator({
        'train': {
            'epochs': 1
        },
        'gpus': list(range(get_gpu_count()))
    })
    res = est.fit(OBJECT_DETCTION_DATASET)
    assert res.get('valid_map', 0) > 0
Пример #3
0
def test_frcnn_estimator():
    from gluoncv.auto.estimators import FasterRCNNEstimator
    est = FasterRCNNEstimator({
        'train': {
            'epochs': 1
        },
        'gpus': list(range(get_gpu_count()))
    })
    OBJECT_DETECTION_TRAIN_MINI, OBJECT_DETECTION_VAL_MINI, OBJECT_DETECTION_TEST_MINI = OBJECT_DETECTION_TRAIN.random_split(
        val_size=0.3, test_size=0.2)
    res = est.fit(OBJECT_DETECTION_TRAIN_MINI)
    assert res.get('valid_map', 0) > 0
    test_result = est.predict(OBJECT_DETECTION_TEST_MINI)
    evaluate_result = est.evaluate(OBJECT_DETECTION_VAL_MINI)
Пример #4
0
def test_frcnn_estimator():
    from gluoncv.auto.estimators import FasterRCNNEstimator
    est = FasterRCNNEstimator({'train': {'epochs': 1}, 'gpus': list(range(get_gpu_count()))})
    OBJECT_DETECTION_TRAIN_MINI, OBJECT_DETECTION_VAL_MINI, OBJECT_DETECTION_TEST_MINI = OBJECT_DETECTION_TRAIN.random_split(
        val_size=0.3, test_size=0.2)
    res = est.fit(OBJECT_DETECTION_TRAIN_MINI)
    assert res.get('valid_map', 0) > 0
    test_result = est.predict(OBJECT_DETECTION_TEST_MINI)
    est.predict(OBJECT_DETECTION_TEST.iloc[0]['image'])
    with Image.open(OBJECT_DETECTION_TEST.iloc[0]['image']) as pil_image:
        est.predict(pil_image)
    evaluate_result = est.evaluate(OBJECT_DETECTION_VAL_MINI)
    # test save/load
    _save_load_test(est, 'frcnn.pkl')
Пример #5
0
from gluoncv.auto.estimators import FasterRCNNEstimator
from gluoncv.auto.tasks.utils import config_to_nested
from d8.object_detection import Dataset

if __name__ == '__main__':
    # specify hyperparameters
    config = {
        'dataset': 'sheep',
        'gpus': [0, 1, 2, 3, 4, 5, 6, 7],
        'estimator': 'faster_rcnn',
        'base_network': 'resnet50_v1b',
        'batch_size': 8,  # range [8, 16, 32, 64]
        'epochs': 3
    }
    config = config_to_nested(config)
    config.pop('estimator')

    # specify dataset
    dataset = Dataset.get('sheep')
    train_data, valid_data = dataset.split(0.8)

    # specify estimator
    estimator = FasterRCNNEstimator(config)

    # fit estimator
    estimator.fit(train_data, valid_data)

    # evaluate auto estimator
    eval_map = estimator.evaluate(valid_data)
    logging.info('evaluation: mAP={}'.format(eval_map[-1][-1]))