Exemplo n.º 1
0
elif opt.setting == 'InterDataset':
    annotation_file = 'Pascal3D.txt'
    test_cls = [
        'aeroplane', 'bicycle', 'boat', 'bottle', 'bus', 'car', 'chair',
        'diningtable', 'motorbike', 'sofa', 'train', 'tvmonitor'
    ]

else:
    sys.exit('Wrong setting!')

mean_class_data = pickle.load(open(opt.class_data, 'rb'))
Err_All = []

for cls in test_cls:
    class_data = mean_class_data[cls]
    dataset_test = Pascal3D(train=False,
                            root_dir=opt.root_dir,
                            annotation_file=annotation_file,
                            cls_choice=[cls],
                            input_dim=opt.input_dim,
                            point_num=opt.point_num)
    Acc, Med, Errs = test_category(dataset_test, model, opt.bin_size, cls,
                                   opt.output, logname, class_data)
    Err_All.extend(Errs)
    print('Acc30 is {:.2f} and MerErr is {:.2f} for {} images in class {}\n'.
          format(Acc, Med, len(dataset_test), cls))

print(
    'Performance across all classes: Acc_pi/6 is {:.2f} and Med_Err is {:.2f}'.
    format(np.mean(np.array(Err_All) <= 30), np.median(np.array(Err_All))))
Exemplo n.º 2
0
# =================CREATE DATASET=========================== #
root_dir = os.path.join('data', opt.dataset)
annotation_file = '{}.txt'.format(opt.dataset)

