def test_Points(): points = shapenet.ShapeNet_Points(root=SHAPENET_ROOT, cache_dir=CACHE_DIR, categories=['can'], train=True, split=.1, resolution=100, smoothing_iterations=3, num_points=5000, surface=False, normals=False) assert len(points) == 10 assert points.cache_dir.exists() assert len(list(points.cache_dir.rglob('*.p'))) == 10 for obj in points: assert set(obj['data']['points'].shape) == set([5000, 3]) assert set(obj['data']['normals'].shape) == set([5000, 3]) shutil.rmtree('tests/datasets/cache/points') points = shapenet.ShapeNet_Points(root=SHAPENET_ROOT, cache_dir=CACHE_DIR, categories=['can'], train=True, split=.1, resolution=100, smoothing_iterations=3, num_points=5000, surface=True, normals=True) assert len(points) == 10 assert points.cache_dir.exists() assert len(list(points.cache_dir.rglob('*.p'))) == 10 for obj in points: assert set(obj['data']['points'].shape) == set([5000, 3]) assert set(obj['data']['normals'].shape) == set([5000, 3]) shutil.rmtree('tests/datasets/cache/points') shutil.rmtree('tests/datasets/cache/voxels') shutil.rmtree('tests/datasets/cache/surface_meshes')
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')
type=str, nargs='+', default=['chair'], help='list of object classes to use') parser.add_argument('-vis', action='store_true', help='Visualize each model while evaluating') parser.add_argument('-batchsize', type=int, default=16, help='Batch size.') parser.add_argument('-f_score', action='store_true', help='compute F-score') args = parser.parse_args() # Data points_set_valid = 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=False, split=.7, num_points=5000) images_set_valid = shapenet.ShapeNet_Images( root='/media/archana/Local/Datasets/ShapeNetRendering', categories=args.categories, train=False, split=.7, views=1, transform=preprocess) meshes_set_valid = shapenet.ShapeNet_Meshes( root='/media/archana/Local/Datasets/ShapeNetCore.v1.zip/ShapeNetCore.v1', categories=args.categories, train=False, split=.7)
type=str, default='log', help='Directory to log data to.') parser.add_argument( '--resume', choices=['best', 'recent'], default=None, help= 'Choose which weights to resume training from (None to start from random initialization.)' ) args = parser.parse_args() # Setup Dataset points_set = shapenet.ShapeNet_Points(root=args.shapenet_root, cache_dir=args.cache_dir, categories=args.categories, train=True, split=.7, num_points=3000) images_set = shapenet.ShapeNet_Images(root=args.shapenet_images_root, categories=args.categories, train=True, split=.7, views=23, transform=preprocess) if args.latent_loss: mesh_set = shapenet.ShapeNet_Surface_Meshes(root=args.shapenet_root, cache_dir=args.cache_dir, categories=args.categories, resolution=100, train=True, split=.7,