Ejemplo n.º 1
0
            for i in range(opt.genCamera):
                cam = next(camSampler)
                cameras.append(cam)

            splatter.initCameras(cameras=cameras)
            writeCameras(scene, os.path.join(opt.output, 'cameras.ply'))
        else:
            for i in range(len(scene.cameras)):
                scene.cameras[i].width = opt.width
                scene.cameras[i].height = opt.height

        splatter.initCameras(cameras=scene.cameras, genSunMode="triColor")

        for pointPath, pointRelPath in zip(points_paths, points_relpaths):
            keyName = os.path.join(os.path.join(opt.output, pointRelPath[:-4]))
            points = readCloud(pointPath, device="cpu")
            scene.loadPoints(points)
            fileName = getBasename(pointPath)
            splatter.setCloud(scene.cloud)
            successful_views= []
            rendered = []
            for i, cam in enumerate(scene.cameras):
                splatter.setCamera(i)
                result = splatter.render()
                if result is None:
                    print("splatted a None")
                    continue
                result = result.detach()[0]
                rendered.append(result)
            print(pointRelPath)
            for i, gt in enumerate(rendered):
Ejemplo n.º 2
0
                        reg_str = ",".join(["%.3f" % (100*v) for v in trainer.loss_reg])
                        entries = [trainer.modifier] + [loss_str] + [reg_str]
                        loss_log.write(",".join(entries)+"\n")
                        print("{:03d} {}: lr {} loss ({}) \n         :       reg ({})".format(
                            t, trainer.modifier, trainer.lr, loss_str, reg_str))

                trainer.finish_cycle()

    writeScene(scene, os.path.join(expr_dir, 'final_scene.json'),
               os.path.join(expr_dir, 'final_cloud.ply'))


if __name__ == "__main__":
    opt = FilterOptions().parse()

    torch.manual_seed(24)
    torch.backends.cudnn.deterministic = True
    torch.backends.cudnn.benchmark = False
    np.random.seed(24)

    # Create ground truth
    scene = readScene(opt.source, device="cpu")
    if opt.cloud:
        points = readCloud(opt.cloud, device="cpu")
        points_coords, _, _ = normalize_point_batch(
            points[:, :3].unsqueeze(0), NCHW=False)
        points[:, :3] = points_coords.squeeze(0)*2
        scene.loadPoints(points)

    trainImageFilter(scene, benchmark=opt.benchmark)