Friday, March 5, 2021
  • Setup menu at Appearance » Menus and assign menu to Top Bar Navigation
Advertisement
  • AI Development
    • Artificial Intelligence
    • Machine Learning
    • Neural Networks
    • Learn to Code
  • Data
    • Blockchain
    • Big Data
    • Data Science
  • IT Security
    • Internet Privacy
    • Internet Security
  • Marketing
    • Digital Marketing
    • Marketing Technology
  • Technology Companies
  • Crypto News
No Result
View All Result
NikolaNews
  • AI Development
    • Artificial Intelligence
    • Machine Learning
    • Neural Networks
    • Learn to Code
  • Data
    • Blockchain
    • Big Data
    • Data Science
  • IT Security
    • Internet Privacy
    • Internet Security
  • Marketing
    • Digital Marketing
    • Marketing Technology
  • Technology Companies
  • Crypto News
No Result
View All Result
NikolaNews
No Result
View All Result
Home Neural Networks

Data Augmentation using Python for Deep Learning

June 6, 2020
in Neural Networks
Data Augmentation using Python for Deep Learning
586
SHARES
3.3k
VIEWS
Share on FacebookShare on Twitter

Dealing with small data sets for Deep Learning.

Data Augmentation is a technique that can be used for making updated copies of images in the data set to artificially increase the size of a training dataset. This technique is very useful when the training data set is very small.

There are already many good articles published on this concept. We can refer to some of these articles at, learn about when to use data augmentation, and other important concepts at data augmentation.

You might also like

The Examples and Benefits of AI in Healthcare: From accurate diagnosis to remote patient monitoring | by ITRex Group | Mar, 2021

3 Types of Image Segmentation. If you are getting started with Machine… | by Doga Ozgon | Feb, 2021

The Role Of Artificial Intelligence In The Fight Against COVID | by B-cube.ai | Feb, 2021

Imagine that you are afraid of Thanos and believe that he is real and will visit Earth one day. As a token of measure, you want to build a defense system that feeds on camera input. The system is meant to be activated when Thanos arrives on Earth by classifying his image from the camera feed. To do that we need to train a reliable model for activating the defense system. If we have only 10 pictures of Thanos its very difficult to build a reliable model that can capture his presence.

1. AI for CFD: Intro (part 1)

2. Using Artificial Intelligence to detect COVID-19

3. Real vs Fake Tweet Detection using a BERT Transformer Model in few lines of code

4. Machine Learning System Design

So to have multiple pictures for training sets we can consider Data Augmentation. Better examples and scenarios of when to use augmentation are mentioned at click here. Let us consider the below image is the one for which we want to perform Data augmentation.

Image by Matt McGloin at comicbook.news

In this article, I’m going to solely concentrate on the coding part of Data Augmentation.

At first, we will look at, how this can be done using NumPy, and then we will discuss the image preprocessing Data Augmentation class in Keras that brings simplicity for this task.

Using Numpy

Importing required modules.

Loading an image to work on.

Cropping: with cropping, we can capture the required parts of the images. Here we are cropping at random to capture random windows of the images. Cropping too small images from the original image can cause information loss.

Randomly cropped images from the original image

Rotating Images: rotating the images to capture the real-time effect of capturing pictures at different angles.

Sample output after rotating images

Image Shifting or otherwise called Image translation: this is nothing but shifting pixels of a picture in some direction and adding back the shifted pixels back in the opposite direction.

Sample output after shifting images

For better results, we can combine some of these techniques, as we will get augmented pictures of different styles.

We have seen that using NumPy takes a lot of effort to manually change the values of the image array which is both computationally expensive and requires a lot of code as mentioned above.

Jobs in AI

Now, we can try augmentation using the Keras Neural Network framework, which makes our job a lot easier.

TensorFlow has a separate class which deals with data augmentation with a lot of different options rather than just flipping, zooming, and cropping the images.

By using Keras, there is no need for manual adjustment of pixels. Keras has inbuilt functions that take care of these things. So the code required for augmentation with Keras is way less along with multiple options.

Let us look at image prepossessing ImageDataGenerator class of Keras:

Let’s look at important arguments that are used for common data argumentation techniques:

  • rotation_range: Int. Degree range for random rotations.
  • width_shift_range: Float, 1-D array-like or int — a fraction of total width
  • height_shift_range: Float, 1-D array-like or int — a fraction of total height
  • brightness_range: Tuple or list of two floats. The range for picking a brightness shift value from.
  • shear_range: Float. Shear Intensity (Shear angle in the counter-clockwise direction in degrees)
  • zoom_range: Float or [lower, upper]. The range for random zoom. If a float, [lower, upper] = [1-zoom_range, 1+zoom_range]. A fraction of the total image to be zoomed.
  • horizontal_flip: Boolean. Randomly flip inputs horizontally.
  • vertical_flip: Boolean. Randomly flip inputs vertically.
  • rescale: rescaling factor. Defaults to None. If None or 0, no rescaling is applied, otherwise we multiply the data by the value provided (after applying all other transformations).
  • preprocessing_function: a function that will be applied to each input. The function will run after the image is resized and augmented. The function should take one argument: one image (Numpy tensor with rank 3) and should output a Numpy tensor with the same shape.
  • data_format: Image data format, either “channels_first” or “channels_last”.
  • validation_split: Float. The fraction of images reserved for validation (strictly between 0 and 1).
  • dtype: Dtype to use for the generated arrays.

