# Research on Lightweight Model for Rapid Identification of Chunky Food Based on Machine Vision
## 2 Building the Dataset
### Dataset Augmentation  
Deep-learning-based object detection algorithms require a large number of images for training. When the number of image samples in the dataset is small, it often leads to problems such as model underfitting and poor robustness. Therefore, data augmentation techniques are used in this paper to increase the number of images [10].  
(1) Geometric Transformation  
Geometric transformation involves operations such as the translation, flipping, and scaling of images. The transformed images are shown in Figure 1.  
\begin{table}
\begin{tabular}{c c c c} \hline \hline
**Category** & **Manually Collected** & **Internet Collected** & **Total** \\ \hline Mashu & 532 & 210 & 742 \\ Fantuan & 496 & 156 & 652 \\ Nuomiji & 512 & 143 & 655 \\ Total & 1540 & 509 & 2049 \\ \hline \hline \end{tabular}
\end{table}
Table 1: Dataset composition.  
Figure 1: Image geometry transformation: (**a**) original image; (**b**) flipped image; (**c**) rotated image; (**d**) cropped image.  
(2) Adding Noise Noise  
Noise refers to signal interference that occurs during image acquisition or transmission, and the most common types of noise are salt and pepper noise and Gaussian noise. Since noise is randomly distributed in the image, probability density functions are often used to model noise. Gaussian noise, also known as normal noise [11], has the following mathematical model:  
\[P(Z)=\frac{1}{\sqrt{z\pi\sigma}}exp\left\{-\frac{(z-\mu)^{2}}{2\sigma^{2}}\right\} \tag{1}\]  
where z is the gray value, \(\mu\) represents the average value of z, and P(Z) is the probability density of the noise. Gaussian noise is often distributed around the mean, and as the difference between the gray value and the mean increases, the noise gradually decreases.  
Salt and pepper noise, also known as impulse noise, has strong randomness and can be expressed by Equation (2).  
\[p(z)=\begin{cases}p_{a}&z=a\\ p_{b}&z=b\\ 0&else\end{cases} \tag{2}\]  
where a and b are the gray values of salt and pepper noise. When a < b, the noise is represented by black dots, and when a > b, the noise is represented by white dots. The images after adding noise are shown below (Figure 2).  
(3) Color Transformation  
Unlike geometric transformation, color transformation changes the pixel's gray value without changing its coordinates. Common color transformations include changing brightness, changing contrast, and Gaussian blur. The transformed images are shown below (Figure 3).  
Figure 3: Image color conversion: (**a**) changing brightness image; (**b**) Gaussian blur image.  
Figure 2: Image after adding noise: (**a**) Gaussian noise; (**b**) pepper noise.  
(4) Cutout  
Cutout is a data augmentation method proposed by [PERSON] et al. in 2017 [12]. The main idea is to randomly crop a part of the image and fill the area with 0. Experimental results have shown that cutout is similar to the dropout regularization method in neural networks, which can prevent overfitting and improve the robustness of neural networks. It can also be used with other data augmentation operations to enhance the diversity of data. The images after the cutout operation are shown in Figure 4.  
After data augmentation, a total of 12,000 images were obtained and annotated for each image. The images in the training set, validation set, and test set were distributed in a ratio of 8:1:1.