## 2 Materials and Methods
### YOLOv4  
This study utilizes YOLOv4, an advanced version of the YOLO (You Only Look Once) object detection model, originally introduced by [PERSON] et al. [43]. YOLOv4, developed by [PERSON], represents the fourth generation and significantly improves both the speed and accuracy compared to its predecessor, YOLOv3. YOLOv4 consists of three main components, the CSP-Darknet53 backbone, SPP Block, and PANet, and the detection head. The CSP-Darknet53 integrates CSP-DenseNet to enhance the operational speed, addressing the limitations of the previous versions. Various techniques are employed to optimize its performance, the structure of YOLOv4 can be shown in Figure 3. CutMix and Mosaic are the data augmentation methods. CutMix removes objects from training images and  
Figure 2: Schematic illustration of (**a**) electrochemical data and video acquisition set-up and (**b**) H\({}_{2}\) volume measurement set-up [6]. replaces them with objects from other images, while Mosaic combines four images into one, reducing the mini-batch size [50]. DropBlock acts as a regularization technique, preventing overfitting by excluding specific regions of the feature map during training. Class Label Smoothing ensures label normalization by allowing label values to range between 0 and 1, enhancing model robustness [51]. The input for this research consists of 3755 image datasets of bubbles. Yolomark was used for labeling and annotation. The output of YOLOv4 is a weights file that records the model's ability to detect bubbles in a video or image. Bag-of-Specials (BoS) techniques in YOLOv4\({}^{\prime}\)s detector include the Mish activation function, SPP, SAM, PAN, and DioU-NMS [45]. Mish maintains a non-vanishing gradient, promoting smoother optimization, and serves as a regularizer by bounding negative outputs [52]. SPP ensures consistent output sizes regardless of varying feature map sizes, utilizing multi-filter pooling to preserve important contextual features [53]. SAM conveys spatial-wise information efficiently [54], and PANet transfers information between different levels, improving the localization accuracy [55]. DioU-NMS, the post-processing technique, uses Intersection over Union (IoU) for loss calculation, considering both the overlap and distance between predicted and actual bounding boxes. NMS is applied to remove overlapping bounding boxes, retaining only highly reliable ones [56]. These YOLOv4 components contribute to enhanced performance, efficient computation, accurate localization, and reliable post-processing, making it a powerful tool for object detection in various applications. This study utilizes this advanced model to detect bubbles on the surface of welding metal, demonstrating the effectiveness and versatility of YOLOv4 in real-world scenarios. In this study, for the bubble detection method, the multi-object-based detection strategy was applied. The dataset was taken through digital camera acquisition and a macro lens. It consists of 3755 images of bubbles, which are divided into 80% for training and 20% for testing. Figure 3(a) shows two different conditions for the same welding metal, before and after corrosion. Before corrosion, the metal surface looked relatively homogenous and there were no visible boundaries between the weld metal, heat-affected zone, and base metal. Figure 3(b) shows an example of a common polarization curve and the timestamp of the video acquisition. The video data were taken for 10 min using a digital camera (DSLR) and a macro lens with 3.2\(\times\) magnification, which produced a size of 1280 \(\times\) 720 pixels and 50 fps. Each image has a size ranging from 1 to 2 MB. The size of the image for the data training resulting from the acquisition process is 352 \(\times\) 352 pixels, with sizes ranging from 100 to 300 KB. For labeling, annotation was accomplished by using YOLOmark [57], labeling in YOLOv4 by marking objects with box-shaped delimiters and adjusting the width and height of the object. The data label format in YOLOv4 has the extension.txt.