Data augmentationn

In the W2, Transfer learning coding exercises, data augmentation is implemented on an image database imported from tensroflow. I was just wondering how this would be implemented with a dataset of my own computer.

Hi @Kevin_Zhou1, you can do it in the same way. Is there anything that made you feel otherwise?

There is no database of images. Images are stored in a directory (see image_dataset_from_directory)

Here’s an example of how you can perform augmentation with just 1 image (be sure to understand the previous concepts before this):

import tensorflow as tf
from matplotlib.pyplot import imshow

aug_model = tf.keras.Sequential([
    tf.keras.layers.RandomBrightness(factor=(.3, .7)),

image ='2.png')
png =, channels=3)
augmented = aug_model(png)

1 Like

I thought there was some different format in the directory or something, I’m really new to this so i wasn’t sure. thanks

No worries. I asked because I wanted to make sure I didn’t overlook - if you had time, do give it a try on your computer and feedback here if you find something.


1 Like