For more details and arguments please check out the tf documentation.

Now, we will augment our images with some of the most common techniques like flipping, rotation, width and height shifting, varying brightness of the image, zooming, and re-scaling the images.

Sample output after using Keras augmentation

Now let’s look at how to augment a complete data set. We will consider the cifar10 data set.

We can notice from the above examples, it is better to use Keras for data augmentation than using NumPy.

Hope these large set of augmented images can help you to activate your defense system and save our planet.

The complete Jupiter notebook can be found at my git hub.

This is my first article, please provide feedback on how to improve my articles from here on.

Credit: BecomingHuman By: Sai Teja Ponugoti

Previous Post

How do tech giants know so much about you?

Next Post

Machine learning app turns face sketches into realististic photos / Boing Boing

Related Posts

The Examples and Benefits of AI in Healthcare: From accurate diagnosis to remote patient monitoring | by ITRex Group | Mar, 2021
Neural Networks

The Examples and Benefits of AI in Healthcare: From accurate diagnosis to remote patient monitoring | by ITRex Group | Mar, 2021

March 4, 2021
3 Types of Image Segmentation. If you are getting started with Machine… | by Doga Ozgon | Feb, 2021
Neural Networks

3 Types of Image Segmentation. If you are getting started with Machine… | by Doga Ozgon | Feb, 2021

March 4, 2021
The Role Of Artificial Intelligence In The Fight Against COVID | by B-cube.ai | Feb, 2021
Neural Networks

The Role Of Artificial Intelligence In The Fight Against COVID | by B-cube.ai | Feb, 2021

March 4, 2021
The TensorFlow Certification: get official recognition, but it’s hard! | by Keenan Moukarzel | Feb, 2021
Neural Networks

The TensorFlow Certification: get official recognition, but it’s hard! | by Keenan Moukarzel | Feb, 2021

March 3, 2021
The Symbolic World: Raising A Turing’s Child Machine (1/2) | by Puttatida Mahapattanakul | Feb, 2021
Neural Networks

The Symbolic World: Raising A Turing’s Child Machine (1/2) | by Puttatida Mahapattanakul | Feb, 2021

March 3, 2021
Next Post
Machine learning app turns face sketches into realististic photos / Boing Boing

Machine learning app turns face sketches into realististic photos / Boing Boing

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recommended

Plasticity in Deep Learning: Dynamic Adaptations for AI Self-Driving Cars

Plasticity in Deep Learning: Dynamic Adaptations for AI Self-Driving Cars

January 6, 2019
Microsoft, Google Use Artificial Intelligence to Fight Hackers

Microsoft, Google Use Artificial Intelligence to Fight Hackers

January 6, 2019

Categories

  • Artificial Intelligence
  • Big Data
  • Blockchain
  • Crypto News
  • Data Science
  • Digital Marketing
  • Internet Privacy
  • Internet Security
  • Learn to Code
  • Machine Learning
  • Marketing Technology
  • Neural Networks
  • Technology Companies

Don't miss it

Ransomware as a service is the new big problem for business
Internet Security

Ransomware as a service is the new big problem for business

March 5, 2021
Google Will Use ‘FLoC’ for Ad Targeting Once 3rd-Party Cookies Are Dead
Internet Privacy

Google Will Use ‘FLoC’ for Ad Targeting Once 3rd-Party Cookies Are Dead

March 5, 2021
AI and machine learning’s moment in health care
Machine Learning

AI and machine learning’s moment in health care

March 4, 2021
The Examples and Benefits of AI in Healthcare: From accurate diagnosis to remote patient monitoring | by ITRex Group | Mar, 2021
Neural Networks

The Examples and Benefits of AI in Healthcare: From accurate diagnosis to remote patient monitoring | by ITRex Group | Mar, 2021

March 4, 2021
Welcome to events Thursdays: Thursday’s daily brief
Digital Marketing

Welcome to events Thursdays: Thursday’s daily brief

March 4, 2021
How to Change the WordPress Admin Login Logo
Learn to Code

React authentication, simplified

March 4, 2021
NikolaNews

NikolaNews.com is an online News Portal which aims to share news about blockchain, AI, Big Data, and Data Privacy and more!

What’s New Here?

  • Ransomware as a service is the new big problem for business March 5, 2021
  • Google Will Use ‘FLoC’ for Ad Targeting Once 3rd-Party Cookies Are Dead March 5, 2021
  • AI and machine learning’s moment in health care March 4, 2021
  • The Examples and Benefits of AI in Healthcare: From accurate diagnosis to remote patient monitoring | by ITRex Group | Mar, 2021 March 4, 2021

Subscribe to get more!

© 2019 NikolaNews.com - Global Tech Updates

No Result
View All Result
  • AI Development
    • Artificial Intelligence
    • Machine Learning
    • Neural Networks
    • Learn to Code
  • Data
    • Blockchain
    • Big Data
    • Data Science
  • IT Security
    • Internet Privacy
    • Internet Security
  • Marketing
    • Digital Marketing
    • Marketing Technology
  • Technology Companies
  • Crypto News

© 2019 NikolaNews.com - Global Tech Updates