## 3 Materials and Methods
### Automated Detection
#### 3.3.3 Improvements  
The baseline was trained solely on simulated images, the only ones that had bounding box annotations. Despite the realness of these simulated images, there is still a domain gap between the simulated and real data distributions, as can be perceived by looking at the second and last columns of Figure 6.  
Previous work [30] tackled this issue by training a CycleGAN [7] with an added semantic consistency loss. More recently, the CycleGAN authors proposed Contrastive Unpaired Translation (CUT) [8], which outperforms CycleGAN while being faster and more lightweight, since the conversion is now unidirectional instead of bidirectional. CUT achieves this by employing contrastive learning at the patch level: a generated patch is encouraged to map to a similar point in the learned latent space as its corresponding input patch, while being further apart from other (random) patches. Similarly to what had been done in [30], we also introduced DiffAugment (Differentiable Augmentation) [41] in CUT. Hyperparameter selection was done empirically taking into account the suggestions offered in the original CycleGAN and CUT papers and, to compare both domain adaptation approaches, both models were trained for 100 epochs with an initial learning rate of \(2\times 10^{-4}\) and a batch size of 1. The images were resized to 256 \(\times\) 256 pixels by center cropping after resizing the longest edge, and DiffAugment involved color, translation and cutout transformations. For the source domain we used the 1960 images from the simulated train set and for the target domain we used 2285 images sampled from videos collected on the real assembly line. For more details on the training hyperparameters of CycleGAN please refer to [30]. With CUT, after preliminary experiments with lower values, we set the PatchNCE loss scaling hyperparameter to 5 to obtain more conservative translations. After training the Detectron2 on simulated images and fine-tuning on their domain converted versions, inspired by [37; 38], we employed pseudo labeling to be able to fine-tune the model on real unlabeled images. We focused on the work of [PERSON] et al. [9], because, besides the advantages stated in Section 3.3.1, the authors made their PyTorch code publicly available ([[https://github.com/facebookresearch/unbiased-teacher](https://github.com/facebookresearch/unbiased-teacher)]([https://github.com/facebookresearch/unbiased-teacher](https://github.com/facebookresearch/unbiased-teacher)), accessed on 8 January 2022) and it is directly built upon Detectron2. It is worth noting that in this process the labeled instances are still being used together with the pseudo labeled examples. The authors also include a confidence threshold to filter predicted bounding boxes with low confidence and prevent confirmation bias or error accumulation. In our experiments we set this threshold to 0.7 and the unsupervised loss weight to 2. In summary, the whole object detection training process can be divided into 3 phases, as depicted at the bottom of Figure 3: training on labeled simulated images, fine-tuning on their domain adapted versions, and fine-tuning on the latter together with pseudo labeled real images. For all phases we resized the images to 640 \(\times\) 360 pixels, used a learning rate of 0.01, a batch size of 4 (In the pseudo labeling stage, each batch included 4 labeled simulated images and 4 pseudo labeled real images. ), a confidence threshold on the Detectron2's predictions of 0.5 and 0.1 for the Non-Maximum Suppression (NMS) threshold. Similarly to what had been proposed in [30], global NMS was applied in every experiment to reduce the number of bounding boxes in the same location, keeping only the most confident ones. Training was conducted for 58.8k, 29.4k and 20k iterations for each phase, respectively. All developed code was implemented in Python 3.8, more specifically in PyTorch [42].