Intel Image Classification Using NN
4 min readOct 19, 2021
--
Context
This is image data of Natural Scenes around the world.
Content
This Data contains around 25k images of size 150x150 distributed under 6 categories.
{‘buildings’ -> 0,
‘forest’ -> 1,
‘glacier’ -> 2,
‘mountain’ -> 3,
‘sea’ -> 4,
‘street’ -> 5 }
The Train, Test, and Prediction data is separated in each zip file. There are around 14k images in Train, 3k in Test, and 7k in Prediction.
This data was initially published on https://datahack.analyticsvidhya.com by Intel to host an Image classification Challenge.
Input Libraries
Import Data
Data Visualization
{0: 'buildings',
1: 'forest',
2: 'glacier',
3: 'mountain',
4: 'sea',
5: 'street'}
Model Architecture
Model: "sequential_5"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
conv2d_20 (Conv2D) (None, 50, 50, 32) 896
_________________________________________________________________
activation_20 (Activation) (None, 50, 50, 32) 0
_________________________________________________________________
conv2d_21 (Conv2D) (None, 48, 48, 32) 9248
_________________________________________________________________
dropout_15 (Dropout) (None, 48, 48, 32) 0
_________________________________________________________________
activation_21 (Activation) (None, 48, 48, 32) 0
_________________________________________________________________
max_pooling2d_10 (MaxPooling (None, 24, 24, 32) 0
_________________________________________________________________
conv2d_22 (Conv2D) (None, 22, 22, 50) 14450
_________________________________________________________________
activation_22 (Activation) (None, 22, 22, 50) 0
_________________________________________________________________
conv2d_23 (Conv2D) (None, 20, 20, 50) 22550
_________________________________________________________________
dropout_16 (Dropout) (None, 20, 20, 50) 0
_________________________________________________________________
activation_23 (Activation) (None, 20, 20, 50) 0
_________________________________________________________________
max_pooling2d_11 (MaxPooling (None, 10, 10, 50) 0
_________________________________________________________________
flatten_5 (Flatten) (None, 5000) 0
_________________________________________________________________
dense_15 (Dense) (None, 40) 200040
_________________________________________________________________
dense_16 (Dense) (None, 50) 2050
_________________________________________________________________
dropout_17 (Dropout) (None, 50) 0
_________________________________________________________________
dense_17 (Dense) (None, 6) 306
=================================================================
Total params: 249,540
Trainable params: 249,540
Non-trainable params: 0
Training the model
Epoch 1/12
439/439 [==============================] - 6s 13ms/step - loss: 1.1497 - accuracy: 0.5524 - val_loss: 1.0417 - val_accuracy: 0.6267
Epoch 2/12
439/439 [==============================] - 5s 12ms/step - loss: 0.8936 - accuracy: 0.6692 - val_loss: 0.8492 - val_accuracy: 0.7253
Epoch 3/12
439/439 [==============================] - 5s 12ms/step - loss: 0.7592 - accuracy: 0.7380 - val_loss: 0.7181 - val_accuracy: 0.7700
Epoch 4/12
439/439 [==============================] - 5s 12ms/step - loss: 0.6645 - accuracy: 0.7740 - val_loss: 0.7024 - val_accuracy: 0.7577
Epoch 5/12
439/439 [==============================] - 5s 12ms/step - loss: 0.6098 - accuracy: 0.7956 - val_loss: 0.6478 - val_accuracy: 0.7883
Epoch 6/12
439/439 [==============================] - 5s 12ms/step - loss: 0.5721 - accuracy: 0.8146 - val_loss: 0.6326 - val_accuracy: 0.7973
Epoch 7/12
439/439 [==============================] - 5s 12ms/step - loss: 0.5257 - accuracy: 0.8313 - val_loss: 0.6020 - val_accuracy: 0.8127
Epoch 8/12
439/439 [==============================] - 5s 12ms/step - loss: 0.4935 - accuracy: 0.8435 - val_loss: 0.6411 - val_accuracy: 0.7797
Epoch 9/12
439/439 [==============================] - 5s 12ms/step - loss: 0.4705 - accuracy: 0.8536 - val_loss: 0.5860 - val_accuracy: 0.8183
Epoch 10/12
439/439 [==============================] - 5s 12ms/step - loss: 0.4290 - accuracy: 0.8673 - val_loss: 0.6026 - val_accuracy: 0.8083
Epoch 11/12
439/439 [==============================] - 5s 12ms/step - loss: 0.4084 - accuracy: 0.8756 - val_loss: 0.5855 - val_accuracy: 0.8147
Epoch 12/12
439/439 [==============================] - 5s 12ms/step - loss: 0.3807 - accuracy: 0.8879 - val_loss: 0.5747 - val_accuracy: 0.8223
Accuracy and Loss Graphs
Prediction
Found 7301 images belonging to 1 classes
DeepCC
[INFO]
Reading [keras model] 'model.h5'
[SUCCESS]
Saved 'model_deepC/model.onnx'
[INFO]
Reading [onnx model] 'model_deepC/model.onnx'
[INFO]
Model info:
ir_vesion : 5
doc :
[WARNING]
[ONNX]: graph-node conv2d_20's attribute auto_pad has no meaningful data.
[WARNING]
[ONNX]: terminal (input/output) conv2d_20_input's shape is less than 1. Changing it to 1.
[WARNING]
[ONNX]: terminal (input/output) dense_17's shape is less than 1. Changing it to 1.
WARN (GRAPH): found operator node with the same name (dense_17) as io node.
[INFO]
Running DNNC graph sanity check ...
[SUCCESS]
Passed sanity check.
[INFO]
Writing C++ file 'model_deepC/model.cpp'
[INFO]
deepSea model files are ready in 'model_deepC/'
[RUNNING COMMAND]
g++ -std=c++11 -O3 -fno-rtti -fno-exceptions -I. -I/opt/tljh/user/lib/python3.7/site-packages/deepC-0.13-py3.7-linux-x86_64.egg/deepC/include -isystem /opt/tljh/user/lib/python3.7/site-packages/deepC-0.13-py3.7-linux-x86_64.egg/deepC/packages/eigen-eigen-323c052e1731 "model_deepC/model.cpp" -D_AITS_MAIN -o "model_deepC/model.exe"
[RUNNING COMMAND]
size "model_deepC/model.exe"
text data bss dec hex filename
1170525 3784 760 1175069 11ee1d model_deepC/model.exe
[SUCCESS]
Saved model as executable "model_deepC/model.exe"
Notebook Link: Here
Credits: Siddharth Ganjoo