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} }
pytorch >= 1.8numpynibabeltorch-interpoltorch-distmap
pip install cornucopiapip install cornucopia@git+https://github.com/balbasty/cornucopiaRead the documentation and in particular:
There are other great, and much more mature, augmentation packages out-there (although few run on the GPU). Here's a non-exhaustive list:
- MONAI
- TorchIO
- Albumentations (2D only)
- Volumentations (3D extension of Albumentations)
If you find this project useful and wish to contribute, please reach out!