PyTorch Profiler- Implement pcg.py as PyTorch Custom C++ and CUDA Extensions
- 4d
- pytorch
To run demo.py:
- vispy
pip install git+https://github.com/worosom/opensimplex_pytorch
For development:
git clone https://github.com/worosom/opensimplex_pytorch
cd opensimplex_pytorch
pip install -e .
from opensimplex_pytorch.simplex3d import simplex3d
simplex3d
accepts a torch.Tensor
of shape (batch_size, 3)
and returns a tensor of shape (batch_size,)
with values centered around 0
a range of -1/1
.
Large
>1e4
input values may lead to undesireable artifacts.
import torch
from opensimplex_pytorch.simplex3d import simplex3d
x = torch.zeros((1, 3))
print(simplex3d(x))
# tensor([[0.1294]])
import torch
from opensimplex_pytorch.simplex3d import simplex3d
# create a grid of pixel coordinates
xs = torch.linspace(-2, 2, steps=20)
ys = torch.linspace(-2, 2, steps=10)
x, y = torch.meshgrid(xs, ys, indexing='xy')
# add a third dimension for time
t = torch.zeros((10, 20))
xyt = torch.dstack((x, y, t))
flat_xyt = torch.reshape(xyt, (-1, 3))
noise = simplex3d(flat_xyt)
noise_img = torch.reshape(noise, (10, 20))
charset = ['🁣', '🁫', '🁳', '🁻', '🂃', '🂋', '🂓']
noise_img = (noise_img - noise_img.min()) / (noise_img.max() - noise_img.min()) # range to 0/1
quant_img = (noise_img * (len(charset) - 1)).type(torch.int8)
for line in quant_img:
for col in line:
print(charset[col], end='')
print()
🂃🂓🂃🁫🁫🁻🂃🁳🁳🁳🂃🂃🁳🁣🁣🁫🁻🁳🁫🁳
🁫🁻🁻🁻🁻🁻🁻🁻🁻🁻🁳🁫🁫🁳🁻🂃🂃🂃🂃🂃
🁻🁳🁻🂋🂃🁳🁳🂃🂃🂃🂃🁻🁻🂋🂃🁳🁳🁻🁻🂃
🁳🁳🁻🁻🁻🁳🁳🁫🁳🁻🁻🁳🁳🁳🁳🁫🁫🁳🁳🁫
🁳🁳🁻🁳🁳🁳🁳🁳🁳🁳🁳🁳🁳🁳🁳🁻🁻🂃🂃🂃
🂃🁳🁻🁻🂃🂃🁳🁫🁳🁻🁻🁻🁳🁳🁳🂃🂋🂃🁻🁻
🁳🁳🁳🁻🂃🁻🁻🁻🁻🁫🁫🁳🁳🁫🁳🁻🁻🁻🁻🂃
🁣🁻🂃🂃🁻🁳🁫🁻🂃🁻🁳🁳🁳🁳🁳🂃🂋🂃🁻🁳
🁻🂋🂃🁻🁳🁫🁳🁻🁻🁳🁻🁻🁳🁫🁫🁳🁻🁳🁳🁳
🁳🂃🁻🁳🁫🁳🁳🁻🂃🂋🂋🁻🁣🁣🁳🂃🁻🁫🁣🁫