Spaces:
Running
Running
Download third_party/TRELLIS/extensions/vox2seq/test.py from gradient-spaces/GuideFlow3D: direct link, hf CLI and curl.
- Browser
- Download file 1.02 kB
-
https://huggingface.co/spaces/gradient-spaces/GuideFlow3D/resolve/main/third_party/TRELLIS/extensions/vox2seq/test.py
- Command line
-
hf download hf://spaces/gradient-spaces/GuideFlow3D/third_party/TRELLIS/extensions/vox2seq/test.py
-
curl -L -o test.py https://huggingface.co/spaces/gradient-spaces/GuideFlow3D/resolve/main/third_party/TRELLIS/extensions/vox2seq/test.py
1.02 kB
| import torch | |
| import vox2seq | |
| if __name__ == "__main__": | |
| RES = 256 | |
| coords = torch.meshgrid(torch.arange(RES), torch.arange(RES), torch.arange(RES)) | |
| coords = torch.stack(coords, dim=-1).reshape(-1, 3).int().cuda() | |
| code_z_cuda = vox2seq.encode(coords, mode='z_order') | |
| code_z_pytorch = vox2seq.pytorch.encode(coords, mode='z_order') | |
| code_h_cuda = vox2seq.encode(coords, mode='hilbert') | |
| code_h_pytorch = vox2seq.pytorch.encode(coords, mode='hilbert') | |
| assert torch.equal(code_z_cuda, code_z_pytorch) | |
| assert torch.equal(code_h_cuda, code_h_pytorch) | |
| code = torch.arange(RES**3).int().cuda() | |
| coords_z_cuda = vox2seq.decode(code, mode='z_order') | |
| coords_z_pytorch = vox2seq.pytorch.decode(code, mode='z_order') | |
| coords_h_cuda = vox2seq.decode(code, mode='hilbert') | |
| coords_h_pytorch = vox2seq.pytorch.decode(code, mode='hilbert') | |
| assert torch.equal(coords_z_cuda, coords_z_pytorch) | |
| assert torch.equal(coords_h_cuda, coords_h_pytorch) | |
| print("All tests passed.") | |