GithubHelp home page GithubHelp logo

fagan2888 / data-augmentation Goto Github PK

View Code? Open in Web Editor NEW

This project forked from outlace/data-augmentation

0.0 1.0 0.0 317 KB

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

License: MIT License

Python 100.00%

data-augmentation's Introduction

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

data-augmentation's People

Contributors

outlace avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.