Skip to main content

Augment like there's no tomorrow: Consistently performing neural networks for medical imaging [arXiv]

This repository contains implementations for StrongAugment and creating distribution-shifted datasets.

Installation

pip3 install strong-augment

Training with strong augmentation.

To train your neural networks with strong augmentatiom simply include StrongAugment to your image transformation pipeline!

import torchvision.transforms as T
from strong_augment import StrongAugment

trnsf = T.Compose(
    T.RandomResizedCrop(224),
    T.RandomVerticalFlip(0.5),
    T.RandomHorizontalFlip(0.5),
    StrongAugment(operations=[2, 3, 4], probabilities=[0.5, 0.3, 0.2]), # Just one line!
    T.ToTensor(),
    T.Normalize(mean=[0.5, 0.5, 0.5], std=[0.2, 0.2, 0.2])
    T.RandomErase(0.2)
)

Creating shifted datasets.

Function shift_dataset can be used create the distribution-shifted datasets for shifted evaluation.

from functools import partial
import torchvision.transforms.functional as F
from strong_augment import shift_dataset

# Let's define the distribution shift function.
shift_fn = partial(F.adjust_gamma, gamma=0.2)

# Now we can shift the dataset!
shift_dataset(
    paths=paths_to_dataset_images,
    output_dir="/data/shifted_datasets/gamma_02",
    function=shift_fn,
    num_workers=20,
)
Processing images |##########| 100000/100000 [00:49<00:00]

Citation

If you use StrongAugment or shifted evaluation, please cite us!

@paper{strong_augment2022,
    title = {Augment like there's no tomorrow: Consistently performing neural networks for medical imaging},
    author = {Pohjonen, Joona and Stürenberg, Carolin and Föhr, Atte and Randen-Brady, Reija and Luomala, Lassi and Lohi, Jouni and Pitkänen, Esa and Rannikko, Antti and Mirtti, Tuomas},
    url = {https://arxiv.org/abs/2206.15274},
    publisher = {arXiv},
    year = {2022},
}

Metadata

Release files for strong-augment 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for strong-augment 0.1.0
File Size Uploaded Provenance Actions
strong_augment-0.1.0.tar.gz 6.7 kB Without provenance Details for strong_augment-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for strong-augment 0.1.0
File Interpreter ABI Platform Actions
strong_augment-0.1.0-py3-none-any.whl Python 3 none any Details for strong_augment-0.1.0-py3-none-any.whl

Total release size: 13.8 kB

Release files / strong_augment-0.1.0.tar.gz

Download URL strong_augment-0.1.0.tar.gz
Size 6.7 kB
Tags Source
SHA-256 checksum
How to use checksums
1c3589c8be4cb511549171fa57fedf0024332a739c538b98ef3cd7d216f6480a
BLAKE2b-256 checksum
How to use checksums
4673b2b3302a62ed75381b29eb270c1923f9e36eef04d30601dbda364d021374
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.2 CPython/3.9.5 Linux/5.15.0-58-generic

Release files / strong_augment-0.1.0-py3-none-any.whl

Download URL strong_augment-0.1.0-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d111245d97f7debd187d8957ea59adc74714538dc9413ee19c1b26cc7dcfc374
BLAKE2b-256 checksum
How to use checksums
e969051637373cac5c1071a2889f28f44eac471f3538a7ac437b24f8ed10040d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.2 CPython/3.9.5 Linux/5.15.0-58-generic

Security for strong-augment 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page