Clothing recognition analysis based on CNN neural network model based on keras platform

Time:2020-10-4

Link to the original text: http://tecdat.cn/?p=8493

In many introductions of image recognition tasks, the famous MNIST dataset is usually used. However, there are some problems with these data

It’s too simple. For example, a simple MLP model can achieve 99% accuracy, while a 2-layer CNN can achieve 99% accuracy.

2. It is overused. Literally, each machine learning introductory article or image recognition task will use this data set as a benchmark. However, because it is very easy to obtain near perfect classification results, its practicability is compromised and it is not really useful for modern machine learning / AI tasks.

As a result, the fashion MNIST dataset appears. The data set is developed as a direct replacement of MNIST data

1. Same size and style: 28×28 gray image

2. Each image is associated with one of the 10 classes

0: T-shirt / top,

1: Pants,

2: Pullover,

3: Dress,

4: Coat,

5: Sandals,

6: Shirt,

7: Sports shoes,

8: Backpacks,

9: Boots

3. 60000 training samples and 10000 test samples. The following is a snapshot of some samples:

Clothing recognition analysis based on CNN neural network model based on keras platform

Since its inception, there have been several submissions to benchmark the data, some of which are more than 95% accurate.

Clothing recognition analysis based on CNN neural network model based on keras platform

I also tried to benchmark this data with keras. Keras is an advanced framework for building deep learning model. Tensorflow, theano and cntk are selected in the back end. It’s easy to install and use. For my application, I used the cntk back end.

Here, I will benchmark two models. One is MLP with 256-512-100-10 layer structure, and the other is VGg like CNN.

The first model achieves the accuracy of [0.89, 0.90] on the test data after 100 epochs, while the latter reaches the accuracy of > 0.94 after 45 periods.

Let’s start with tsne. Tsne is said to be the most effective size reduction tool.

I used 1000 samples to run quickly. If your PC is fast enough and has time, you can run tsne against a full dataset.

Clothing recognition analysis based on CNN neural network model based on keras platform

We see that several features, including mass size, bottom splitting and symmetry, separate the categories.

In order to build our own network, we first import some libraries

Clothing recognition analysis based on CNN neural network model based on keras platform

The accuracy of the model is nearly 90% on the test data set of about 100 periods. Now, let’s build a CNN model similar to VGg. We use an architecture similar to VGg, but still very different. Due to the small amount of graphical data, if we use the original VGg architecture, it is likely to over fit and perform poorly when testing the data, as observed in the publicly submitted benchmarks listed above. It is very natural and easy to build such a model in keras

This model has 1.5 million parameters. We can call the ‘fit’ method to train the model:

model3_fit=model3.fit(X_train, Y_train2, validation_data = (X_test, Y_test2), epochs=50, verbose=1, batch_size=500)

After 40 times, the accuracy of the model is 0.94 on the test data. Obviously, this model also has the problem of over fitting. We’ll fix that later.

Clothing recognition analysis based on CNN neural network model based on keras platform

Clothing recognition analysis based on CNN neural network model based on keras platform