- July 2021 (image compression) - Released implemenation of Scale Hyperprior
- July 2021 (video compression) - Released implementation of DVC
NeuralCompression is a Python repository dedicated to research of neural networks that compress data. The repository includes tools such as JAX-based entropy coders, image compression models, video compression models, and metrics for image and video evaluation.
NeuralCompression is alpha software. The project is under active development. The API will change as we make releases, potentially breaking backwards compatibility.
NeuralCompression is a project currently under development. You can install the repository in development mode.
First, install PyTorch according to the directions from the PyTorch website. Then, you should be able to run
pip install neuralcompressionto get the latest version from PyPI.
First, clone the repository and navigate to the NeuralCompression root directory. To match your local environment to the test environment, run
pip install -r dev-requirements.txtThen, you can install the package in development mode by running
pip install -e .If you are not interested in matching the test environment, then you only need to apply the second step to install.
We use a 2-tier repository structure. The neuralcompression package contains
a core set of tools for doing neural compression research. Code committed to
the core package requires stricter linting, high code quality, and rigorous
review. The projects folder contains code for reproducing papers and training
baselines. Code in this folder is not linted aggressively, we don't enforce
type annotations, and it's okay to omit unit tests.
The 2-tier structure enables rapid iteration and reproduction via code in
projects that is built on a backbone of high-quality code in
neuralcompression.
neuralcompression- base packagedata- PyTorch data loaders for various data setsentropy_coders- lossless compression algorithms in JAXcraystack- an implementation of the rANS algorithm with the craystack API
functional- methods for image warping, information cost, flop counting, etc.layers- building blocks for compression modelsmetrics-torchmetricsclasses for assessing model performancemodels- complete compression models
projects- recipes and code for reproducing papersscale_hyperprior_lightningScale Hyperprior (Balle et al., 2018)deep_video_compressionDVC (Lu et al., 2019)
This repository also features interactive notebooks detailing different
parts of the package, which can be found in the tutorials directory.
Existing tutorials are:
- Walkthrough of the
neuralcompressionflop counter (view on Colab). - Using
neuralcompression.metricsandtorchmetricsto calculate rate-distortion curves (view on Colab).
For an example of package usage, see the Scale Hyperprior for an example of how to train an image compression model in PyTorch Lightning. See DVC for a video compression example.
Please read our CONTRIBUTING guide and our CODE_OF_CONDUCT prior to submitting a pull request.
We test all pull requests. We rely on this for reviews, so please make sure any
new code is tested. Tests for neuralcompression go in the tests folder in
the root of the repository. Tests for individual projects go in those projects'
own tests folder.
We use black for formatting, isort for import sorting, flake8 for
linting, and mypy for type checking.
NeuralCompression is MIT licensed, as found in the LICENSE file.
If you find NeuralCompression useful in your work, feel free to cite
@misc{muckley2021neuralcompression,
author={Matthew Muckley and Jordan Juravsky and Daniel Severo and Mannat Singh and Quentin Duval and Karen Ullrich},
title={NeuralCompression},
howpublished={\url{https://github.com/facebookresearch/NeuralCompression}},
year={2021}
}