Skip to content

balbasty/cornucopia

Repository files navigation

Cornucopia logo

The cornucopia package provides a generic framework for preprocessing, augmentation, and domain randomization; along with an abundance of specific layers, mostly targeted at (medical) imaging. cornucopia is written using a PyTorch backend, and therefore runs on the CPU or GPU.

Cornucopia is intended to be used on the GPU for on-line augmentation. A quick benchmark of affine and elastic augmentation shows that while cornucopia is slower than TorchIO on the CPU (~ 3s vs 1s), it is greatly accelerated on the GPU (~ 50ms). Note that a cornucopia adapter will be available in TorchIO v2, allowing seamless integration of cornucopia transformations with TorchIO pipelines.

Since version 0.4, all layers are differentiable, allowing augmentation parameters to be optimized via backpropagation. The Learn2Synth framework examplifies this application:

  • 📄 Paper
  • 💻 Code
  • 📖 Bibtex
    @inproceedings{hu2025learn2synth,
      title={Learn2Synth: Learning Optimal Data Synthesis Using Hypergradients for Brain Image Segmentation},
      author={Hu, Xiaoling and Zeng, Xiangrui and Puonti, Oula and Iglesias, Juan Eugenio and Fischl, Bruce and Balbastre, Ya{\"e}l},
      booktitle={Proceedings of the IEEE/CVF International Conference on Computer Vision},
      pages={20368--20378},
      year={2025}
    }

Installation

Dependencies

  • pytorch >= 1.8
  • numpy
  • nibabel
  • torch-interpol
  • torch-distmap

Pip (release)

pip install cornucopia

Pip (dev)

pip install cornucopia@git+https://github.com/balbasty/cornucopia

Documentation

Read the documentation and in particular:

Other augmentation packages

There are other great, and much more mature, augmentation packages out-there (although few run on the GPU). Here's a non-exhaustive list:

Contributions

If you find this project useful and wish to contribute, please reach out!

About

An abundance of augmentation layers

Resources

License

Stars

20 stars

Watchers

5 watching

Forks

Packages

 
 
 

Contributors

Languages