Reputation: 47
I am new to Tensorflow and to implementing deep learning. I have a dataset of images (images of the same object).
I want to train a Neural Network model using python and Tensorflow for object detection.
I am trying to import the data to Tensorflow but I am not sure what is the right way to do it.
Most of the tutorials available online are using public datasets (i.e. MNIST), which importing is straightforward but not helpful in the case where I need to use my own data.
Is there a procedure or tutorial that i can follow?
Upvotes: 0
Views: 1116
Reputation: 3617
You could create a data directory containing one subdirectory per image class containing the respective image files and use flow_from_directory
of tf.keras.preprocessing.image.ImageDataGenerator
.
A tutorial on how to use this can be found in the Keras Blog.
Upvotes: 1
Reputation: 361
There are many ways to import images for training, you can use Tensorflow but these will be imported as Tensorflow objects, which you won't be able to visualize until you run the session.
My favorite tool to import images is skimage.io.imread
. The imported images will have the dimension (width, height, channels)
Or you can use importing tool from scipy.misc
.
To resize images, you can use skimage.transform.resize
.
Before training, you will need to normalize all the images to have the values between 0 and 1. To do that, you simply divide the images by 255.
The next step is to one hot encode your labels to be an array of 0s and 1s.
Then you can build and train your CNN.
Upvotes: 1