Skip to main content

Angkor Wat, Cambodia

Tf Image Classifier

Model Evaluation

Keras Applications are deep learning models that are made available alongside pre-trained weights. These models can be used for prediction, feature extraction, and fine-tuning.

Weights are downloaded automatically when instantiating a model. They are stored at ~/.keras/models/:

Available Models - Excerp

ModelSize (MB)Top-1 AccuracyTop-5 AccuracyParametersDepthTime (ms) per inference step (CPU)Time (ms) per inference step (GPU)
Xception8879.0%94.5%22.9M81109.48.1
ResNet50V29876.0%93.0%25.6M10345.64.4
InceptionV39277.9%93.7%23.9M18942.26.9
MobileNet1670.4%89.5%4.3M5522.63.4
MobileNetV21471.3%90.1%3.5M10525.93.8
NASNetMobile2374.4%91.9%5.3M38927.06.7
EfficientNetV2B02978.7%94.3%7.2M---
EfficientNetV2B13479.8%95.0%8.2M---
EfficientNetV2B24280.5%95.1%10.2M---
EfficientNetV2B35982.0%95.8%14.5M---
EfficientNetV2S8883.9%96.7%21.6M---
EfficientNetV2M22085.3%97.4%54.4M---
EfficientNetV2L47985.7%97.5%119.0M---

Used Models

  • EfficientNetV2B0
  • EfficientNetV2S
  • Xception
  • InceptionV3
  • NASNetMobile
  • MobileNetV3Small
  • MobileNetV3Large
  • MobileNetV2
  • vit-base-patch16-224
  • DeiT
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns

Model Metrics

model_metrics = [
[ 'MobileNetV3Small', 0.3474, 0.9178, 16.753, 75, 260, 7, 76 ],
[ 'MobileNetV3Large', 0.0658, 0.9930, 34.593, 58, 206, 5, 40 ],
[ 'MobileNetV2', 1.2054, 0.6573, 47.857, 96, 331, 8, 79 ],
[ 'EfficientNetV2B0', 0.3779, 0.9084, 45.989, 47, 164, 8, 68 ],
[ 'EfficientNetV2S', 0.3431, 0.9013, 107.201, 66, 230, 21, 178 ],
[ 'Xception', 0.6363, 0.8188, 110.849, 69, 240, 18, 173 ],
[ 'InceptionV3', 2.7047, 0.3087, 116.969, 48, 167, 10, 85 ],
[ 'NASNetMobile', 3.2046, 0.1838, 38.513, 247, 857, 41, 423 ],
[ 'ViT', 0.5979, 0.8589, 350.537, 172, 597, 21, 203 ],
[ 'DeiT', 0.7199, 0.7900, 350.737, 174, 604, 21, 204 ]
]

data_columns = [
'Model',
'Loss',
'Accuracy',
'Tf Model Size [MB]',
'Training Training Set [s]',
'Training [ms/step]',
'Prediction Validation Set [s]',
'Prediction [ms/step]'
]
model_metrics_df = pd.DataFrame(model_metrics, columns=data_columns)
model_metrics_df = model_metrics_df.set_index('Model')



model_metrics_df
ModelLossAccuracyTf Model Size [MB]Training Training Set [s]Training [ms/step]Prediction Validation Set [s]Prediction [ms/step]
MobileNetV3Small0.34740.917816.75375260776
MobileNetV3Large0.06580.993034.59358206540
MobileNetV21.20540.657347.85796331879
EfficientNetV2B00.37790.908445.98947164868
EfficientNetV2S0.34310.9013107.2016623021178
Xception0.63630.8188110.8496924018173
InceptionV32.70470.3087116.969481671085
NASNetMobile3.20460.183838.51324785741423
ViT0.59790.8589350.53717259721203
DeiT0.71990.7900350.73717460421204
plt.figure(figsize=(12, 5))

sns.set(style='darkgrid')

