# Neural Network-Based Price Tag Data Analysis
## 4 Results  
Two metrics were chosen as performance indicators: accuracy and \(F1\)-score. The metric data calculation is represented in Equations (1)-(4). \[Accuracy=\frac{TP+TN}{TP+FP+FN+TN} \tag{1}\]  
\[Precision=\frac{TP}{TP+FP} \tag{2}\]  
\[Recall=\frac{TP}{TP+FN} \tag{3}\]  
\[F1=2\cdot\frac{Precision\cdot Recall}{Precision+Recall} \tag{4}\]  
where _TP_ is true positive results, _FP_ is false positive results, _TN_ is true negative results and _FN_ is false negative results. Accuracies achieved in the course of training are presented in Table 1. Additionally, this table presents the average time spent for each epoch. Figure 9 shows a graphs of the change in the loss function during the neural network's learning process. \begin{table}
\begin{tabular}{c c c c c c} \hline \hline  & **Dataset** & **UNet** & **MobileNetV2** & **VGG16** & **YOLOv4-Tiny** \\ \hline \multirow{2}{*}{Cross validation accuracy} & Train & 90.64\% & 82.79\% & 89.16\% & 98.24\% \\  & Validation & 92.12\% & 78.56\% & 83.72\% & 96.92\% \\ \hline \multirow{2}{*}{\(F1\) score} & Train & 0.36 & 0.34 & 0.65 & 0.62 \\  & Validation & 0.38 & 0.32 & 0.58 & 0.61 \\ \hline \multicolumn{2}{c}{Time per epoch} & Full dataset & 16.74 s & 8.97 s & 11.95 s & 2.74 s \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Neural network learning results. Figure 8: EasyOCR architecture. The results for the trained networks are shown in Figure 10.  
It is evident from Figure 9 that Unet and MobileNetV2 correctly determine the segment position, but when selecting it, they make mistakes, not highlighting parts from the required area and capturing irrelevant areas. The accuracy can be improved by using a median filter, which studies a region for each pixel, determines the most common value in that region, and replaces the pixel with that value. Figure 11 shows the use of a median filter featuring various kernel sizes. The optimal kernel size is five, as it eliminates minor segmentation defects without capturing data falling outside the segment of interest. However, even after the median filter is applied, there are still segmentation errors in the image that can prevent the segment from being properly cut out. This is due to the fact that corner coordinates are used in this procedure, which makes the segment much larger and results in the capture of unnecessary information. Based on the above facts and the results presented in Table 1, it can be concluded that YOLOv4-tiny is the most advantageous architecture. However, for the correct processing of data in the segments found, it is necessary to programmatically expand the areas obtained using the neural network. So, the Description area was increased to the width of the input image, which improved the accuracy. Additionally, since the Description area on the price tags under consideration is not surrounded by unnecessary information, this extension will not affect the subsequent character recognition in any way. Owing to this extension, the accuracy of YOLOv4-tiny can be considered close to 100%, and therefore the accuracy of the entire development will be equal to the accuracy of character recognition. During research, a pre-trained EasyOCR model was used for the character recognition. In testing, we were able to achieve high accuracy for each of the segments. The model results are given in Figure 12.  
Figure 9: Change in the loss-function: (**a**) UNet, MobileNetV2, VGG16; (**b**) YOLOv4-tiny. Figure 10: Results of trained networks: (**a**) UNet; (**b**) MobileNetV2; (**c**) VGG16; (**d**) YOLOv4-tiny. To calculate the EasyOCR accuracy, the following metrics were used: MAPE [27] for numeric segments (Equation (5)), the ratio of correctly recognized characters to the total number of characters in text segments (Equation (6)), and the ratio of recognized barcodes to the total number of barcodes (Equation (7)). The final accuracy of neural networks is calculated as the arithmetic mean between all the previously named metrics (Equation (8)).