• Stars
    star
    445
  • Rank 98,085 (Top 2 %)
  • Language
    Python
  • Created about 8 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Data augmentation tool for images

Image Augmentor

This is a simple data augmentation tool for image files, intended for use with machine learning data sets. The tool scans a directory containing image files, and generates new images by performing a specified set of augmentation operations on each file that it finds. This process multiplies the number of training examples that can be used when developing a neural network, and should significantly improve the resulting network's performance, particularly when the number of training examples is relatively small.

Run the utility from the command-line as follows:

python main.py <image dir> <transform1> <transform2> ...

The <image dir> argument should be the path to a directory containing the image files to be augmented. The utility will search the directory recursively for files with any of the following extensions: jpg, jpeg, bmp, png.

The transform arguments determine what types of augmentation operations will be performed, using the codes listed in the table below:

Code Description Example Values
fliph Horizontal Flip fliph
flipv Vertical Flip flipv
noise Adds random noise to the image noise_0.01,noise_0.5
rot Rotates the image by the specified amount rot_90,rot_-45
trans Shifts the pixels of the image by the specified amounts in the x and y directions trans_20_10,trans_-10_0
zoom Zooms into the specified region of the image, performing stretching/shrinking as necessary zoom_0_0_20_20,zoom_-10_-20_10_10
blur Blurs the image by the specified amount blur_1.5

Each transform argument results in one additional output image being generated for each input image. An argument may consist of one or more augmentation operations. Multiple operations within a single argument must be separated by commas, and the order in which the operations are performed will match the order in which they are specified within the argument.

Examples

Produce 2 output images for each input image, one of which is flipped horizontally, and one of which is flipped vertically:

python main.py ./my_images fliph flipv

Produce 1 output image for each input image, by first rotating the image by 90° and then flipping it horizontally:

python main.py ./my_images rot_90,fliph

Operations

Horizontal Flip

Mirrors the image around a vertical line running through its center

python main.py ./my_images fliph

Original Image       Flipped Image

Vertical Flip

Mirrors the image around a horizontal line running through its center

python main.py ./my_images flipv

Original Image       Flipped Image

Noise

Adds random noise to the image. The amount of noise to be added is specified by a floating-point numeric value that is included in the transform argument, the numeric value must be greater than 0.

python main.py ./my_images noise_0.01 noise_0.02 noise_0.05

Original Image       Noisy Image       Noisy Image       Noisy Image

Rotate

Rotates the image. The angle of rotation is specified by an integer value that is included in the transform argument

python main.py ./my_images rot_90 rot_180 rot_-90

Original Image       Rotated Image       Rotated Image       Rotated Image

Translate

Performs a translation on the image. The size of the translation in the x and y directions are specified by integer values that are included in the transform argument

python main.py ./my_images trans_20_20 trans_0_100

Original Image       Translated Image       Translated Image

Zoom/Stretch

Zooms in (or out) to a particular area of the image. The top-left and bottom-right coordinates of the target region are specified by integer values included in the transform argument. By specifying a target region with an aspect ratio that differs from that of the source image, stretching transformations can be performed.

python main.py ./my_images zoom_150_0_300_150 zoom_0_50_300_150 zoom_200_0_300_300

Original Image       Zoomed Image       Stretched Image       Stretched Image

Blur

Blurs the image. The amount of blurring is specified by a floating-point value included in the transform argument.

python main.py ./my_images blur_1.0 blur_2.0 blur_4.0

Original Image       Blurred Image       Blurred Image       Blurred Image

More Repositories

1

homoglyph

A big list of homoglyphs and some code to detect them
JavaScript
535
star
2

mosaic

Python script for creating photomosaic images
Python
535
star
3

bitmeteros

BitMeter OS - a cross-platform bandwidth monitor
C
330
star
4

reading-list-mover

A Python utility for moving bookmarks/reading lists between services
Python
199
star
5

markov-text

Python utility that uses a Markov Chain to generate random sentences using a source text
Python
185
star
6

moment-precise-range

A moment.js plugin to display human-readable date/time ranges
JavaScript
150
star
7

bayesian-classifier

A Naive Bayesian Classifier written in Python
Python
102
star
8

star-charts

