rakhimovv / voronoi-interp-torch

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

voronoi-interp-torch

If you only know a few random pixels of an image, you can fill in the rest using nearest neighbors. This can result in cool animations as you gradually add more and more pixels at random.

The original version of this project written in Go.

This version is differentiable using PyTorch and CUDA.

Example

Here is an example output:

demo

Given that the function is differentiable you can also optimize the color values of the cells instead of using the original ones:

opt

Usage

Install python module: ./setup.sh

Example:

import torch
from voronoi_interp_torch import voronoi_interpolate

coords = torch.randint(0, 100, size=(100, 2)).cuda()
values = torch.rand(100, 3).cuda()
result = voronoi_interpolate(coords, values, H=100, W=100)

Demo where backprop is tested.

About


Languages

Language:Jupyter Notebook 96.9%Language:Cuda 1.9%Language:Python 0.7%Language:C++ 0.5%Language:Shell 0.0%