# Vision Transformer in Industrial Visual Inspection
## 4 Experiments and Results  
### Experiment Settings  
The experiments were executed with the complete resized images, as well as with crops generated by a sliding window approach, applied to the full resolution original images, as input. Due to the tall and narrow shapes of the damages in the wooden load space (WLS) use case, we chose a rectangular window shape of \(1024\times 512\), while the sheet metal and character recognition (CR) use cases utilize a square shape of \(1024\times 1024\). The crop resulting from a certain window position is only used if it contains a visible bounding box as this showed to yield the best performance. Table 2 summarizes the characteristics of the six utilized datasets. The datasets are split into training, validation, and test sets with a ratio of 80%, 10%, and 10%, respectively. We balanced the ratio of classes for WLS and CR in all sets equally so that the ratio was the same as in the original data to avoid under-representation of certain classes.  
Transfer learning is utilized by initialization with weights from models pre-trained on COCO to reduce the training time and number of required samples. We selected the Adam-W optimizer [45] due to its good performance on benchmark datasets in CV [19; 20; 46; 47; 48; 49]. To achieve better optimized weights due to smaller possible increments of adaptation, the initial learning rate of \(1\cdot 10^{-4}\) is decayed by a factor of 0.1 at epoch 40 for the DETR family models and at epoch 100 for the CNN models Supplementary the gradients of DETR and DDETR are limited to \(L_{2}\)-\(Norm\leq 0.1\) during training to prevent exploding gradients. Data augmentation is used according to the original publications' specifications [20; 22; 30; 36; 50]. This means random flipping with a probability of 50% for Retina Net and F-RCNN. DETR and DDETR utilize random flipping and random crops with resizing. For Yolo v3, a variety of photometric distortions, random crops and random flipping augment the input. Additionally, the inputs for all models are padded to a shape that makes them divisible by 32, to achieve a constant input size, which is required by all detection heads.  
Our models were implemented with MMDetection, an open source object detection toolbox [51], which offers modularity for models and train/test pipelines, as well as a wide variety of pre-trained models and utility functions. We trained all models for 150 epochs on eight Nvidia V100 GPUs with 32 GB memory, with the maximum batch size the memory allows for (details in Table 3). By doing so, we utilized the full capacity of the hardware, but lost some comparability between the models, because of the differing batch sizes. The loss of comparability can be justified by more stable training and better generalization as shown in the next chapter.  
\begin{table}
\begin{tabular}{l c c c c c} \hline \hline
**Task** & **\# Images** & **\# Annotations** & **\# Classes** & **Input Size (w, h)** & **Step Size** \\ \hline Sheet metal flooring & 192 & 394 & 1 & (3072, *) & - \\ \hline Sheet metal flooring, & & & & & \\ windowed & 219 & 223 & 1 & (1024, 1024) & 800, 800 \\ \hline Wooden load space & 156 & 255 & 3 & (3072, *) & - \\ \hline Wood load space, & & & & & \\ windowed & 746 & 957 & 3 & (512, 1024) & 400, 400 \\ \hline Characters & 200 & 21.571 & 43 & (3072, *) & - \\ \hline Characters, & & & & & \\ windowed & 1871 & 27.81 & 43 & (1024, 1024) & 800, 800 \\ \hline \hline \end{tabular}  
* corresponding height to keep aspect ratio.  
\end{table}
Table 2: Characteristics of the datasets utilized in this study.