Skip to content
Branch: master
Go to file
Code

Latest commit

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 

README.md

Data-Augmentation

These functions will randomly distort image data to amplify total amount of images for use in machine learning algorithms.

We will use this package to amplify ("augment") a single image.

The library randomly rotates, flips along axis, translates, adds noise, and adds "black boxes" to images to increase the number of usable data for a machine learning algorithm.

import DataAugmentation as da

import matplotlib.pyplot as plt
import numpy as np
%matplotlib inline

Augment function signature:
def augment(images, labels=None, amplify=2):

Input Data:

images shape: (batch_size, height, width, channels=3)
labels shape: (batch_size, 3) [this is an optional parameter]
amplify is how many (randomly altered) copies of the original image(s) you want to produce

# Sample image to amplify
sample = plt.imread('samples/dog_icon.jpg')
plt.imshow(sample)
<matplotlib.image.AxesImage at 0x1161fe550>

png

sample.shape #Need to reshape to (batch_size, height, width, channels)
sample = np.reshape(sample, (1,256,256,3))
augmented_data = da.augment(sample, amplify=10)
augmented_data.shape
#First image is original, rest are synthesized
(10, 256, 256, 3)
plt.imshow(augmented_data[1])
#Randomly translated
<matplotlib.image.AxesImage at 0x118a3bd68>

png

plt.imshow(augmented_data[7])
#Look carefully, random noise added
<matplotlib.image.AxesImage at 0x118e4e080>

png

plt.imshow(augmented_data[6])
#Randomly rotated
<matplotlib.image.AxesImage at 0x118f488d0>

png

About

These functions will randomly distort image data to amplify total amount of images for use in machine learning algorithms.

Topics

Resources

License

Releases

No releases published

Languages

You can’t perform that action at this time.