# An Improved Approach to Detection of Rice Leaf Disease with GAN-Based Data Augmentation Pipeline
## 3 Methodology and Tools
### Research Method  
The proposed GAN-based augmentation pipeline trains an SG2-ADA model using a limited dataset to generate high-quality synthetic images. The goal here is to reproduce a statistical pattern and property of the original dataset through SG2-ADA by modeling its probability distribution over the data space. After training the generative model until it reaches convergence. The GAN model generates new data with the same characteristics as the original data using a truncation factor of (\(\psi=0.25\), \(\psi=0.50\), \(\psi=0.75\), and \(\psi=1.0\)); noting that the increase in truncation helps to further diversify the generated images by shrinking the sampling region of the latent space. Part of the generated images come with some defects, such as blurriness and noise distortion which could significantly degrade the performance of the CNN models when applied [44]. As such, we applied an image processing technique to detect the amount of blurriness in the generated images, then filter and discard some of the blurry and other poorly generated images by using the variance of the Laplacian method (see Equations (1)-(5)). The method is implemented by passing a single channel of an image and convolving it with a \(3\times 3\) kernel while taking the variance of the response. If the variance is \(\leq 100\) then the image is considered blurry; otherwise, the image is not blurry. (See Figures 1 and 2). \begin{table}
\begin{tabular}{l l} \hline \hline
**Limitations of Standard Data Augmentations** & **Advantages of Standard Augmentation** \\ \hline Standard data augmentation still inherits & It reduces the cost of collecting or generating \\ biases from the original datasets. & and labeling new datasets. \\ \hline Finding an effective optimal standard data & It reduces data scarcity and overfitting whilst \\ augmentation approach can be challenging. & improving model accuracy. \\ \hline Quality assurance for standard data & Helps with resolving class imbalance and \\ augmentation is costly. & creates variability in data models. \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Limitations and advantages of the standard method. Laplacian can be given as:  
\[\
abla^{2}f=\frac{\partial^{2}f}{\partial^{2}x}+\frac{\partial^{2}f}{\partial^{2 }f} \tag{1}\]  
Partial derivative with respect to \(x\):  
\[\frac{\partial^{2}f}{\partial^{2}x}=f(x+1,y)+f(x-1,y)-2f(x,y) \tag{2}\]  
Partial derivative with respect to \(y\):  
\[\frac{\partial^{2}f}{\partial^{2}y}=f(x,y+1)+f(x,y-1)-2f(x,y) \tag{3}\]  
Combined the partial derivatives of \(x,y\). \[\
abla^{2}f=[f(x+1,y)+f(x-1,y)+f(x,y+1)+f(x,y-1)]-4f(x,y) \tag{4}\]  
Then forms a \(3\times 3\) filters for \((x,y)\) coordinates. \[ \begin{array}{ccccc}x-1,y-1&x,y-1&x+1,y-1&0&1&0\\ x-1,y&x,y&x,y+1&\to 1&-4&1\\ x-1,y+1&x,y+1&x+1,y+1&0&1&0\end{array}  \tag{5}\]  
Figure 1: Detected blurry image. Figure 2: Detected as not blurry image. Then, the filtered generated images are combined with the existing raw images. This can be represented mathematically. (See Equation (6)) shows a union of existing and generated synthetic data. \[A\cup B=\{x:x\in A\text{ \ or }x\ \in B\} \tag{6}\]  
where  
\(A=\{x,\text{ }existing\text{ }raw\text{ }data\}\)  
\(B=\{x,\text{ }generated\text{ }synthetic\text{ }data\}\)  
Lastly, the combined balanced data is passed forward to Faster-RCNN or SSD model for training using the proposed augmentation pipeline, while also applying the standard augmentation technique on faster-RCNN and SSD model, (see Figure 3). Hence, the results of the two methods are compared based on the average precision and loss metrics. The following Algorithm 1 shows a step-by-step implementation of the proposed augmentation pipeline; our method follows a simple optimization framework that involves generating synthetic images to solve the problem of a small and imbalanced dataset.