# Approach for Tattoo Detection and Identification Based on YOLOv5 and Similarity Distance
## 3 Background of the Experimental Investigation  
The review of related works has shown (Table 1) that various deep learning-based algorithms can be used for tattoo detection or localization tasks. In our research, the focus is on a real-time object detection task, so CNN and R-CNN methods are not entirely appropriate. When comparing real-time object detector algorithms YOLO, SSD, and RetinaNet, it should be noted that SSD has low accuracy compared to other alternatives. Furthermore, RetinaNet exhibits better accuracy compared to YOLO or SSD, but lower efficiency for real-time object detection due to its high computational cost. Although YOLOv5 continues to be a widely acclaimed real-time object detection algorithm, boasting improved accuracy over its predecessors and retaining the ability to identify even diminutive objects. So, based on related works, the YOLOv5 object detection algorithm was used in the experimental investigation for tattoo detection. The pre-trained models of YOLOv5 were used as a base [28] (Table 2).  
During the experimental investigation, all models were trained in an environment with the following specifications: Intel(R) Xeon(R) CPU E5-2630 v4 @ 2.20 GHz (20 Threads, 10 Cores). The environment had a Linux operating system with 32 GB DDR4 RAM and GPU, called Tesla P100 PCIe 12 GB.  
After the tattoo has been detected, the person's identification in the database based on similarity distance has been analyzed. In this investigation, two similarity distances were analyzed: cosine and Euclidean distances. Suppose that we have two images: the tattoo detected in image \(X=(x_{1},x_{2},\ldots,x_{N})\), and the tattoo from the database \(Y=(y_{1},y_{2},\ldots,y_{N})\), where \(N\) is the dimensionality of the vector corresponding to each datum. In this case, the Euclidean similarity distance can be calculated (1).  
\[d(X,Y)=\sqrt{\sum_{k=1}^{N}(x_{k}-y_{k})^{2}} \tag{1}\]  
The Euclidean distance is the distance between two data points in Euclidean space. In the context of data analysis, it is often used to find the dissimilarity or similarity between data. Smaller values of the Euclidean distance indicate greater similarity. The cosine similarity distance (2) is useful in the analysis of high-dimensional data, such as in the detection of pairwise similarities in images. The value of cosine similarity indicates the cosine of the angle between two vectors in a multidimensional space.  
\[d(X,Y)=1-\frac{\sum_{k=1}^{N}x_{k}y_{k}}{\sqrt{\sum_{k=1}^{N}x_{k}^{2}}\times \sqrt{\sum_{k=1}^{N}y_{k}^{2}}} \tag{2}\]  
\begin{table}
\begin{tabular}{c c c c c c c c} \hline \hline \multirow{2}{*}{**Models**} & **Image Size** & **mAPval** & **mAPval** & **Speed (ms)** & **Speed (ms)** & **Speed (ms)** & **Params (M)** & **FLOPs** \\  & **(Yixels)** & **(50–95)** & **(50)** & **CPU b1** & **V100 b1** & **V100 b32** & **Prams (M)** & **@640 (B)** \\ \hline YOLOv5n & 640 & 28.0 & 45.7 & 45 & 6.3 & 0.6 & 1.9 & 4.5 \\ \hline YOLOv5s & 640 & 37.4 & 56.8 & 98 & 6.4 & 0.9 & 7.2 & 16.5 \\ \hline YOLOv5m & 640 & 45.4 & 64.1 & 224 & 8.2 & 1.7 & 21.2 & 49.0 \\ \hline YOLOv5l & 640 & 49.0 & 67.3 & 430 & 10.1 & 2.7 & 46.5 & 109.1 \\ \hline YOLOv5x & 640 & 50.7 & 68.9 & 766 & 12.1 & 4.8 & 86.7 & 205.7 \\ \hline \hline \end{tabular}
\end{table}
Table 2: The specification of the pre-trained YOLOv5 models used [28].