# Neural Network-Based Price Tag Data Analysis
## 3 Materials and Methods  
To achieve results in the analysis of information on the price tag, it is necessary to divide image processing into the following stages:  
* Segmenting images to highlight areas containing data of interest;
* Selecting segment coordinates;
* Cutting the segments out in accordance with the obtained coordinates;
* Applying Optical Character Recognition (OCR) to the selected areas;
* Searching for necessary information (quantity of products) within the product description. The hardware and software used in this study:  
* LabelImg graphical image annotation tool;
* Server CPU: Intel(r) Xeon(r) E7-4809 v4;
* Server OS: Ubuntu Server. A dataset consisting of \"Lenta\" retail chain price tag photographs was collected for the neural networks to be trained on. It consists of 80 photos of tags and 80 text files containing label coordinates (for YOLOv4-tiny); every image has a size of 512 \(\times\) 512 pixels. For UNet, MobileNet and VGG16, the same photos were used along with the masks of segments. The training and validation parts of the dataset were split randomly at a ratio of 3:1. To train neural networks, each image was labeled with the following segments:  
* Description, which is a product name and description;
* Barcode, which is an EAN-13 product barcode;
* Rub, which is a product price in rules;
* Kop, which is a product price in kopecks;
* Rub_card, which is a product price in rules, including a discount for \"Lenta\" card holders;
* Kop_card, which is a product price in kopecks, including a discount for \"Lenta\" card holders. Example of labeling is shown in Figure 1.  
The differences between the Russian price tags and the price tags in other countries are insignificant, because in many countries the price tags have a similar structure and each price tag has segments with a description of the product, a barcode and a price. Differences can be found in the location of the segments and in the number of segments with a price, for example, the price with a discount card and the price before and after the discount. Figure 2 shows an example of the markup of a similarly structured price tag for the Walmart chain of stores. The Description and Barcode segments are present and differ only in location, while the Dol and Cents segments are analogous to the Rub and Kop segments, respectively. Figure 1: Example of labeling. There are many different architectures available to carry out the segmentation. In our research, we have chosen the following models: Unet, MobileNetV2, VGG16 and YOLOv4-tiny. The EasyOCR API was chosen for text recognition. Each of the selected models was trained featuring the following parameters:  
* UNet: loss function--cross entropy; optimizer--Adam algorithm with learning rate lr = 0.0001; batch size--5; number of iterations per epoch--12. * MobileNetV2: loss function--cross entropy; optimizer--Adam algorithm with learning rate lr = 0.0001; batch size--5; number of iterations per epoch--12. * VGG16: loss function--mean squared error (MSE); Optimizer--Adagrad; batch size--5; number of iterations per epoch--12. * YOLOv4-tiny: loss function--complete intersection over Union (CIoU); optimizer--stochastic gradient descent (SGD); batch size--64; number of iterations per epoch--24. Since the loss functions of the Unet, MobileNetV2 and VGG16 architectures are characterized by a large gradient step, they were trained over 50 epochs. YOLOv4-tiny was trained on 1000 epochs, due to the small gradient step. Since the training of neural networks is time-consuming and for UNet, MobileNetV2 and VGG16 networks it is necessary to highlight each segment on a separate image, these networks were trained on the product description segment only, since this segment is unstable and features the largest size. An example of the product description segment layout is shown in Figure 3.  
The UNet model architecture is a set of 19 convolutional layers using bottleneck and sliding windows [17; 18]. This network has proven to be a reliable and high-quality image segmentation solution.