sns.scatterplot(
x='Tf Model Size [MB]',
y='Accuracy',
data=model_metrics_df,
s=100,
alpha=1,
hue='Model',
palette='nipy_spectral'
).set_title('Accuracy vs Model Size')

plt.savefig('./assets/Model_Eval_04.webp', bbox_inches='tight')

Model Evaluation

plt.figure(figsize=(12, 5))

sns.set(style='darkgrid')

sns.scatterplot(
x='Tf Model Size [MB]',
y='Loss',
data=model_metrics_df,
s=100,
alpha=1,
hue='Model',
palette='nipy_spectral'
).set_title('Loss vs Model Size')

plt.savefig('./assets/Model_Eval_05.webp', bbox_inches='tight')

Model Evaluation

plt.figure(figsize=(12, 5))

sns.set(style='darkgrid')

sns.scatterplot(
x='Training [ms/step]',
y='Accuracy',
data=model_metrics_df,
s=100,
alpha=1,
hue='Model',
palette='nipy_spectral'
).set_title('Accuracy vs Training Time')

plt.savefig('./assets/Model_Eval_06.webp', bbox_inches='tight')

Model Evaluation

plt.figure(figsize=(12, 5))

sns.set(style='darkgrid')

sns.scatterplot(
x='Prediction [ms/step]',
y='Accuracy',
data=model_metrics_df,
s=100,
alpha=1,
hue='Model',
palette='nipy_spectral'
).set_title('Loss vs Prediction Time')

plt.savefig('./assets/Model_Eval_07.webp', bbox_inches='tight')

Model Evaluation

Loss Curves

loss_curves = [
[ 'MobileNetV3Small', './assets/MobileNetV3Small_FT_01.webp' ],
[ 'MobileNetV3Large', './assets/MobileNetV3Large_FT_01.webp' ],
[ 'EfficientNetV2B0', './assets/EfficientNetV2B0_01.webp' ],
[ 'EfficientNetV2S', './assets/EfficientNetV2S_01.webp' ],
[ 'Xception', './assets/Xception_01.webp' ],
[ 'InceptionV3', './assets/InceptionV3_FT_01.webp' ],
[ 'NASNetMobile', './assets/NASNetMobile_FT_01.webp' ],
[ 'MobileNetV2', './assets/MobileNetV2_FT_01.webp' ],
[ 'ViT', './assets/ViT_01.webp' ],
[ 'DeiT', './assets/DeiT_01.webp' ]
]
plt.figure(figsize=(16,5))

for model, curve in loss_curves:
for i in range(len(loss_curves)):
ax = plt.subplot(2,5,i+1)
plt.title(loss_curves[i][0])
image = plt.imread(loss_curves[i][1])
plt.imshow(image)
plt.axis('off')

plt.savefig('./assets/Model_Eval_01.webp', bbox_inches='tight')

Model Evaluation

Accuracy Curves

accuracy_curves = [
[ 'MobileNetV3Small', './assets/MobileNetV3Small_FT_02.webp' ],
[ 'MobileNetV3Large', './assets/MobileNetV3Large_FT_02.webp' ],
[ 'EfficientNetV2B0', './assets/EfficientNetV2B0_02.webp' ],
[ 'EfficientNetV2S', './assets/EfficientNetV2S_02.webp' ],
[ 'Xception', './assets/Xception_02.webp' ],
[ 'InceptionV3', './assets/InceptionV3_FT_02.webp' ],
[ 'NASNetMobile', './assets/NASNetMobile_FT_02.webp' ],
[ 'MobileNetV2', './assets/MobileNetV2_FT_02.webp' ],
[ 'ViT', './assets/ViT_02.webp' ],
[ 'DeiT', './assets/DeiT_02.webp' ]
]
plt.figure(figsize=(16,5))

for model, curve in accuracy_curves:
for i in range(len(accuracy_curves)):
ax = plt.subplot(2,5,i+1)
plt.title(accuracy_curves[i][0])
image = plt.imread(accuracy_curves[i][1])
plt.imshow(image)
plt.axis('off')

