def test_ssd_estimator(): from gluoncv.auto.estimators import SSDEstimator est = SSDEstimator({'train': {'epochs': 1, 'batch_size': 8}, '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)
def test_ssd_estimator(): from gluoncv.auto.estimators import SSDEstimator est = SSDEstimator({ 'train': { 'epochs': 1, 'batch_size': 8 }, 'gpus': list(range(get_gpu_count())) }) res = est.fit(OBJECT_DETCTION_DATASET) assert res.get('valid_map', 0) > 0
def test_ssd_estimator(): from gluoncv.auto.estimators import SSDEstimator est = SSDEstimator({ 'train': { 'epochs': 1, 'batch_size': 8 }, 'gpus': list(range(get_gpu_count())) }) res = est.fit(OBJECT_DETECTION_TRAIN) assert res.get('valid_map', 0) > 0 test_result = est.predict(OBJECT_DETECTION_TEST) evaluate_result = est.evaluate(OBJECT_DETECTION_VAL)
def test_ssd_estimator(): from gluoncv.auto.estimators import SSDEstimator est = SSDEstimator({'train': {'epochs': 1, 'batch_size': 8}, 'gpus': list(range(get_gpu_count()))}) res = est.fit(OBJECT_DETECTION_TRAIN) assert res.get('valid_map', 0) > 0 test_result = est.predict(OBJECT_DETECTION_TEST) 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) # test save/load est2 = _save_load_test(est, 'ssd.pkl') evaluate_result2 = est2.evaluate(OBJECT_DETECTION_VAL) np.testing.assert_array_equal(evaluate_result, evaluate_result2, err_msg=f'{evaluate_result} != \n {evaluate_result2}')
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': 'ssd', 'base_network': 'resnet50_v1', 'data_shape': 512, 'batch_size': 64, # 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 = SSDEstimator(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]))