Ejemplo n.º 1
0
def test_vis():
    from lib.utils.config import cfg
    # TODO make this an API
    dataset = VOCDetection(cfg.DATASET.DATASET_DIR, [('2007', 'test')],
                           SSDAugmentation((300, 500), dataset_mean),
                           VOCAnnotationTransform())
    from lib.utils.visualize_utils import TBWriter
    tb_writer = TBWriter(log_dir, {'vis_list': [3, 4, 5, 6, 8]})

    # import random
    # img_idx = random.randint(0, len(data_loader.dataset)-1)
    # image, target = dataset.pull_item(img_index, tb_writer)
    for img_idx in range(len(dataset)):
        if img_idx > 5:
            break
        tb_writer.cfg['steps'] = img_idx
        image, target, extra = dataset.pull_item(img_idx, tb_writer)
        print(image.shape)
Ejemplo n.º 2
0
def test_loader():
    from lib.utils.config import cfg
    # TODO: a strange bug: datasets loader hangs in cpu mode
    os.environ["CUDA_VISIBLE_DEVICES"] = "0"  # Specified GPUs range

    dataset = VOCDetection(
        cfg.DATASET.DATASET_DIR, cfg.DATASET.TEST_SETS,
        SSDAugmentation(cfg.DATASET.IMAGE_SIZE,
                        cfg.DATASET.PIXEL_MEANS,
                        use_base=True), VOCAnnotationTransform())
    data_loader = data.DataLoader(dataset,
                                  batch_size=cfg.DATASET.TRAIN_BATCH_SIZE,
                                  num_workers=cfg.DATASET.NUM_WORKERS,
                                  shuffle=False,
                                  collate_fn=detection_collate,
                                  pin_memory=True)
    for i, (images, targets, extra) in enumerate(data_loader):
        print(i)
Ejemplo n.º 3
0
def test_vis():
    dataset = COCODetection(
        COCO_ROOT, ('valminusminival2014', ),
        SSDAugmentation((300, 300), dataset_mean, use_base=True),
        COCOAnnotationTransform())

    from lib.utils.visualize_utils import TBWriter
    tb_writer = TBWriter(log_dir, {'epoch': 50, 'vis_list': [3, 4, 5, 6, 8]})

    # import random
    # img_idx = random.randint(0, len(dataset)-1)
    # image, target = dataset.pull_item(img_idx, tb_writer)

    for img_idx in range(len(dataset)):
        if img_idx > 5:
            break
        tb_writer.cfg['steps'] = img_idx
        image, target = dataset.pull_item(img_idx, tb_writer)
        print(image.shape)
Ejemplo n.º 4
0
def test_loader():
    # TODO: a strange bug: datasets loader hangs in cpu mode
    os.environ["CUDA_VISIBLE_DEVICES"] = cfg.CUDA_VISIBLE_DEVICES
    cfg_path = osp.join(cfg.CFG_ROOT, 'coco.yml')
    merge_cfg_from_file(cfg_path)

    dataset = COCODetection(
        cfg.DATASET.DATASET_DIR, cfg.DATASET.TEST_SETS,
        SSDAugmentation(cfg.DATASET.IMAGE_SIZE, dataset_mean, use_base=True),
        COCOAnnotationTransform())
    loader = data.DataLoader(dataset,
                             batch_size=cfg.DATASET.EVAL_BATCH_SIZE,
                             num_workers=cfg.DATASET.NUM_WORKERS,
                             shuffle=False,
                             collate_fn=detection_collate,
                             pin_memory=True)
    print(len(dataset))
    for i, (images, targets, extra) in enumerate(loader):
        print(i)