Esempio n. 1
0
def test_SDF_Points():
    sdf_points = shapenet.ShapeNet_SDF_Points(root=SHAPENET_ROOT,
                                              cache_dir=CACHE_DIR,
                                              categories=['can'],
                                              train=True,
                                              split=.1,
                                              resolution=100,
                                              smoothing_iterations=3,
                                              num_points=5000,
                                              occ=False,
                                              sample_box=True)

    assert len(sdf_points) == 10
    assert sdf_points.cache_dir.exists()
    assert len(list(sdf_points.cache_dir.rglob('*.p'))) == 10
    for obj in sdf_points:
        assert set(obj['data']['sdf_points'].shape) == set([5000, 3])
        assert set(obj['data']['sdf_distances'].shape) == set([5000])

    shutil.rmtree('tests/datasets/cache/sdf_points')

    sdf_points = shapenet.ShapeNet_SDF_Points(root=SHAPENET_ROOT,
                                              cache_dir=CACHE_DIR,
                                              categories=['can'],
                                              train=True,
                                              split=.1,
                                              resolution=100,
                                              smoothing_iterations=3,
                                              num_points=5000,
                                              occ=True,
                                              sample_box=True)

    assert len(sdf_points) == 10
    assert sdf_points.cache_dir.exists()
    assert len(list(sdf_points.cache_dir.rglob('*.p'))) == 10
    for obj in sdf_points:
        assert set(obj['data']['occ_points'].shape) == set([5000, 3])
        assert set(obj['data']['occ_values'].shape) == set([5000])

    shutil.rmtree('tests/datasets/cache/sdf_points')
    shutil.rmtree('tests/datasets/cache/voxels')
    shutil.rmtree('tests/datasets/cache/surface_meshes')
Esempio n. 2
0
def test_Combination():
    dataset_params = {
        'root': SHAPENET_ROOT,
        'categories': ['can'],
        'train': True,
        'split': .8,
    }
    # images = shapenet.ShapeNet_Images(root=SHAPENET_ROOT, cache_dir=CACHE_DIR,
    #                                   categories=['bowl'], views=1, train=True, split=.8)
    meshes = shapenet.ShapeNet_Meshes(**dataset_params)
    voxels = shapenet.ShapeNet_Voxels(**dataset_params,
                                      cache_dir=CACHE_DIR,
                                      resolutions=[32])
    sdf_points = shapenet.ShapeNet_SDF_Points(**dataset_params,
                                              cache_dir=CACHE_DIR,
                                              smoothing_iterations=3,
                                              num_points=500,
                                              occ=False,
                                              sample_box=True)

    points = shapenet.ShapeNet_Points(**dataset_params,
                                      cache_dir=CACHE_DIR,
                                      resolution=100,
                                      smoothing_iterations=3,
                                      num_points=500,
                                      surface=False,
                                      normals=True)

    dataset = shapenet.ShapeNet_Combination([voxels, sdf_points, points])

    for obj in dataset:
        obj_data = obj['data']
        assert set(obj['data']['sdf_points'].shape) == set([500, 3])
        assert set(obj['data']['sdf_distances'].shape) == set([500])
        assert set(obj['data']['32'].shape) == set([32, 32, 32])
        assert set(obj['data']['points'].shape) == set([500, 3])
        assert set(obj['data']['normals'].shape) == set([500, 3])

    train_loader = DataLoader(dataset,
                              batch_size=2,
                              shuffle=True,
                              num_workers=8)
    for batch in train_loader:
        assert set(batch['data']['sdf_points'].shape) == set([2, 500, 3])
        assert set(batch['data']['sdf_distances'].shape) == set([2, 500])
        assert set(batch['data']['32'].shape) == set([2, 32, 32, 32])
        assert set(batch['data']['points'].shape) == set([2, 500, 3])
        assert set(batch['data']['normals'].shape) == set([2, 500, 3])

    shutil.rmtree('tests/datasets/cache/sdf_points')
    shutil.rmtree('tests/datasets/cache/points')
    shutil.rmtree('tests/datasets/cache/voxels')
    shutil.rmtree('tests/datasets/cache/surface_meshes')
Esempio n. 3
0
parser.add_argument('-logdir',
                    type=str,
                    default='log',
                    help='Directory to log data to.')
parser.add_argument('-save-model',
                    action='store_true',
                    help='Saves the model and a snapshot \
	of the optimizer state.')
args = parser.parse_args()
"""
Dataset
"""
sdf_set = shapenet.ShapeNet_SDF_Points(
    root='/media/archana/Local/Datasets/ShapeNetCore.v1.zip/ShapeNetCore.v1',
    cache_dir='/media/archana/Local/Datasets/ShapeNetCore.v1.zip/cache/',
    categories=args.categories,
    train=True,
    split=.7,
    num_points=3000)
point_set = shapenet.ShapeNet_Points(
    root='/media/archana/Local/Datasets/ShapeNetCore.v1.zip/ShapeNetCore.v1',
    cache_dir='/media/archana/Local/Datasets/ShapeNetCore.v1.zip/cache/',
    categories=args.categories,
    train=True,
    split=.7,
    num_points=3000)
images_set = shapenet.ShapeNet_Images(
    root='/media/archana/Local/Datasets/ShapeNetRendering',
    categories=args.categories,
    train=True,
    split=.7,