plt.savefig('./assets/Model_Eval_02.webp', bbox_inches='tight')

Model Evaluation

Confusion

confusion_matrices = [
[ 'MobileNetV3Small', './assets/MobileNetV3Small_FT_04.webp' ],
[ 'MobileNetV3Large', './assets/MobileNetV3Large_FT_04.webp' ],
[ 'EfficientNetV2B0', './assets/EfficientNetV2B0_04.webp' ],
[ 'EfficientNetV2S', './assets/EfficientNetV2S_04.webp' ],
[ 'Xception', './assets/Xception_FT_04.webp' ],
[ 'NASNetMobile', './assets/NASNetMobile_FT_04.webp' ],
[ 'MobileNetV2', './assets/MobileNetV2_FT_04.webp' ],
[ 'ViT', './assets/ViT_04.webp' ],
[ 'DeiT', './assets/DeiT_04.webp' ]
]
plt.figure(figsize=(14,12))

for model, curve in confusion_matrices:
for i in range(len(confusion_matrices)):
ax = plt.subplot(3,3,i+1)
plt.title(confusion_matrices[i][0])
image = plt.imread(confusion_matrices[i][1])
plt.imshow(image)
plt.axis('off')

plt.savefig('./assets/Model_Eval_03.webp', bbox_inches='tight')

Model Evaluation

Model Prediction

MobileNetV3Small

MobileNetV3Small_Predictions = [
[ './assets/MobileNetV3Small_Prediction_01.webp' ],
[ './assets/MobileNetV3Small_Prediction_02.webp' ],
[ './assets/MobileNetV3Small_Prediction_03.webp' ]
]
plt.figure(figsize=(16,8))

for prediction in MobileNetV3Small_Predictions:
for i in range(len(MobileNetV3Small_Predictions)):
ax = plt.subplot(1,3,i+1)
image = plt.imread(MobileNetV3Small_Predictions[i][0])
plt.imshow(image)
plt.axis('off')

plt.savefig('./assets/Model_Eval_MobileNetV3Small_01.webp', bbox_inches='tight')

Model Evaluation

Model Evaluation

MobileNetV2

MobileNetV2_Predictions = [
[ './assets/MobileNetV2_Prediction_01.webp' ],
[ './assets/MobileNetV2_Prediction_02.webp' ],
[ './assets/MobileNetV2_Prediction_03.webp' ]
]
plt.figure(figsize=(16,8))

for prediction in MobileNetV2_Predictions:
for i in range(len(MobileNetV2_Predictions)):
ax = plt.subplot(1,3,i+1)
image = plt.imread(MobileNetV2_Predictions[i][0])
plt.imshow(image)
plt.axis('off')

plt.savefig('./assets/Model_Eval_MobileNetV2_01.webp', bbox_inches='tight')

Model Evaluation

Model Evaluation

MobileNetV3Large

MobileNetV3Large_Predictions = [
[ './assets/MobileNetV3Large_Prediction_01.webp' ],
[ './assets/MobileNetV3Large_Prediction_02.webp' ],
[ './assets/MobileNetV3Large_Prediction_03.webp' ]
]
plt.figure(figsize=(16,8))

for prediction in MobileNetV3Small_Predictions:
for i in range(len(MobileNetV3Small_Predictions)):
ax = plt.subplot(1,3,i+1)
image = plt.imread(MobileNetV3Small_Predictions[i][0])
plt.imshow(image)
plt.axis('off')

plt.savefig('./assets/Model_Eval_MobileNetV3Large_01.webp', bbox_inches='tight')

Model Evaluation

Model Evaluation

EfficientNetV2B0

MobileNetV3Small_Predictions = [
[ './assets/EfficientNetV2B0_Prediction_01.webp' ],
[ './assets/EfficientNetV2B0_Prediction_02.webp' ],
[ './assets/EfficientNetV2B0_Prediction_03.webp' ]
]
plt.figure(figsize=(16,8))

