# GAN-Based Image Dehazing for Intelligent Weld Shape Classification and Tracing Using Deep Learning
## 2 Methods
### Theoretical Background of YOLO Architecture
#### 2.3.1 YOLOv4 Architecture  
YOLOv4 DarkNet with Scaled YOLOv4 is the one of the accurate neural network models produced in recent times for single-stage object detection. Its architecture is made up of three parent blocks, namely, backbone, neck and head, as shown in Figure 5, with 334 layers. This architecture uses cross-stage partialized (CSP), in which feature maps of the base layer are partitioned into two sections and finally merged into the transition layer [34; 35]. This initiates the gradient flow through different network paths, thereby reducing the amount of computation and inference speed, as well as accuracy.  
The input image is fed into the backbone layer which is responsible for convolutional down sampling to extract the features. In this work, CSPDarknet53 is used as the backbone for object detection, which has 53 convolutional layers with high accuracy [36]. The dense block contains multiple convolution layers starting from 13 \(\times\) 13 \(\times\) 512 as the input layer \(X_{o}\) and finally 13 \(\times\) 13 \(\times\) 1024 as the output transition layer. The neck layer serves as the extra  
Figure 5: YOLOv4 architecture for weld seam detection and tracing.  
layer between the backbone and the head for in-depth prediction [37]. In Scaled YOLOv4, PAN network and modified SPP (spatial pyramid pooling) constitute the neck layer. The SPP retains the output of the spatial dimension and removes fixed size constraints. The path aggregation network (PANNet) is added for the aggregation of features and image segmentation, which preserves the spatial information present in the images [38]. Here, three anchors--[12; 16; 19; 36; 40; 28], [36; 75; 76; 55; 72; 57; 146] and [142; 110; 192; 243; 459; 401]--were used and each bounding box predicted the offset from the top corner of each image (\(c_{x}\), \(c_{y}\)), as well as \(B_{w}\) width, \(B_{h}\) height and probability (confidence) score \(c\). The governing equations for bounding boxes are as follows:  
\[\textit{Bounding Box coordinates},B_{x}=2\,\sigma(t_{x})-0.5+c_{x} \tag{10}\]  
\[B_{y}=2\sigma(t_{y})-0.5+c_{y} \tag{11}\]  
\[\textit{Bounding Box width},B_{w}=(2\sigma(t_{w}))^{2}P_{w} \tag{12}\]  
\[\textit{Bounding Box height},B_{h}=(2\sigma(t_{h}))^{2}P_{h} \tag{13}\]  
\[\sigma(t)\!\!=pr(\textit{containing object})\times IoU(\textit{predicted box},\textit{Ground truth box}) \tag{14}\]  
\[\textit{Confidence Score}=\text{ c }=\text{ pr(object)}\ast\text{IoU} \tag{15}\]  
The YOLOv4 network uses cross minibatch normalization so that it can work on any GPU. Furthermore, there are many regularisation techniques in the literature, but DropBlock regularisation was used in this work where certain parts of the image were hidden, and the network was forced to learn the other features rather than relying upon important features [39; 40]. There are two main parameters, namely, block size and \(\gamma\), which determine the number of units to be dropped. The larger the block size the more features are masked, which makes stronger regularisation. The equation for \(\gamma\) is shown below:  
\[\gamma=\frac{1-\textit{keep\_prob}}{\textit{block\_size}^{2}}\,\,\frac{\textit{ feat\_size}^{2}}{(\textit{feat\_size}-\textit{block\_size}+1)^{2}} \tag{16}\]  
where _keep_prob_ is the threshold probability value (values below this threshold will be masked) and _feat_size_ is the size of the feature map.