Generate SVG star charts using Python
Python
102
star
9

mazes

JavaScript Maze Generator
JavaScript
74
star
10

monkeyshine

A collection of slightly evil JavaScript
JavaScript
45
star
11

lunar-calendar

Generates an HTML Lunar Calendar
HTML
42
star
12

old-time-radio

An internet radio station streaming classic shows from the Golden Age of Radio
JavaScript
35
star
13

convnet-designer

A utility for designing Convolutional Neural Networks
JavaScript
27
star
14

readable-regex

Java library for creating readable regular expressions
Java
26
star
15

javabean-tester

JavaBean Tester
Java
24
star
16

js-planet-phase

A small JavaScript library for rendering realistic moon and planet phases in HTML
JavaScript
23
star
17

table-sorter

Table Sorter
JavaScript
21
star
18

generative-patterns

Web-Based Generative Pattern Maker
JavaScript
21
star
19

clipper

Page Clipper Bookmarklet
JavaScript
21
star
20

process-roulette

A shell script game where you kill random processes on your computer, the more you kill the higher your score!
Shell
16
star
21

wordvis

This is a Python script to generate Sunburst Charts that visualise the structure of English words.
Python
16
star
22

maze.js

Maze Generation Algorithms and Rendering Code
JavaScript
12
star
23

sarsa-lambda

A Python implementation of the SARSA λ reinforcement learning algorithm
Python
11
star
24

https-certificate-expiry-checker

A Python script for checking when HTTPS certificates will expire
Python
11
star
25

regex_parser

A regular expression parser written in JavaScript
JavaScript
10
star
26

blockchain

Minimum Viable Blockchain in Python
Python
9
star
27

star-rise-and-set-times

A browser-based tool for calculating the rising and setting times of stars
JavaScript
9
star
28

connect4

Python
8
star
29

save-restore

Save/Restore Bookmarklet
JavaScript
8
star
30

boggle

A boggle solver and game
Python
7
star
31

bokeh

Bokeh Animation with JavaScript
JavaScript
7
star
32

video-barcode-generator

Video Barcode Generator
Shell
6
star
33

show-passwords

Show Passwords Bookmarklet
HTML
6
star
34

scheme-interpreter

An interpreter for a basic subset of the Scheme programming language
Python
6
star
35

algorithms

Python
5
star
36

magnetic-pendulum

An interactive simulation of a Magnetic Pendulum
JavaScript
5
star
37

solar-system-moons

Python code for generating infographic posters that visualise data about the outer planets in our solar system
Python
5
star
38

zen.sh

A shell script meditation timer for macOS
Shell
4
star
39

top-down-parser

A simple top-down parser written in JavaScript
JavaScript
4
star
40

planetary-systems

Python code to generate an SVG showing planetary systems
Python
4
star
41

stellar-classification-parser

A parser for star classification codes
JavaScript
4
star
42

bitmeteros-python-client

A graphical client for BitMeter OS
Python
4
star
43

hltracker

Hotline Tracker
Visual Basic
3
star
44

netmo

Browser-based remote network monitoring tool
Python
3
star
45

gradient-descent

Python implementations of both Linear and Logistic Regression using Gradient Descent
Python
3
star
46

neural-net

A simple neural network implemented in Python
Python
2
star
47

beatmatcher

An HTML/JavaScript mixing and beatmatching game
JavaScript
2
star
48

crypto-tools

Python
1
star
49

twitter-min

Minimalist Twitter Search Client, contained in a single HTML file
HTML
1
star
50

analog-digital-clock

Analogue/Digital Clock
JavaScript
1
star
51

peg-parser

The beginnings of a Parsing Expression Grammar parser
Python
1
star
52

landscape

JavaScript
1
star
53

ball_stand

A 3D model of a ball-stand, useful for displaying the clear acrylic balls often used for contact juggling.
OpenSCAD
1
star
54

reinforcement-robot

Experiment with Reinforcement Learning using robots!
JavaScript
1
star
55

tcpdump-web

A web interface for tcpdump
JavaScript
1
star
56

wordle.sh

A Wordle-solving shell script
Shell
1
star
57

svg-stars

Generate pretty animated SVGs for stars
JavaScript
1
star