## 4 Experiments
### Results and Discussion
#### 4.3.3 AnoViT Anomaly Detection  
To train the vision transformer-based encoder-decoder model (AnoViT) on the low-resolution Leather Defect detection and Classification dataset, several modifications are required. As an unsupervised learning method, only normal images are required for training. After the training and validation datasets are split in the ratio of 0.8 to 0.2, the remaining 472 non-defective leather sample images are utilised for training the model. Several configuration parameters must be adjusted for the reduced image size (from the original scripts input dimensions of 1024 \(\times\) 1024 pixels), as well as the increased number of input images, and the unavailability of validating ground truth images. Figure 16 depicts the original input image (top) and its corresponding class activation map (bottom) generated using the reconstruction error based on learned distribution of normal images. Figure 17 shows that visibly prominent defects found in the benchmark MVTec AD leather dataset [46] are identified relatively clearer. However, attributed to the fact that the 'normal' data used to train the model possess no defects and therefore no shadows, some reconstruction error is found in any abnormalities, including slight contours and shadows caused by defects such as the cut and poke defects. To better match the required radiometric output dimensions as well as patch size divisions, images are processed and exported at decreased dimensions of 512 \(\times\) 512 pixels (half the original size). Aside from the primary defect identified in box 2 of both images, it is worth noting a line at the top (shown in box 1) of many reconstructed output images caused by an error in the reconstruction process, though the line itself is not indicative of any defects in the input image. This reconstructive error is found in both datasets (seen in Figure 16a) but is more prominent in the images from the MVTec AD dataset. Figure 15: ViT-based dot product anomaly detection and localisation: randomly selected validation image (**top**) and corresponding activation map overlay with localised defective regions of interest (**bottom**). (**a**) Grain off defect; (**b**) Loose grain defect. Figure 16: Vision transformer-based encoder–decoder anomaly detection (AnoViT): randomly selected low-resolution validation image (**top**) with corresponding activation map overlay (**bottom**); Image scale in pixels. (**a**) Loose grain defect; (**b**) Folding mark defect. Figure 17: Vision transformer-based encoder–decoder anomaly detection (AnoViT): randomly selected validation image (**top**) and corresponding activation map overlay with localised defective regions of interest (**bottom**); Image scale in pixels. (**a**) Colour defect; (**b**) Cut defect image. To enhance the performance on low-resolution images, techniques like histogram equalization and contrast enhancement can be employed, improving the quality of low-resolution images before they are fed into the model. Model performance is also refined by better learning generalized features with increased data augmentation techniques such as rotation, flipping, zooming, translation, and brightness. To further improve the sensitivity and performance of the AnoViT anomaly detection method, it was found that fine-tuning the parameter constants, within their provided ranges, produced improved results. Sensitivity to certain surface or defect types is increased by manually experimenting with various combinations of hyper-parameter values. Variations in static array values (mean and std) used for image denormalization, optimizer parameters (learning rate, beta1, and beta2), and ViT-specific characteristics (patch and batch size, number of epochs, weight decay, and validation ratio) resulted in observable result improvements in certain defect types. Although experimentation with adjusted hyper-parameter values did produce better localisation results, improvements were not necessarily achieved across all categories (indistinguishable change in pinhole defects).