Image Augmentation using machine learning computer vision
This is a deep learning neural network task that is used for image classification for computer vision.
Image Augmentation is a technique in which we can maintain the quality of the image after some changes with the image, For example, we can crop the images in different ways, so that the objects of interest appear in different positions, reducing the model’s dependence on the position where objects appear. We can also adjust the brightness, color, and other factors to reduce the model’s sensitivity to color. It can be said that image augmentation technology contributed greatly to the success of AlexNet.
Here we will learn and implement mxnet datasets.
First import all related packages
%matplotlib inline
import d2l
from mxnet import autograd, gluon, image, init, np, npx
from mxnet.gluon import nn
npx.set_np()
Image Augmentation Methods
Flipping and Cropping
Changing the Color
Overlying Multiple Image Augmentation Methods
First, read the image
#Read image from current directory
d2l.set_figsize((3.5, 2.5))
img = image.imread('../img/cat1.jpg')
d2l.plt.imshow(img.asnumpy());
Now this method run image "aug" methods for multiple times
#method to run aug multiple times
def apply(img, aug, num_rows=2, num_cols=4, scale=1.5):
Y = [aug(img) for _ in range(num_rows * num_cols)]
d2l.show_images(Y, num_rows, num_cols, scale=scale)
Flipping and Cropping
#flipping from left and right
apply(img, gluon.data.vision.transforms.RandomFlipLeftRight())
Changing the Color
This is another augmentation method is changing colors. We can change four aspects of the image color: brightness, contrast, saturation, and hue.
#Changing the britness
apply(img, gluon.data.vision.transforms.RandomBrightness(0.5))
Output:
Now we change the hue of the image
#changing the hue of image
apply(img, gluon.data.vision.transforms.RandomHue(0.5))
Output:
Get your project or assignment completed by Deep learning expert and experienced developers and researchers.
OR
If you have project files, You can send at codersarts@gmail.com directly