Classify the logos(among 6 selected brands) using deep learning:

sanskar agrawal
AITS Journal
3 min readSep 18, 2021

--

There are 6 different logos type (Burger King, McDonalds, Other, Starbucks, Subway, KFC). We have used CNN for predicting new ball images.

This Model Predicts whether the image is of which brand by seeing logos using Convolution Neural Network.

Importing Libraries:

Unzip the dataset:

Data Pre-processing:

Map the classifications i.e. classes to an integer and display the list of all unique 6 brands.

Output:

{'Burger King': 0, 'KFC': 1, 'McDonalds': 2, 'Other': 3, 'Starbucks': 4, 'Subway': 5}

Displaying some images from dataset:

Output:

Divide the training dataset into train set and validation set:

Output:

Found 1393 images belonging to 6 classes.
Found 345 images belonging to 6 classes.

Train a sequential model:

Output:

Model: "sequential"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
conv2d (Conv2D) (None, 100, 100, 32) 896
_________________________________________________________________
max_pooling2d (MaxPooling2D) (None, 50, 50, 32) 0
_________________________________________________________________
conv2d_1 (Conv2D) (None, 50, 50, 64) 18496
_________________________________________________________________
max_pooling2d_1 (MaxPooling2 (None, 25, 25, 64) 0
_________________________________________________________________
conv2d_2 (Conv2D) (None, 25, 25, 64) 36928
_________________________________________________________________
max_pooling2d_2 (MaxPooling2 (None, 12, 12, 64) 0
_________________________________________________________________
conv2d_3 (Conv2D) (None, 12, 12, 64) 36928
_________________________________________________________________
max_pooling2d_3 (MaxPooling2 (None, 6, 6, 64) 0
_________________________________________________________________
conv2d_4 (Conv2D) (None, 6, 6, 64) 36928
_________________________________________________________________
max_pooling2d_4 (MaxPooling2 (None, 3, 3, 64) 0
_________________________________________________________________
dropout (Dropout) (None, 3, 3, 64) 0
_________________________________________________________________
conv2d_5 (Conv2D) (None, 3, 3, 64) 36928
_________________________________________________________________
max_pooling2d_5 (MaxPooling2 (None, 1, 1, 64) 0
_________________________________________________________________
flatten (Flatten) (None, 64) 0
_________________________________________________________________
dense (Dense) (None, 256) 16640
_________________________________________________________________
activation (Activation) (None, 256) 0
_________________________________________________________________
dropout_1 (Dropout) (None, 256) 0
_________________________________________________________________
dense_1 (Dense) (None, 6) 1542
_________________________________________________________________
activation_1 (Activation) (None, 6) 0
=================================================================
Total params: 185,286
Trainable params: 185,286
Non-trainable params: 0
_________________________________________________________________

Compile and fit the model:

Output:

Epoch 1/40
44/44 [==============================] - 41s 934ms/step - loss: 1.5418 - accuracy: 0.4602 - val_loss: 1.4519 - val_accuracy: 0.4783
Epoch 2/40
44/44 [==============================] - 41s 932ms/step - loss: 1.3943 - accuracy: 0.4738 - val_loss: 1.4155 - val_accuracy: 0.4783
...
...
...
Epoch 39/40
44/44 [==============================] - 38s 861ms/step - loss: 0.2385 - accuracy: 0.9296 - val_loss: 0.4292 - val_accuracy: 0.8406
Epoch 40/40
44/44 [==============================] - 38s 860ms/step - loss: 0.2084 - accuracy: 0.9304 - val_loss: 0.7735 - val_accuracy: 0.7884

Plot curves:

Deep CC:

Notebook Link :

--

--

sanskar agrawal
AITS Journal

I am proficient in programming languages such as Python,SQL and Visualisation tools like Tableau and also passionate to solve challenging business problems.