# Fine-Tuned Visual Transformer Masked Autoencoder Applied for Anomaly Detection in Satellite Images
## 3 Results and Discussion
### Trained Architecture  
After training the model with the parameters described in the previous chapter, it was tested on the provided dataset. The visualization of the autoencoder working part is shown in Figure 3.  
The figure contains four pictures. The first of them presents the original image, while the second presents the masked one. The next two are outputs of the processing pipeline. The figure described as'reconstruction' contains the image reconstructed by the autoencoder. The last image presented shows a reconstructed image with patches that were visible to the autoencoder, i.e., copied from the original image. The analysis allows us to draw the following conclusion: the trained model is capable of reconstructing general shapes and homogeneous images, with higher reconstruction error, when there are more details in the image or there is a heterogeneous change within the regular environment. After the model was evaluated, a thorough analysis was performed to verify the interpretability of themodel in terms of correctly and incorrectly classified samples from the dataset. The results of the analysis are shown in Figure 4.  
Looking at Figure 4, we can see the image samples that were the subject of the final classification. The images are transformed according to random horizontal and vertical rotation flip, random rotation, and auto-contrast methods. Figure 4b shows an example of a correctly classified normal sample, while Figure 4a depicts an anomaly. We can state that the system works correctly for homogenous images without man-made objects, while Figure 4a shows some trenches of military training dug out. On the other hand, Figure 4c presents undetected signs of wildfires in the environment. Also, as shown in Figure 4d, some terrains with regular shape may be taken as anomalies by the proposed system. In terms of the reconstruction error (indicated by the value of the loss function), it can be visualized for further analysis with the histograms presented in Figure 5.  
The histograms show that the loss function values tend to be concentrated for normal samples, whereas they tend to be more distributed for anomalous images. In addition, the overall reconstruction error is lower for normal images, which confirms the hypothesis stated that known images are reconstructed in a better way than novel, unfamiliar images. Figure 3: Image reconstruction results for a single image with possible combinations. To address the problem of assessing the confidence level, we propose a formula that derives from the calculated anomaly score. The indicator is proportional to the absolute value of the difference between the anomaly score for a given sample and the threshold. In the case of the reconstruction problem, the threshold value should be set at 0.5, meaning the closer the anomaly score is to 0, the more certain model's output is when predicting normal samples. On the other hand, the closer the value is to 1, the higher the error that  
Figure 4: Examples of obtained classification output for each confusion matrix class. (**a**) Example of correctly classified anomaly sample. (**b**) Example of correctly classified normal sample. (**c**) Example of misclassified normal sample. (**d**) Example of misclassified anomaly sample. Figure 5: Loss function histograms for both classes. (**a**) Histogram of loss function value for the normal dataset. (**b**) Histogram of loss function value for the anomalous dataset. the estimator reconstructss the image with, i.e., the probability of spotting an anomaly is higher. To scale values and obtain the final range from 0 to 1, the obtained value should be multiplied by 2. The final formula for the confidence level for the task can be described with Formula (3), as follows:  
\[confidence\_level=2\cdot|(anomaly\_score-0.5)| \tag{3}\]  
Several performance indicators, i.e., accuracy, precision, recall, and F1 score, have been calculated according to Formulas (4a)-(4d). Accuracy is a quality factor that refers to the percentage of correctly classified images.