Training code and pre-trained models for Neural Cellular Automata on different datasets and tasks
Project description
NCALab
NCALab is a framework designed to facilitate the creation and analysis of Neural Cellular Automata (NCA) implementations.
NCAs are a new type of Artificial Neural Network model that operates on a grid of cells in multiple iterations.
With NCALab, users can effortlessly explore various applications of NCA, including image segmentation, classification, and synthesis.
The models are documented, unit-tested and type-checked and can be modified in a streamlined fashion.
For more information on NCAs, check out our curated Awesome List and our NCA Tutorial.
Neural Cellular Automata
NCA are a new type of neural architecture, fusing Cellular Automata and Artificial Neural Networks to create memory-efficient, robust models. By replacing the transition function of a Cellular Automaton with a neural network model (a Multi-Layer Perceptron), they can learn from labelled input data to achieve tasks like image classification or segmentation.
Akin to a traditional cellular automaton, a neural cellular automaton operates in multiple time steps (typically up to 100 steps until a prediction is considered finished). In each time step, the cells of an image are stochastically updated by a multilayer perceptron. Instead of a manual neighborhood aggregation (e.g. Moore or von Neumann neighborhood), neighboring cell states are determined by applying 2D depth-wise convolutions to the input image.
For a better overview on the basic NCA architecture, we recommend you to read the original 2020 NCA Paper by Mordvintsev et al.
Features
Features of NCALab include:
- Easy training and evaluation of NCA models
- Cascaded multi-scale training
- Tensorboard integration with default presets
- Training with k-fold cross-validation
- Convenience features: Fixing random seeds, selecting compute devices, data processing
- Animation and visualization of NCA predictions
Roadmap
The following features are planned for future releases of NCALab:
- Implementation of more approaches presented in research that extend or tweak NCA models
- Simplifyed saving and loading of trained NCA models
- Evaluation of federated and continual learning with NCAs
- NCAs that operate on 3D voxel data
Getting started
This project makes use of uv for package and dependency management.
Please read the installation instructions of uv before proceeding or simply install it to your Python workspace by running:
pip install -U uv
Perhaps the best way of getting started with NCALab is to take a look at the provided usage example tasks, starting with the Growing Emoji task.
Usage Example Tasks
So far, the following example tasks are implemented in NCALab:
- Image Generation:
- Growing NCA for emoji generation
- Training and evaluation
- Fine-tuning of a pre-trained emoji generator
- Hyperparameter search
- Growing NCA for emoji generation
- Image Classification:
- Self-classifying MNIST digits
- MedMNIST image classification (PathMNIST, BloodMNIST, DermaMNIST)
- Image Segmentation:
- Endoscopic polyp segmentation (Kvasir-SEG, public)
You can find those example tasks inside the tasks/ directory and its subfolders.
Growing Lizard Example
A good starting point to get started with NCAs is the famous Growing Lizard emoji example.
uv run tasks/growing_emoji/train_growing_emoji.py
Run this script to generate a GIF of the trained model's prediction:
uv run tasks/growing_emoji/eval_growing_emoji.py
Installation
Run
pip install ncalab
to install the latest release or
pip install git+https://github.com/MECLabTUDA/NCALab
for the most recent commit of NCALab. We recommend to install NCALab in a virtual environment.
Tensorboard integration
We recommend you to monitor your training progress in Tensorboard. To launch tensorboard, run
uv run tensorboard --logdir=runs
in a separate terminal. Once it is running, it should show you the URL the tensorboard server is running on, which is localhost:6006 by default. Alternatively, you may use the tensorboard integration of your IDE.
For Developers
Type checking:
uv run mypy ncalab
Static code analysis:
uv run ruff check ncalab
Testing:
uv run pytest
How to Cite
Coming soon.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ncalab-0.3.1.tar.gz.
File metadata
- Download URL: ncalab-0.3.1.tar.gz
- Upload date:
- Size: 17.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
96dcc152f519e313157ce5f1df8cf1890a790f8f69d64bc56a2d73a6ed64b992
|
|
| MD5 |
2ac1ce082e5677e237def8eb27307f38
|
|
| BLAKE2b-256 |
9f425c4fe058bd87d4aa2e25fd855603bebaf73b95452dc3a82cca1fc70adab6
|
Provenance
The following attestation bundles were made for ncalab-0.3.1.tar.gz:
Publisher:
python-publish.yml on MECLabTUDA/NCALab
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ncalab-0.3.1.tar.gz -
Subject digest:
96dcc152f519e313157ce5f1df8cf1890a790f8f69d64bc56a2d73a6ed64b992 - Sigstore transparency entry: 413051785
- Sigstore integration time:
-
Permalink:
MECLabTUDA/NCALab@233f69f348c8ebca18e7e46f3f64b2c2144d4152 -
Branch / Tag:
refs/tags/v0.3.2 - Owner: https://github.com/MECLabTUDA
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@233f69f348c8ebca18e7e46f3f64b2c2144d4152 -
Trigger Event:
release
-
Statement type:
File details
Details for the file ncalab-0.3.1-py3-none-any.whl.
File metadata
- Download URL: ncalab-0.3.1-py3-none-any.whl
- Upload date:
- Size: 11.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a2fe0949baa48d6da3496602dcd463a6312cdd523a20caab6dea5f181448d890
|
|
| MD5 |
407ce0f6f7afb2837e4c9913a5fe65bf
|
|
| BLAKE2b-256 |
e2198230d7c8e984b1ff7caf2ddf5c7acfba494b0513f1c997eafacd9dce3ec2
|
Provenance
The following attestation bundles were made for ncalab-0.3.1-py3-none-any.whl:
Publisher:
python-publish.yml on MECLabTUDA/NCALab
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ncalab-0.3.1-py3-none-any.whl -
Subject digest:
a2fe0949baa48d6da3496602dcd463a6312cdd523a20caab6dea5f181448d890 - Sigstore transparency entry: 413051792
- Sigstore integration time:
-
Permalink:
MECLabTUDA/NCALab@233f69f348c8ebca18e7e46f3f64b2c2144d4152 -
Branch / Tag:
refs/tags/v0.3.2 - Owner: https://github.com/MECLabTUDA
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@233f69f348c8ebca18e7e46f3f64b2c2144d4152 -
Trigger Event:
release
-
Statement type: