# Promotion of Color Sorting in Industrial Systems Using a Deep Learning Algorithm
## 2 Materials and Methods
Further, manual labelling of the original training images, images augmented by rotation, and mirror effect were executed. The program LabelImg ([[https://tzutalin.github.com/heartexlabs/labelImg/](https://tzutalin.github.com/heartexlabs/labelImg/)]([https://tzutalin.github.com/heartexlabs/labelImg/](https://tzutalin.github.com/heartexlabs/labelImg/)) (accessed on 10 May 2021)) was used for this purpose because it has the capacity of image labelling and automatic saving in the format demanded by Yolo and PascalVOC [36]. The program stores an image and a text file with the coordinates of the labelled object of interest and its assigned class. A php script was created for other sets of augmented images. This script automatically copies the text file from the original training images, because coordinates of the object of interest are not known. The original training images are then used to generate the images. \begin{table}
\begin{tabular}{c c c c} \hline \hline
**Training Set** & **Compliant Raspberries** & **Noncompliant Raspberries** & **Total Raspberries** \\ \hline Number of original images & 79 & 46 & 125 \\ Brightness: +10, +20, +50, +100, 150, \(-10\) & 711 & 414 & 1125 \\ \(-20,-50,-100\) & & & \\ Gamma: 0.5, 0.7; 0.9; 1.2; 1.5; 1.7; 2.0 & 553 & 322 & 875 \\ Gaussian noise: 0.2; 0.5; 1.0; 1.5; 2.0 & 395 & 230 & 625 \\ Rotation: 90 cw, 90 ccw, 180 & 237 & 138 & 375 \\ Mirror & 158 & 92 & 250 \\ Blur: 0.2; 0.4; 0.6; 0.8; 1.0 & 395 & 230 & 625 \\ Total & & 4000 & \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Table with input data. Figure 4: Image augmentation methods: (**a**) blur; (**b**) rotation; (**c**) gamma correction; (**d**) mirror effect; (**e**) brightness level; (**f**) noise. interest are identical. Only image exposures were changed, not the object position in the image, e.g., in the case of rotation and mirror effect. The first step for initialization and technical setup was to create an account on a virtual machine and to install YOLOv3 environment. Here, YOLO implementation is based on Python programming language ([[https://github.com/ultralytics/yolov3](https://github.com/ultralytics/yolov3)]([https://github.com/ultralytics/yolov3](https://github.com/ultralytics/yolov3)) (accessed on 24 August 2021)). A virtual machine, \"Deep Learning\", was used for the needs of algorithm training, leased on the Google Cloud platform ([[https://cloud.google.com](https://cloud.google.com)]([https://cloud.google.com](https://cloud.google.com)) (accessed on 1 September 2021). A virtual machine was used instead of a classic computer system for the following reasons:  
* convolutional networks' training on computers with average graphics card is slow, and even unusable;
* virtual machine comes with preinstalled software, which shortens the environment time-alignment;  
User can configure multiple items such as: number of processors, graphics card type, disk size, preinstalled software, region of server location, etc. Configuration of the training computer used for research involves the following:  
* GPUs: 1 \(\times\) NVIDIA Tesla K80;
* CPU platform: Intel Haswell, 4 vCPUs, 15 GB memory;
* SSD hard disk. Repository on all configurations is available online at any time at the following link: [[https://github.com/IvaMark/YoloV3-Raspberry/](https://github.com/IvaMark/YoloV3-Raspberry/)]([https://github.com/IvaMark/YoloV3-Raspberry/](https://github.com/IvaMark/YoloV3-Raspberry/)) (accessed on 1 September 2020). The total of 9 trainings were executed with different hyperparameters to determine the best performances. The following hyperparameters were changed: number of epochs, batch size, and learning rate. The basic ideas and guidelines in the choice of these hyperparameters are defined by [PERSON] in his works [37; 38]. Figure 5 shows a network used by YOLOv3 and a method of calculating the coordinates. Detection on different layers solves defects of detecting small objects in the image. Upsampling layers concatenated with previous layers retains tiny characteristics that assist in detecting small objects.