Exemplo n.º 1
0
def get_dataset(args):
    # built-in dataset (voc)
    if 'voc' in args.dataset_name:
        logging.info('Please follow this instruction to download dataset: \
            https://gluon-cv.mxnet.io/build/examples_datasets/pascal_voc.html#sphx-glr-build-examples-datasets-pascal-voc-py ')
        train_dataset = task.Dataset(name=args.dataset_name)
        test_dataset = task.Dataset(name=args.dataset_name, Train=False)
        return (train_dataset, test_dataset)        

    # custom datset. 
    if args.dataset_name in dataset_dict: 
        url, index_file_name_trainval, index_file_name_test, classes, \
             = dataset_dict[args.dataset_name]

        data_root = os.path.join(args.dataset_root, args.dataset_name)
        if not args.no_redownload:
            root = args.dataset_root
            filename_zip = ag.download(url, path=root)
            filename = ag.unzip(filename_zip, root=root)
            data_root = os.path.join(root, filename)
    else:
        logging.info("This dataset is not in dataset_dict. It should be downloaded before running this script.")
        index_file_name_trainval = args.index_file_name_trainval
        index_file_name_test = args.index_file_name_test
        classes = args.classes
        
    train_dataset = task.Dataset(data_root, index_file_name=index_file_name_trainval, classes=classes)
    test_dataset = task.Dataset(data_root, index_file_name=index_file_name_test, classes=classes, Train=False)

    return (train_dataset, test_dataset)        
Exemplo n.º 2
0
    dataset_train, dataset_test = get_dataset(args)

    time_limits = 5 * 60 * 60  # 5 days
    epochs = 12
    # use coco pre-trained model for custom datasets
    transfer = None if ('voc' in args.dataset_name) or (
        'coco' in args.dataset_name) else 'coco'
    detector = task.fit(dataset_train,
                        num_trials=30,
                        epochs=epochs,
                        net=ag.Categorical('darknet53', 'mobilenet1.0'),
                        meta_arch=args.meta_arch,
                        lr=ag.Categorical(1e-2, 5e-3, 1e-3, 5e-4, 1e-4, 5e-5),
                        transfer=transfer,
                        data_shape=ag.Categorical(320, 416),
                        nthreads_per_trial=16,
                        ngpus_per_trial=1,
                        batch_size=8,
                        lr_decay_epoch=ag.Categorical('80,90', '85,95'),
                        warmup_epochs=ag.Int(1, 10),
                        warmup_iters=ag.Int(250, 1000),
                        wd=ag.Categorical(1e-4, 5e-4, 2.5e-4),
                        syncbn=ag.Bool(),
                        label_smooth=ag.Bool(),
                        time_limits=time_limits,
                        dist_ip_addrs=[])

    test_map = detector.evaluate(dataset_test)
    print("mAP on test dataset: {}".format(test_map[1][1]))
Exemplo n.º 3
0
import autogluon as ag
from autogluon import ObjectDetection as task
from console_logging.console import Console
console = Console()

console.log("Baixando Dataset...")
root = './'
filename_zip = ag.download(
    'https://autogluon.s3.amazonaws.com/datasets/tiny_motorbike.zip',
    path=root)
filename = ag.unzip(filename_zip, root=root)

console.log("Criando TASK TRAIN ")
import os
data_root = os.path.join(root, filename)
dataset_train = task.Dataset(data_root, classes=('motorbike', ))

console.info("TRAINING DATA MODEL...")
time_limits = 5 * 60 * 60  # 5 hours
epochs = 30
detector = task.fit(dataset_train,
                    num_trials=2,
                    epochs=epochs,
                    lr=ag.Categorical(5e-4, 1e-4),
                    ngpus_per_trial=1,
                    time_limits=time_limits)
console.success("TRAINING DONE !")
console.log("START TEST MODEL ")
dataset_test = task.Dataset(data_root,
                            index_file_name='test',
                            classes=('motorbike', ))
Exemplo n.º 4
0
                  'net': ag.Categorical('darknet53', 'mobilenet1.0'), 'meta_arch': args.meta_arch,
                  'lr': ag.Categorical(1e-2, 5e-3, 1e-3, 5e-4, 1e-4, 5e-5), 'transfer': transfer,
                  'data_shape': ag.Categorical(320, 416), 'nthreads_per_trial': 16,
                  'ngpus_per_trial': 8, 'batch_size': 64,
                  'lr_decay_epoch': ag.Categorical('80,90', '85,95'),
                  'warmup_epochs': ag.Int(1, 10), 'warmup_iters': ag.Int(250, 1000),
                  'wd': ag.Categorical(1e-4, 5e-4, 2.5e-4), 'syncbn': ag.Bool(),
                  'label_smooth': ag.Bool(), 'time_limits': time_limits, 'dist_ip_addrs': []}
    elif args.meta_arch == 'faster_rcnn':
        kwargs = {'num_trials': 30, 'epochs': ag.Categorical(30, 40, 50, 60),
                  'net': ag.Categorical('resnest101', 'resnest50'),
                  'meta_arch': args.meta_arch,
                  'lr': ag.Categorical(0.02, 0.01, 0.005, 0.002, 2e-4, 5e-4), 'transfer': transfer,
                  'data_shape': (640, 800), 'nthreads_per_trial': 16,
                  'ngpus_per_trial': 8, 'batch_size': 16,
                  'lr_decay_epoch': ag.Categorical('24,28', '35', '50,55', '40', '45', '55',
                                                   '30, 35', '20'),
                  'warmup_iters': ag.Int(5, 500),
                  'wd': ag.Categorical(1e-4, 5e-4, 2.5e-4), 'syncbn': True,
                  'label_smooth': False, 'time_limits': time_limits, 'dist_ip_addrs': []}
    else:
        raise NotImplementedError('%s is not implemented.', args.meta_arch)
    detector = task.fit(dataset_train, **kwargs)
    ctx = [mx.gpu(i) for i in range(get_gpu_count())]
    if not ctx:
        ctx = [mx.cpu()]
    test_map = detector.evaluate(dataset_test, ctx=ctx)
    print("mAP on test dataset: {}".format(test_map[-1][-1]))
    print(test_map)
    detector.save('final_model.model')