## 3 Materials and Methods
### Patch-Based Transformer Model
#### 3.2.1 Data Augmentation  
Initially, in the model training step, the dataset was enhanced by applying various methods for data augmentation to improve the model's robustness and lessen the chance of overfitting. The augmentation pipeline was implemented using the Keras Sequential application programming interface (API) and included the following transformations.  
Normalization, shown in Equation (2), was applied to each pixel \(\xi_{n}\) of all the channels of images to bring the mean to zero and adjust the standard deviation (\(\sigma_{n}\)) to one, as shown in Equations (3) and (4). The data supplied as an input is standardized to a consistent scale thanks to this process, which is necessary to keep the models developed using deep learning stable and performing well.  
\[\hat{x}_{n}\ =\ \frac{x_{n}-\mu_{n}}{\sigma_{n}} \tag{2}\]  
Figure 4: Purposed model’s architecture.  
Figure 3: Cherry-picked sample of synthetic images with abnormal effects, upscaled for seeing imperfections.  
\[\mu_{n}\ =\ \frac{1}{m}\sum_{i=0}^{m}x_{ni} \tag{3}\]  
\[\sigma_{n}\ =\ \sqrt{\frac{1}{m}\sum_{i=0}^{m}(x_{ni}-\mu_{n})^{2}} \tag{4}\]  
In addition to normalization, we applied a range of data augmentation techniques to enhance the performance and generalization ability of our models. Specifically, random horizontal and vertical flips were employed to alter the spatial orientation of image pixels, thereby increasing data diversity. Furthermore, random rotations were implemented using Keras data augmentation layers, with rotation angles controlled via floating-point parameters that define the maximum permissible degrees for both clockwise and counterclockwise rotation. To further diversify the training data, a random zoom effect was introduced using dedicated Keras augmentation layers, simulating variations in object scale and perspective. These augmentations collectively helped to mitigate overfitting by introducing subtle variations in the input images. By slightly modifying pixel arrangements, the model is encouraged to learn generalizable features rather than memorizing specific training examples.  
As illustrated in Figure 5, augmentations such as flipping, rotating, and zooming adjust the input images dynamically to provide a richer and more robust training dataset. While these augmentations increase input variability, normalization plays a crucial complementary role by ensuring that the range of input feature values remains consistent. This prevents disproportionately high or low input values from exerting undue influence on the learning process due to scale imbalances in model parameters.  
In the contemporary landscape of deep learning, CNNs are widely regarded as the backbone of classification models, primarily due to their extensive usage and remarkable performance across a variety of tasks [63]. CNNs have proven particularly effective in image classification, but their utility extends beyond visual data, with successful applications in domains such as audio and sound classification as well [64; 65].  
Unlike traditional deep learning models, CNNs process input data in the form of two-dimensional matrices (of size \(n\times m\)), enabling the application of convolutional filters in localized regions of the input. These filters learn spatial hierarchies of features by sliding across the input matrix, effectively capturing low- to high-level patterns. This process, illustrated in Figure 6, allows CNNs to generate rich feature representations layer by layer, making them highly suitable for tasks involving structured spatial data.  
Unlike the CNN architecture, implementing the transformer architecture for image classification requires a different approach to input processing. As described in the work by [PERSON] et al. [62], the standard image representation (a 3D matrix with height, width, and channel dimensions) must be transformed into a 2D sequence format suitable for transformer-based models [66].  
Figure 5: Input variability.