| Literature DB >> 34884080 |
Grzegorz Wieczorek1, Marcin Chlebus2, Janusz Gajda2, Katarzyna Chyrowicz3, Kamila Kontna3, Michał Korycki3, Albina Jegorowa4, Michał Kruk1.
Abstract
The multiclass prediction approach to the problem of recognizing the state of the drill by classifying images of drilled holes into three classes is presented. Expert judgement was made on the basis of the quality of the hole, by dividing the collected photographs into the classes: "very fine," "acceptable," and "unacceptable." The aim of the research was to create a model capable of identifying different levels of quality of the holes, where the reduced quality would serve as a warning that the drill is about to wear down. This could reduce the damage caused by a blunt tool. To perform this task, real-world data were gathered, normalized, and scaled down, and additional instances were created with the use of data-augmentation techniques, a self-developed transformation, and with general adversarial networks. This approach also allowed us to achieve a slight rebalance of the dataset, by creating higher numbers of images belonging to the less-represented classes. The datasets generated were then fed into a series of convolutional neural networks, with different numbers of convolution layers used, modelled to carry out the multiclass prediction. The performance of the so-designed model was compared to predictions generated by Microsoft's Custom Vision service, trained on the same data, which was treated as the benchmark. Several trained models obtained by adjusting the structure and hyperparameters of the model were able to provide better recognition of less-represented classes than the benchmark.Entities:
Keywords: CNN; GAN; laminated chipboard; multi-class classification
Mesh:
Year: 2021 PMID: 34884080 PMCID: PMC8659545 DOI: 10.3390/s21238077
Source DB: PubMed Journal: Sensors (Basel) ISSN: 1424-8220 Impact factor: 3.576
Figure 1Comparison of gradients. Rotated image has visible blank spaces.
Figure 2Exemplary images from original dataset.
Sizes of the classes in the dataset.
| Class | Description | Number of Objects |
|---|---|---|
| Class 0 | very fine | 33 |
| Class 1 | acceptable | 271 |
| Class 2 | unacceptable | 155 |
|
| 459 |
Number of observations in the dataset and its distribution between classes.
| Class | Train | Validation | Test |
|---|---|---|---|
| Class 0 | 19 | 7 | 7 |
| Class 1 | 162 | 54 | 55 |
| Class 2 | 93 | 31 | 31 |
|
| 274 | 92 | 93 |
Confusion matrix for CNN Model on validation set trained on original dataset (274 observations).
| True/Predicted | Class 0 | Class 1 | Class 2 |
|---|---|---|---|
| Class 0 | 0/7 | 7/7 | 0/7 |
| Class 1 | 0/54 | 54/54 | 0/54 |
| Class 2 | 0/31 | 31/31 | 0/31 |
Figure 3Model accuracy for the training and validation sets in relation to different number of epochs used to train the CNN.
Figure 4Model loss for the training and validation sets in relation to different number of epochs used to train the CNN.
Figure 5Creation of additional data entry for images belonging to class 2.
Number of observations in the training dataset after the combination of images was applied to original data.
| Class | Train |
|---|---|
| Class 0 | 361 |
| Class 1 | 1597 |
| Class 2 | 521 |
|
| 2479 |
Number of observations in the train dataset and its distribution between classes after data augmentation.
| Class | Train |
|---|---|
| Class 0 | 1440 |
| Class 1 | 3190 |
| Class 2 | 2080 |
|
| 6710 |
Figure 6Images generated using simple data augmentation techniques.
Structure of GAN generator model.
| Layer | Output Shape | Parameters |
|---|---|---|
| Dense | (None, 3200) | 259,200 |
| LeakyReLU | (None, 3200) | 0 |
| Reshape | (None, 5, 5, 128) | 0 |
| Conv2DTranspose | (None, 10, 10, 128) | 262,272 |
| LeakyReLU | (None, 10, 10, 128) | 0 |
| Conv2DTranspose | (None, 20, 20, 128) | 262,272 |
| LeakyReLU | (None, 20, 20, 128) | 0 |
| Conv2DTranspose | (None, 40, 40, 128) | 262,272 |
| LeakyReLU | (None, 40, 40, 128) | 0 |
| Conv2DTranspose | (None, 80, 80, 128) | 262,272 |
| LeakyReLU | (None, 80, 80, 128) | 0 |
| Conv2D | (None, 80, 80, 1) | 1153 |
|
| 1,309,441 | |
|
| 1,309,441 |
Structure of the GAN discriminator model.
| Layer | Output shape | Parameters |
|---|---|---|
| Conv2D | (None, 40, 40, 64) | 640 |
| LeakyReLU | (None, 40, 40, 64) | 0 |
| Dropuot | (None, 40, 40, 64) | 0 |
| Conv2D | (None, 20, 20, 64) | 36,928 |
| LeakyReLU | (None, 20, 20, 64) | 0 |
| Dropuot | (None, 20, 20, 64) | 0 |
| Flatten | (None, 25, 600) | 0 |
| Dense | (None, 1) | 26,601 |
|
| 63,169 | |
|
| 0 | |
|
| 63,169 |
Structure of the GAN model.
| Layer | Output Shape | Parameters |
|---|---|---|
| Generator model | (None, 80, 80, 1) | 1,309,441 |
| Discriminator model | (None, 1) | 63,169 |
|
| 1,372,610 | |
|
| 1,309,441 | |
|
| 63,169 |
Figure 7Images generated by the GANs.
Number of classes in the training dataset generated by the GANs.
| Class | Train |
|---|---|
| Class 0 | 1400 |
| Class 1 | 3100 |
| Class 2 | 2000 |
|
| 6500 |
Number of observations in the dataset and its distribution between classes.
| Class | Train | Validation | Test |
|---|---|---|---|
| Class 0 | 3201 | 7 | 7 |
| Class 1 | 7887 | 54 | 55 |
| Class 2 | 4601 | 31 | 31 |
|
| 15,689 | 92 | 93 |
Figure 8ROC curves for the Microsoft Custom Vision model.
Confusion matrices for the Custom Vision model on the validation set with different correcting vectors.
| Custom Vision Model, Default Results | |||
|---|---|---|---|
|
|
|
|
|
| Class 0 | 1/7 | 6/7 | 0/7 |
| Class 1 | 0/54 | 54/54 | 0/54 |
| Class 2 | 0/31 | 19/31 | 12/31 |
|
| |||
|
|
|
|
|
| Class 0 | 3/7 | 4/7 | 0/7 |
| Class 1 | 2/54 | 52/54 | 0/54 |
| Class 2 | 0/31 | 16/31 | 15/31 |
|
| |||
|
|
|
|
|
| Class 0 | 2/7 | 5/7 | 0/7 |
| Class 1 | 2/54 | 52/54 | 0/54 |
| Class 2 | 0/31 | 16/31 | 15/31 |
Precision and recall per class for the Microsoft Custom Vision model on the validation set with different correction vectors.
| Microsoft Custom Vision | Class 0 | Class 1 | Class 2 |
|---|---|---|---|
| Precision (default) | 1.00 | 0.68 | 1.00 |
| Recall (default) | 0.14 | 1.00 | 0.39 |
| Precision (original ratio) | 0.60 | 0.72 | 1.00 |
| Recall (original ratio) | 0.43 | 0.96 | 0.48 |
| Precision (training ratio) | 0.50 | 0.71 | 1.00 |
| Recall (training ratio) | 0.29 | 0.96 | 0.48 |
F1 scores for the Custom Vision model on the validation set with different correcting vectors.
| Model | F1 Micro | F1 Macro |
|---|---|---|
| Model with default results | 0.73 | 0.54 |
| Model with original training vector | 0.76 | 0.66 |
| Model with multiplied training vector | 0.75 | 0.61 |
Structure of the proposed CNN model; example of a model with 4 layers.
| Layer | Output Shape | Parameters |
|---|---|---|
| Conv2D | (None, 78, 78, 32) | 320 |
| Conv2D | (None, 76, 76, 32) | 9248 |
| MaxPooling | (None, 38, 38, 32) | 0 |
| Conv2D | (None, 36, 36, 64) | 18,496 |
| Conv2D | (None, 34, 34, 64) | 36,928 |
| MaxPooling | (None, 17, 17, 64) | 0 |
| Conv2D | (None, 15, 15, 128) | 73,856 |
| Conv2D | (None, 13, 13, 128) | 147,584 |
| MaxPooling | (None, 6, 6, 128) | 0 |
| Conv2D | (None, 4, 4, 128) | 295,168 |
| Conv2D | (None, 2, 2, 128) | 590,080 |
| MaxPooling | (None, 1, 1, 128) | 0 |
| Flatten | (None, 256) | 0 |
| Dense | (None, 128) | 32,896 |
| Dense | (None, 64) | 8256 |
| Dense | (None, 3) | 195 |
|
| 1,213,027 | |
|
| 1,213,027 | |
|
| 0 |
Figure 9Model accuracy for the model with 1 layer and a batch size of 256 in relation to different number of epochs used to train the CNN.
Figure 10Model loss for the model with 1 layer and a batch size of 256 in relation to different number of epochs used to train the CNN.
Parameter configuration and model loss for the training and validation sets.
| Number | Batch | Epochs | Train | Validation |
|---|---|---|---|---|
| of Layers | Size | Loss | Loss | |
| 1 | 256 | 1 | 0.51 | 0.72 |
| 1 | 512 | 1 | 0.86 | 0.89 |
| 1 | 128 | 1 | 0.33 | 0.90 |
| 4 | 512 | 3 | 0.44 | 0.92 |
| 3 | 512 | 2 | 0.59 | 0.93 |
| 4 | 16 | 4 | 1.03 | 0.93 |
| 2 | 512 | 1 | 0.88 | 0.93 |
| 4 | 128 | 2 | 0.29 | 0.97 |
| 1 | 512 | 5 | 0.05 | 0.98 |
| 3 | 512 | 4 | 0.23 | 0.98 |
Parameter configuration, AUC for each class, and minimum AUC for the validation set.
| Number of | Batch | Epochs | AUC | AUC | AUC | min |
|---|---|---|---|---|---|---|
| Layers | Size | Class 0 | Class 1 | Class 2 | AUC | |
| 2 | 8 | 4 | 0.70 | 0.72 | 0.80 | 0.70 |
| 3 | 8 | 6 | 0.69 | 0.73 | 0.78 | 0.69 |
| 3 | 8 | 1 | 0.73 | 0.68 | 0.78 | 0.68 |
| 4 | 8 | 11 | 0.68 | 0.71 | 0.77 | 0.68 |
| 3 | 8 | 11 | 0.67 | 0.71 | 0.76 | 0.67 |
| 3 | 16 | 8 | 0.67 | 0.68 | 0.79 | 0.67 |
| 3 | 8 | 5 | 0.67 | 0.66 | 0.79 | 0.66 |
| 4 | 8 | 10 | 0.69 | 0.66 | 0.75 | 0.66 |
| 2 | 8 | 6 | 0.66 | 0.68 | 0.77 | 0.66 |
| 3 | 16 | 3 | 0.66 | 0.75 | 0.80 | 0.66 |
Description of chosen models based on the validation loss and the highest minimal AUC value.
| Model | Number | Batch | Epochs | Validation | min |
|---|---|---|---|---|---|
| of Layers | Size | Loss | AUC | ||
| 1 | 1 | 256 | 1 | 0.72 | 0.53 |
| 2 | 1 | 512 | 1 | 0.89 | 0.46 |
| 3 | 1 | 128 | 1 | 0.90 | 0.55 |
| 4 | 2 | 8 | 4 | 2.61 | 0.70 |
| 5 | 3 | 8 | 6 | 2.11 | 0.69 |
| 6 | 3 | 8 | 1 | 1.76 | 0.68 |
Validation loss for the 6 best models after removing the third dense layer.
| Model | Number | Batch | Epochs | 3rd Dense | Validation |
|---|---|---|---|---|---|
| of Layers | Size | Layer Present | Loss | ||
| 1 | 1 | 256 | 1 | Yes | 0.72 |
| 1 | 1 | 256 | 1 | No | 1.05 |
| 2 | 1 | 512 | 1 | Yes | 0.89 |
| 2 | 1 | 512 | 1 | No | 1.00 |
| 3 | 1 | 128 | 1 | Yes | 0.90 |
| 3 | 1 | 128 | 1 | No | 0.75 |
| 4 | 2 | 8 | 4 | Yes | 2.61 |
| 4 | 2 | 8 | 4 | No | 3.27 |
| 5 | 3 | 8 | 6 | Yes | 2.11 |
| 5 | 3 | 8 | 6 | No | 2.89 |
| 6 | 3 | 8 | 1 | Yes | 1.76 |
| 6 | 3 | 8 | 1 | No | 1.55 |
Figure 11ROC curves for the 6 best models.
Confusion matrices for models 1–6.
| Model 1 | |||
|---|---|---|---|
|
|
|
|
|
| Class 0 | 0/7 | 5/7 | 2/7 |
| Class 1 | 5/54 | 46/54 | 3/54 |
| Class 2 | 0/31 | 10/31 | 21/31 |
|
| |||
|
|
|
|
|
| Class 0 | 0/7 | 7/7 | 0/7 |
| Class 1 | 0/54 | 54/54 | 0/54 |
| Class 2 | 0/31 | 29/31 | 2/31 |
|
| |||
|
|
|
|
|
| Class 0 | 0/7 | 7/7 | 0/7 |
| Class 1 | 8/54 | 46/54 | 0/54 |
| Class 2 | 2/31 | 8/31 | 21/31 |
|
| |||
|
|
|
|
|
| Class 0 | 0/7 | 7/7 | 0/7 |
| Class 1 | 1/54 | 49/54 | 4/54 |
| Class 2 | 0/31 | 14/31 | 17/31 |
|
| |||
|
|
|
|
|
| Class 0 | 1/7 | 5/7 | 1/7 |
| Class 1 | 1/54 | 47/54 | 6/54 |
| Class 2 | 0/31 | 11/31 | 20/31 |
|
| |||
|
|
|
|
|
| Class 0 | 0/7 | 6/7 | 1/7 |
| Class 1 | 2/54 | 51/54 | 1/54 |
| Class 2 | 0/31 | 16/31 | 15/31 |
Precisions and recalls for models 1–6.
| Model 1 | Class 0 | Class 1 | Class 2 |
|---|---|---|---|
| Precision | 0.00 | 0.75 | 0.81 |
| Recall | 0.00 | 0.85 | 0.68 |
|
| |||
| Precision | 0.00 | 0.60 | 1.00 |
| Recall | 0.00 | 1.00 | 0.06 |
|
| |||
| Precision | 0.00 | 0.75 | 1.00 |
| Recall | 0.00 | 0.85 | 0.68 |
|
| |||
| Precision | 0.00 | 0.70 | 0.81 |
| Recall | 0.00 | 0.91 | 0.55 |
|
| |||
| Precision | 0.50 | 0.75 | 0.74 |
| Recall | 0.14 | 0.87 | 0.65 |
|
| |||
| Precision | 0.00 | 0.70 | 0.88 |
| Recall | 0.00 | 0.94 | 0.48 |
F1 scores for the 6 best models.
| Model | F1 Micro | F1 Macro |
|---|---|---|
| Model 1 | 0.73 | 0.51 |
| Model 2 | 0.61 | 0.29 |
| Model 3 | 0.73 | 0.54 |
| Model 4 | 0.72 | 0.48 |
| Model 5 | 0.74 | 0.57 |
| Model 6 | 0.72 | 0.48 |
Confusion matrices for models 1, 3, and 5, corrected with the original training vector on the validation set.
| Confusion Matrix, Model 1, Original Training Vector | |||
|---|---|---|---|
|
|
|
|
|
| Class 0 | 4/7 | 1/7 | 2/7 |
| Class 1 | 37/54 | 12/54 | 5/54 |
| Class 2 | 5/31 | 3/31 | 23/31 |
|
| |||
|
|
|
|
|
| Class 0 | 3/7 | 2/7 | 2/7 |
| Class 1 | 37/54 | 15/54 | 2/54 |
| Class 2 | 7/31 | 2/31 | 22/31 |
|
| |||
|
|
|
|
|
| Class 0 | 1/7 | 5/7 | 1/7 |
| Class 1 | 3/54 | 43/54 | 8/54 |
| Class 2 | 0/31 | 11/31 | 20/31 |
Confusion matrices for models 1, 3, and 5, corrected with multiplied training vector on the validation set.
| Confusion Matrix, Model 1, Multiplied Training Vector | |||
|---|---|---|---|
|
|
|
|
|
| Class 0 | 1/7 | 4/7 | 2/7 |
| Class 1 | 14/54 | 35/54 | 5/54 |
| Class 2 | 2/31 | 5/31 | 24/31 |
|
| |||
|
|
|
|
|
| Class 0 | 1/7 | 4/7 | 2/7 |
| Class 1 | 16/54 | 36/54 | 2/54 |
| Class 2 | 2/31 | 6/31 | 23/31 |
|
| |||
|
|
|
|
|
| Class 0 | 1/7 | 5/7 | 1/7 |
| Class 1 | 1/54 | 45/54 | 8/54 |
| Class 2 | 0/31 | 11/31 | 20/31 |
Precisions and recalls for models 1, 3, and 5 with correcting vectors applied.
| Model 1 | Class 0 | Class 1 | Class 2 |
|---|---|---|---|
| Precision (default) | 0.00 | 0.75 | 0.81 |
| Recall (default) | 0.00 | 0.85 | 0.68 |
| Precision (original ratio) | 0.09 | 0.75 | 0.77 |
| Recall (original ratio) | 0.57 | 0.22 | 0.74 |
| Precision (training ratio) | 0.06 | 0.80 | 0.77 |
| Recall (training ratio) | 0.14 | 0.65 | 0.77 |
|
|
|
|
|
| Precision (default) | 0.00 | 0.75 | 1.00 |
| Recall (default) | 0.00 | 0.85 | 0.68 |
| Precision (original ratio) | 0.06 | 0.79 | 0.85 |
| Recall (original ratio) | 0.43 | 0.28 | 0.71 |
| Precision (training ratio) | 0.05 | 0.78 | 0.85 |
| Recall (training ratio) | 0.14 | 0.67 | 0.74 |
|
|
|
|
|
| Precision (default) | 0.50 | 0.75 | 0.74 |
| Recall (default) | 0.14 | 0.87 | 0.65 |
| Precision (original ratio) | 0.25 | 0.73 | 0.69 |
| Recall (original ratio) | 0.14 | 0.80 | 0.65 |
| Precision (training ratio) | 0.50 | 0.74 | 0.69 |
| Recall (training ratio) | 0.14 | 0.83 | 0.65 |
F1 micro- and macro-scores for the best models with different correcting vectors.
| Model | F1 Micro | F1 Macro |
|---|---|---|
| Model 1 (default) | 0.73 | 0.51 |
| Model 1 (original ratio) | 0.42 | 0.42 |
| Model 1 (training ratio) | 0.65 | 0.52 |
| Model 3 (default) | 0.73 | 0.54 |
| Model 3 (original ratio) | 0.43 | 0.43 |
| Model 3 (training ratio) | 0.65 | 0.53 |
| Model 5 (default) | 0.74 | 0.57 |
| Model 5 (original ratio) | 0.70 | 0.54 |
| Model 5 (training ratio) | 0.72 | 0.56 |
Confusion matrices for best CNN Model and Custom Vision model corrected with original training vector on test set.
| Confusion Matrix, Best Cnn Model, Original Training Vector | |||
|---|---|---|---|
|
|
|
|
|
| Class 0 | 6/7 | 1/7 | 0/7 |
| Class 1 | 19/55 | 26/55 | 10/55 |
| Class 2 | 1/31 | 2/31 | 28/31 |
|
| |||
|
|
|
|
|
| Class 0 | 4/7 | 3/7 | 0/7 |
| Class 1 | 1/55 | 52/55 | 2/55 |
| Class 2 | 0/31 | 11/31 | 20/31 |
Precisions and recalls for best CNN Model and Custom Vision model corrected with original training vector on the test set.
| CNN Model | Class 0 | Class 1 | Class 2 |
|---|---|---|---|
| Precision | 0.23 | 0.89 | 0.74 |
| Recall | 0.86 | 0.47 | 0.90 |
|
| |||
| Precision | 0.80 | 0.79 | 0.91 |
| Recall | 0.57 | 0.95 | 0.65 |
F1 micro- and macro-scores for the best CNN Model and the Custom Vision model.
| Model | F1 Micro | F1 Macro |
|---|---|---|
| CNN Model | 0.65 | 0.60 |
| Custom Vision Model | 0.82 | 0.76 |