I was using Google Colab to train a model so I could try it on my laptop, however, when saving the model this error occurs, I'm using a GPU
[INFO] evaluating network...
precision recall f1-score support
with_mask 0.99 1.00 0.99 384
without_mask 1.00 0.99 0.99 386
accuracy 0.99 770
macro avg 0.99 0.99 0.99 770
weighted avg 0.99 0.99 0.99 770
[INFO] saving mask detector model...
Traceback (most recent call last):
File "train_mask_detector.py", line 149, in <module>
plt.plot(np.arange(0, N), H.history["acc"], label="train_acc")
KeyError: 'acc'
2020-08-15 15:09:08.012494: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudart.so.10.1
[INFO] loading images...
/usr/local/lib/python3.6/dist-packages/PIL/Image.py:961: UserWarning: Palette images with Transparency expressed in bytes should be converted to RGBA images
"Palette images with Transparency expressed in bytes should be "
tcmalloc: large alloc 2315722752 bytes == 0x91b80000 @ 0x7f2a8385e1e7 0x7f2a8007a5e1 0x7f2a800dee88 0x7f2a800e1fc8 0x7f2a800e25a5 0x7f2a8017984d 0x50a7f5 0x50cfd6 0x507f24 0x50b053 0x634dd2 0x634e87 0x63863f 0x6391e1 0x4b0dc0 0x7f2a8345bb97 0x5b26fa
tcmalloc: large alloc 1852096512 bytes == 0x11bbf2000 @ 0x7f2a8385e1e7 0x7f2a8007a5e1 0x7f2a800dee88 0x7f2a800defa3 0x7f2a8016a0c6 0x7f2a8016a528 0x50c4de 0x507f24 0x509c50 0x50a64d 0x50cfd6 0x507f24 0x509c50 0x50a64d 0x50c1f4 0x58e809 0x4c9306 0x588114 0x58834e 0x5517c1 0x5a9eec 0x50a783 0x50c1f4 0x507f24 0x509c50 0x50a64d 0x50cfd6 0x507f24 0x50b053 0x634dd2 0x634e87
WARNING:tensorflow:`input_shape` is undefined or non-square, or `rows` is not in [96, 128, 160, 192, 224]. Weights for input shape (224, 224) will be loaded as the default.
2020-08-15 15:09:31.941657: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcuda.so.1
2020-08-15 15:09:32.004988: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:982] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2020-08-15 15:09:32.005892: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1716] Found device 0 with properties:
pciBusID: 0000:00:04.0 name: Tesla K80 computeCapability: 3.7
coreClock: 0.8235GHz coreCount: 13 deviceMemorySize: 11.17GiB deviceMemoryBandwidth: 223.96GiB/s
2020-08-15 15:09:32.005987: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudart.so.10.1
2020-08-15 15:09:32.260469: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcublas.so.10
2020-08-15 15:09:32.402794: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcufft.so.10
2020-08-15 15:09:32.430120: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcurand.so.10
2020-08-15 15:09:32.701520: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcusolver.so.10
2020-08-15 15:09:32.728638: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcusparse.so.10
2020-08-15 15:09:33.266461: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudnn.so.7
2020-08-15 15:09:33.266776: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:982] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2020-08-15 15:09:33.267816: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:982] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2020-08-15 15:09:33.268607: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1858] Adding visible gpu devices: 0
2020-08-15 15:09:33.286410: I tensorflow/core/platform/profile_utils/cpu_utils.cc:104] CPU Frequency: 2300000000 Hz
2020-08-15 15:09:33.286728: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x1f08d80 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2020-08-15 15:09:33.286778: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Host, Default Version
2020-08-15 15:09:33.373932: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:982] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2020-08-15 15:09:33.374835: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x1f08bc0 initialized for platform CUDA (this does not guarantee that XLA will be used). Devices:
2020-08-15 15:09:33.374876: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Tesla K80, Compute Capability 3.7
2020-08-15 15:09:33.376571: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:982] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2020-08-15 15:09:33.377366: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1716] Found device 0 with properties:
pciBusID: 0000:00:04.0 name: Tesla K80 computeCapability: 3.7
coreClock: 0.8235GHz coreCount: 13 deviceMemorySize: 11.17GiB deviceMemoryBandwidth: 223.96GiB/s
2020-08-15 15:09:33.377428: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudart.so.10.1
2020-08-15 15:09:33.377501: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcublas.so.10
2020-08-15 15:09:33.377562: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcufft.so.10
2020-08-15 15:09:33.377609: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcurand.so.10
2020-08-15 15:09:33.377653: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcusolver.so.10
2020-08-15 15:09:33.377702: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcusparse.so.10
2020-08-15 15:09:33.377751: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudnn.so.7
2020-08-15 15:09:33.377909: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:982] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2020-08-15 15:09:33.378782: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:982] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2020-08-15 15:09:33.379553: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1858] Adding visible gpu devices: 0
2020-08-15 15:09:33.383743: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudart.so.10.1
2020-08-15 15:09:37.202833: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1257] Device interconnect StreamExecutor with strength 1 edge matrix:
2020-08-15 15:09:37.202895: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1263] 0
2020-08-15 15:09:37.202914: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1276] 0: N
2020-08-15 15:09:37.207175: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:982] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2020-08-15 15:09:37.208107: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:982] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2020-08-15 15:09:37.208872: W tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:39] Overriding allow_growth setting because the TF_FORCE_GPU_ALLOW_GROWTH environment variable is set. Original config value was 0.
2020-08-15 15:09:37.208930: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1402] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 10630 MB memory) -> physical GPU (device: 0, name: Tesla K80, pci bus id: 0000:00:04.0, compute capability: 3.7)
Downloading data from https://storage.googleapis.com/tensorflow/keras-applications/mobilenet_v2/mobilenet_v2_weights_tf_dim_ordering_tf_kernels_1.0_224_no_top.h5
9412608/9406464 [==============================] - 0s 0us/step
[INFO] compiling model...
[INFO] training head...
Epoch 1/20
2020-08-15 15:09:42.573008: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcublas.so.10
2020-08-15 15:09:44.011634: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudnn.so.7
96/96 [==============================] - 39s 408ms/step - loss: 0.3189 - accuracy: 0.8561 - val_loss: 0.0953 - val_accuracy: 0.9766
Epoch 2/20
96/96 [==============================] - 37s 390ms/step - loss: 0.1159 - accuracy: 0.9599 - val_loss: 0.0671 - val_accuracy: 0.9805
Epoch 3/20
96/96 [==============================] - 37s 389ms/step - loss: 0.0820 - accuracy: 0.9708 - val_loss: 0.0646 - val_accuracy: 0.9779
Epoch 4/20
96/96 [==============================] - 37s 381ms/step - loss: 0.0666 - accuracy: 0.9773 - val_loss: 0.0505 - val_accuracy: 0.9857
Epoch 5/20
96/96 [==============================] - 36s 378ms/step - loss: 0.0577 - accuracy: 0.9816 - val_loss: 0.0436 - val_accuracy: 0.9870
Epoch 6/20
96/96 [==============================] - 37s 388ms/step - loss: 0.0547 - accuracy: 0.9793 - val_loss: 0.0441 - val_accuracy: 0.9883
Epoch 7/20
96/96 [==============================] - 37s 385ms/step - loss: 0.0489 - accuracy: 0.9826 - val_loss: 0.0432 - val_accuracy: 0.9883
Epoch 8/20
96/96 [==============================] - 37s 381ms/step - loss: 0.0472 - accuracy: 0.9855 - val_loss: 0.0407 - val_accuracy: 0.9896
Epoch 9/20
96/96 [==============================] - 37s 380ms/step - loss: 0.0443 - accuracy: 0.9846 - val_loss: 0.0364 - val_accuracy: 0.9909
Epoch 10/20
96/96 [==============================] - 37s 388ms/step - loss: 0.0362 - accuracy: 0.9872 - val_loss: 0.0357 - val_accuracy: 0.9896
Epoch 11/20
96/96 [==============================] - 38s 391ms/step - loss: 0.0393 - accuracy: 0.9878 - val_loss: 0.0337 - val_accuracy: 0.9909
Epoch 12/20
96/96 [==============================] - 36s 378ms/step - loss: 0.0342 - accuracy: 0.9898 - val_loss: 0.0375 - val_accuracy: 0.9883
Epoch 13/20
96/96 [==============================] - 36s 378ms/step - loss: 0.0324 - accuracy: 0.9895 - val_loss: 0.0329 - val_accuracy: 0.9896
Epoch 14/20
96/96 [==============================] - 37s 386ms/step - loss: 0.0288 - accuracy: 0.9905 - val_loss: 0.0314 - val_accuracy: 0.9909
Epoch 15/20
96/96 [==============================] - 37s 383ms/step - loss: 0.0246 - accuracy: 0.9928 - val_loss: 0.0292 - val_accuracy: 0.9922
Epoch 16/20
96/96 [==============================] - 37s 381ms/step - loss: 0.0238 - accuracy: 0.9931 - val_loss: 0.0301 - val_accuracy: 0.9909
Epoch 17/20
96/96 [==============================] - 36s 375ms/step - loss: 0.0259 - accuracy: 0.9918 - val_loss: 0.0373 - val_accuracy: 0.9883
Epoch 18/20
96/96 [==============================] - 37s 386ms/step - loss: 0.0236 - accuracy: 0.9924 - val_loss: 0.0282 - val_accuracy: 0.9909
Epoch 19/20
96/96 [==============================] - 37s 388ms/step - loss: 0.0256 - accuracy: 0.9898 - val_loss: 0.0314 - val_accuracy: 0.9896
Epoch 20/20
96/96 [==============================] - 37s 384ms/step - loss: 0.0240 - accuracy: 0.9924 - val_loss: 0.0289 - val_accuracy: 0.9922
[INFO] evaluating network...
precision recall f1-score support
with_mask 0.99 1.00 0.99 384
without_mask 1.00 0.99 0.99 386
accuracy 0.99 770
macro avg 0.99 0.99 0.99 770
weighted avg 0.99 0.99 0.99 770
[INFO] saving mask detector model...
Traceback (most recent call last):
File "train_mask_detector.py", line 149, in <module>
plt.plot(np.arange(0, N), H.history["acc"], label="train_acc")
KeyError: 'acc'