/neural-cellular-automata

Neural Cellular Automata for texture generation in tinygrad following Self-Organising Textures by Eyvind Niklasson et. al..

Primary LanguagePythonBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

This is an implementation of Self-Organising Textures by Eyvind Niklasson et. al. using a neural network framework called tinygrad.

Install dependencies:

python3 -m pip install Pillow numpy matplotlib tinygrad torchvision

To train a model:

python3 train.py

To create a gif called agif.gif of the trained or currently training model:

python3 -i
>>> from viz import create_gif
>>> create_gif("agif.gif")

Model hyperparamaters can be adjusted in train.py, vgg16.py contains a tinygrad VGG-16 model which loads its weights from the torchvision pretrained model. loss.py contains various loss functions for minimizing style-loss, or maximizing the activation of a unit the Resnet image classifier.

Tinygrad is much slower than pytorch for training. See pytorch.py for a pytorch version of this software which has been modified to produce monochrome textures.