Classifying Images of Clothing Using TensorFlow
Train a Deep Learning model to classify images of clothing using Convolutional Neural Networks in TensorFlow.
Import the Fashion MNIST dataset
the MNIST fasion dataset conatins 70,000 grayscale image of 10 classes. Which reprsent individual clothing items with 28*28 pixels of resolution. Each value is in the range [0,255] which defines the color and intensity of each pixel. We'll be using 60,000 fir training and 10,000 for testing in order to classify images
The labels are an array of integers, ranging from 0 to 9. These correspond to the class of clothing the image represents:
Explore the data
Preprocess the data
Building the model
For this project, we are going to use a typical CNN architecture represented in the image below.
As we have in the image, we will include a convolutional and a pooling layers, then another convolutional and pooling layers. Then, we are going to add a flatten layer to transform our 2d-array image in a 1d-array and add some dense layers. We can add some dropout layers to reduce overfitting. For the last layer, we add a dense layer with the number of classes from our problem (10) and a softmax activation, which creates the probability distribution for each class.
Compile the model
Train the model
This model reaches an accuracy of about 0.95 (or 95%) on the training data.
Evaluating the model
It turns out that the accuracy on the test dataset is a little less than the accuracy on the training dataset. however this still represents a good result.
Make predictions
When the model predicts right, the text will be displayed in blue, if the prediction is wrong, it will be displayed in red. Also, it will be displayed the calculated probability for the predicted class.
Results
Conclusion
In this project, it was presented how to train a Convolutional Neural Network to classify images of clothing from the Fashion MNIST dataset using TensorFlow and Keras. Using this model, we got an overall accuracy of 91,22% in our test dataset, which is a good result. However, specifically for our Shirt class we got an accuracy of only 73%. We could try to improve the accuracy of this class using some data augmentation techniques. Furthermore, in case you want to get a model with higher accuracy, you could try changing some hyperparameters or using different network architectures.