if opt.dataset == 'ObjectNet3D':
    test_cats = [
        'bed', 'bookshelf', 'calculator', 'cellphone', 'computer', 'door',
        'filing_cabinet', 'guitar', 'iron', 'knife', 'microwave', 'pen', 'pot',
        'rifle', 'shoe', 'slipper', 'stove', 'toilet', 'tub', 'wheelchair'
    ]
    dataset_train = Pascal3D(train=True,
                             root_dir=root_dir,
                             annotation_file=annotation_file,
                             cat_choice=test_cats,
                             keypoint=opt.keypoint,
                             novel=opt.novel,
                             shape=opt.shape,
                             shape_dir=opt.shape_dir,
                             view_num=opt.view_num,
                             tour=opt.tour,
                             random_range=opt.random_range,
                             random=opt.random)
    dataset_eval = Pascal3D(train=False,
                            root_dir=root_dir,
                            annotation_file=annotation_file,
                            cat_choice=test_cats,
                            keypoint=opt.keypoint,
                            random=False,
                            novel=opt.novel,
                            shape=opt.shape,
                            shape_dir=opt.shape_dir,
                            view_num=opt.view_num,
Exemplo n.º 3
0
print(opt)
# ========================================================== #


# =================CREATE DATASET=========================== #
if opt.novel:
    print('Excluding novel classes in training')
else:
    print('Including novel classes in training')

# 20 novel classes on ObjectNet3D
if opt.setting == 'IntraDataset':
    test_cats = ['bed', 'bookshelf', 'calculator', 'cellphone', 'computer', 'door', 'filing_cabinet', 'guitar', 'iron',
                 'knife', 'microwave', 'pen', 'pot', 'rifle', 'shoe', 'slipper', 'stove', 'toilet', 'tub', 'wheelchair']
    dataset_train = Pascal3D(train=True, root_dir=opt.root_dir_train, annotation_file=opt.annot_train,
                             cls_choice=test_cats, input_dim=opt.input_dim, point_num=opt.point_num,
                             keypoint=opt.keypoint, novel=opt.novel, shot=opt.shot)

# 12 novel classes on Pascal3D
elif opt.setting == 'InterDataset':
    test_cats = ['aeroplane', 'bicycle', 'boat', 'bottle', 'bus', 'car',
                 'chair', 'diningtable', 'motorbike', 'sofa', 'train', 'tvmonitor']
    dataset_train = Pascal3D(train=True, root_dir=opt.root_dir_train, annotation_file=opt.annot_train,
                             cls_choice=test_cats, input_dim=opt.input_dim, point_num=opt.point_num,
                             keypoint=opt.keypoint, novel=opt.novel, shot=opt.shot)
else:
    sys.exit('Wrong setting!')

train_loader = DataLoader(dataset_train, batch_size=opt.batch_size, shuffle=True, num_workers=opt.workers, drop_last=True)

print('train data consist of {} samples'.format(len(dataset_train)))
Exemplo n.º 4
0
f.close()
# ========================================================== #


# ================TESTING LOOP============================== #
Accs = {}
Meds = {}

root_dir = os.path.join('data', opt.dataset)
annotation_file = '{}.txt'.format(opt.dataset)
if opt.dataset == 'Pascal3D':
    test_cats = ['aeroplane', 'bicycle', 'boat', 'bottle', 'bus', 'car', 'chair', 'diningtable', 'motorbike', 'sofa',
                 'train', 'tvmonitor']
    for cat in tqdm(test_cats):
        dataset_test = Pascal3D(root_dir=root_dir, annotation_file=annotation_file,
                                cat_choice=[cat], train=False, random=False, shape=opt.shape, shape_dir=opt.shape_dir,
                                view_num=opt.view_num, tour=opt.tour, random_model=opt.random_model)
        Accs[cat], Meds[cat] = test_category(opt.shape, opt.batch_size, opt.dataset, dataset_test, model, opt.bin_size,
                                             cat, predictions_path, logname)


elif opt.dataset == 'ObjectNet3D':
    test_cats = ['bed', 'bookshelf', 'calculator', 'cellphone', 'computer', 'door', 'filing_cabinet', 'guitar', 'iron',
                 'knife', 'microwave', 'pen', 'pot', 'rifle', 'shoe', 'slipper', 'stove', 'toilet', 'tub', 'wheelchair']
    for cat in tqdm(test_cats):
        dataset_test = Pascal3D(root_dir=root_dir, annotation_file=annotation_file, shape_dir=opt.shape_dir,
                                cat_choice=[cat], train=False, random=False, keypoint=True, shape=opt.shape,
                                view_num=opt.view_num, tour=opt.tour, random_model=opt.random_model)
        Accs[cat], Meds[cat] = test_category(opt.shape, opt.batch_size, opt.dataset, dataset_test, model, opt.bin_size,
                                             cat, predictions_path, logname)
Exemplo n.º 5
0
f.write('\n')
f.close()
# ========================================================== #


# ================TESTING LOOP============================== #
Accs = {}
Meds = {}


if opt.dataset == 'Pascal3D':
    test_cats = ['aeroplane', 'bicycle', 'boat', 'bottle', 'bus', 'car', 'chair', 'diningtable', 'motorbike', 'sofa',
                 'train', 'tvmonitor']
    for cat in test_cats:
        dataset_test = Pascal3D(root_dir='data/Pascal3D', annotation_file='pascal3d_annotation.txt',
                                cat_choice=[cat], train=False, mutated=False, shape=opt.shape, mode=opt.mode,
                                render_number=opt.num_render, tour=opt.tour, random_model=opt.random_model)
        Accs[cat], Meds[cat] = test_category(opt.shape, opt.batch_size, opt.dataset, dataset_test, model, bin_size, cat,
                                             predictions_path, logname)


elif opt.dataset == 'Object3D':
    test_cats = ['bed', 'bookshelf', 'calculator', 'cellphone', 'computer', 'door', 'filing_cabinet', 'guitar', 'iron',
                 'knife', 'microwave', 'pen', 'pot', 'rifle', 'shoe', 'slipper', 'stove', 'toilet', 'tub', 'wheelchair']
    for cat in test_cats:
        dataset_test = Pascal3D(root_dir='data/Object3D', annotation_file='object3d_annotation.txt',
                                cat_choice=[cat], train=False, mutated=False, keypoint=True, shape=opt.shape,
                                mode=opt.mode, render_number=opt.num_render, tour=opt.tour, random_model=opt.random_model)
        Accs[cat], Meds[cat] = test_category(opt.shape, opt.batch_size, opt.dataset, dataset_test, model, bin_size, cat,
                                             predictions_path, logname)
Exemplo n.º 6
0
f.close()
# ========================================================== #


# ================TESTING LOOP============================== #
Accs = {}
Meds = {}

root_dir = os.path.join('data', opt.dataset)
annotation_file = '{}.txt'.format(opt.dataset)
if opt.dataset == 'Pascal3D':
    test_cats = ['aeroplane', 'bicycle', 'boat', 'bottle', 'bus', 'car', 'chair', 'diningtable', 'motorbike', 'sofa',
                 'train', 'tvmonitor']
    for cat in test_cats:
        dataset_test = Pascal3D(root_dir=root_dir, annotation_file=annotation_file,
                                cat_choice=[cat], train=False, mutated=False, shape=opt.shape,
                                render_number=opt.num_render, tour=opt.tour, random_model=opt.random_model)
        Accs[cat], Meds[cat] = test_category(opt.shape, opt.batch_size, opt.dataset, dataset_test, model, bin_size, cat,
                                             predictions_path, logname)


elif opt.dataset == 'ObjectNet3D':
    test_cats = ['bed', 'bookshelf', 'calculator', 'cellphone', 'computer', 'door', 'filing_cabinet', 'guitar', 'iron',
                 'knife', 'microwave', 'pen', 'pot', 'rifle', 'shoe', 'slipper', 'stove', 'toilet', 'tub', 'wheelchair']
    for cat in test_cats:
        dataset_test = Pascal3D(root_dir=root_dir, annotation_file=annotation_file,
                                cat_choice=[cat], train=False, mutated=False, keypoint=True, shape=opt.shape,
                                render_number=opt.num_render, tour=opt.tour, random_model=opt.random_model)
        Accs[cat], Meds[cat] = test_category(opt.shape, opt.batch_size, opt.dataset, dataset_test, model, bin_size, cat,
                                             predictions_path, logname)