Skip to main content

TF Sprinkles

Sprinkles augmentation implemented in TensorFlow.

Branch Build status Coverage status PyPI version
master Build Status Coverage Status PyPI version
develop Build Status Coverage Status

Based on Less Wright's Medium article, Progessive Sprinkles: a New Data Augmentation for CNNs. See also his post on fast.ai.

To install:

pip install tf_sprinkles

To use:

from tf_sprinkles import Sprinkles
sprinkles = Sprinkles(num_holes, side_length)

Then call sprinkles(image) in the input pipeline for your image. A simple example to get started using the cat.jpeg image located in the data folder is:

import numpy as np
import tensorflow as tf
from tf_sprinkles import Sprinkles
from PIL import Image
from matplotlib import pyplot as plt

sprinkles = Sprinkles(num_holes=100, side_length=10)
img = Image.open('test/data/cat.jpeg')
img = np.asarray(img) / 255.
result = sprinkles(tf.constant(img, dtype=tf.float32))
plt.imshow(result.numpy())

Which results in the following image with sprinkles.

cat with sprinkles

Note that the mode flag added in version 1.1.0 can be used to specify that sprinkles should be filled with Gaussian noise (mode='gaussian'), randomly filled with black or white (mode='salt_pepper'), or all black (the default or mode=None).

Metadata

Release files for tf-sprinkles 1.1.3

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

Source distribution (sdist)

Source distribution for tf-sprinkles 1.1.3
File Size Uploaded
tf_sprinkles-1.1.3.tar.gz 4.5 kB Details

Release files / tf_sprinkles-1.1.3.tar.gz

Download URL tf_sprinkles-1.1.3.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
050ba38fa0590f29b8a809fcd6004f399617f10a63c686de3515453d2293acf6
BLAKE2b-256 checksum
How to use checksums
d2597dce3ecde194111d94550fde25885c127536c33abe12012c9469d306bf3e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.2

Release history Release notifications | RSS feed

This release

1.1.3 This release

1 release file

1.1.2

1 release file

1.1.1

1 release file

1.1.0

1 release file

1.0.3

1 release file

1.0.2

1 release file

1.0.1

1 release file

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