for prediction in MobileNetV3Small_Predictions:
for i in range(len(MobileNetV3Small_Predictions)):
ax = plt.subplot(1,3,i+1)
image = plt.imread(MobileNetV3Small_Predictions[i][0])
plt.imshow(image)
plt.axis('off')

plt.savefig('./assets/Model_Eval_EfficientNetV2B0_01.webp', bbox_inches='tight')

Model Evaluation

Model Evaluation

EfficientNetV2S

EfficientNetV2S_Predictions = [
[ './assets/EfficientNetV2S_Prediction_01.webp' ],
[ './assets/EfficientNetV2S_Prediction_02.webp' ],
[ './assets/EfficientNetV2S_Prediction_03.webp' ]
]
plt.figure(figsize=(16,8))

for prediction in EfficientNetV2S_Predictions:
for i in range(len(EfficientNetV2S_Predictions)):
ax = plt.subplot(1,3,i+1)
image = plt.imread(EfficientNetV2S_Predictions[i][0])
plt.imshow(image)
plt.axis('off')

plt.savefig('./assets/Model_Eval_EfficientNetV2S_01.webp', bbox_inches='tight')

Model Evaluation

Model Evaluation

Xception

Xception_Predictions = [
[ './assets/Xception_Prediction_01.webp' ],
[ './assets/Xception_Prediction_02.webp' ],
[ './assets/Xception_Prediction_03.webp' ]
]
plt.figure(figsize=(16,8))

for prediction in Xception_Predictions:
for i in range(len(Xception_Predictions)):
ax = plt.subplot(1,3,i+1)
image = plt.imread(Xception_Predictions[i][0])
plt.imshow(image)
plt.axis('off')

plt.savefig('./assets/Model_Eval_Xception_01.webp', bbox_inches='tight')

Model Evaluation

Model Evaluation

NASNetMobile

NASNetMobile_Predictions = [
[ './assets/NASNetMobile_Prediction_01.webp' ],
[ './assets/NASNetMobile_Prediction_02.webp' ],
[ './assets/NASNetMobile_Prediction_03.webp' ]
]
plt.figure(figsize=(16,8))

for prediction in NASNetMobile_Predictions:
for i in range(len(NASNetMobile_Predictions)):
ax = plt.subplot(1,3,i+1)
image = plt.imread(NASNetMobile_Predictions[i][0])
plt.imshow(image)
plt.axis('off')

plt.savefig('./assets/Model_Eval_NASNetMobile_01.webp', bbox_inches='tight')

Model Evaluation

Model Evaluation

ViT

ViT_Predictions = [
[ './assets/ViT_Prediction_01.webp' ],
[ './assets/ViT_Prediction_02.webp' ],
[ './assets/ViT_Prediction_03.webp' ]
]
plt.figure(figsize=(16,8))

for prediction in ViT_Predictions:
for i in range(len(ViT_Predictions)):
ax = plt.subplot(1,3,i+1)
image = plt.imread(ViT_Predictions[i][0])
plt.imshow(image)
plt.axis('off')

plt.savefig('./assets/Model_Eval_ViT_01.webp', bbox_inches='tight')

Model Evaluation

Model Evaluation

DeiT

DeiT_Predictions = [
[ './assets/DeiT_Prediction_01.webp' ],
[ './assets/DeiT_Prediction_02.webp' ],
[ './assets/DeiT_Prediction_03.webp' ]
]
plt.figure(figsize=(16,8))

for prediction in DeiT_Predictions:
for i in range(len(DeiT_Predictions)):
ax = plt.subplot(1,3,i+1)
image = plt.imread(DeiT_Predictions[i][0])
plt.imshow(image)
plt.axis('off')

plt.savefig('./assets/Model_Eval_DeiT_01.webp', bbox_inches='tight')

Model Evaluation

Model Evaluation