Tattoo classification and identification method and device, equipment and medium
By performing type annotation and feature extraction on skin image data, combined with MobileNet and VIT models for tattoo probability assessment and detailed identification, the problem of low accuracy of tattoo image recognition is solved, and more efficient and accurate tattoo classification is achieved.
Patent Information
- Application Number
- CN202510333747.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-20
- Publication Date
- 2025-07-29
AI Technical Summary
In the prior art, the recognition accuracy of tattoo images is low, and is affected by factors such as shooting angle, lighting conditions, image resolution and background interference. In addition, deep learning models are prone to ignore rare tattoo types during training, resulting in inaccurate classification recognition.
By obtaining various types of skin image data for type annotation, extracting skin appearance features, using point-by-point convolution and depth convolution to calculate tattoo probability, and combining tattoo classification tags for feature recognition, using MobileNet and VIT models for initial screening and detailed identification to improve recognition accuracy.
It effectively improves the accuracy of tattoo classification recognition, enhances the adaptability and robustness of the model to image quality changes, reduces the demand for computing resources, and improves the recognition efficiency and accuracy.
Smart Images

Figure CN120388204A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image recognition, and particularly to a method, device, equipment and medium for tattoo classification and recognition. Background Art
[0002] In the existing technologies, the quality of tattoo images is affected by many factors, including shooting angle, lighting conditions, changes in human body postures, image resolution, and interference from the background, etc. The changes in these factors result in significant differences in the performance of tattoo images in different environments, thereby increasing the recognition difficulty of deep learning models. Tattoo images usually have relatively complex backgrounds, and objects, light and shadow changes, etc. in the background may all interfere with the recognition of the model, thus affecting the accuracy. In addition, deep learning models rely on a large amount of labeled data during training. However, in many actual application scenarios, especially in the financial business field, the samples of tattoo images are relatively scarce, and there may be a large class imbalance problem for different types of tattoos, resulting in the model being more inclined to recognize the categories with higher frequencies during training, while ignoring the relatively rare tattoo types, ultimately affecting the accuracy of tattoo classification and recognition.
[0003] Currently, the existing technologies have the problem of relatively low accuracy in tattoo classification and recognition. Summary of the Invention
[0004] The present invention provides a method, device, equipment and medium for tattoo classification and recognition, and its main purpose is to solve the problem of relatively low accuracy in tattoo classification and recognition.
[0005] In a first aspect, to achieve the above object, the method for tattoo classification and recognition provided by the present invention includes:
[0006] Obtain various types of skin image data, perform type annotation on the skin image data to obtain skin type images;
[0007] Obtain a number of skin images to be recognized, and determine the skin appearance features of the skin images to be recognized according to the skin type images;
[0008] Select a feature extraction algorithm for the skin images to be recognized according to the skin appearance features;
[0009] Perform point-by-point convolution and depth convolution on the skin images to be recognized according to the selected feature extraction algorithm to obtain the tattoo probability of each skin image to be recognized;
[0010] If the tattoo probability is less than or equal to a preset probability threshold, then obtain a judgment result that the skin type of the skin image to be recognized with the tattoo probability less than or equal to the probability threshold is not a tattoo;
[0011] If the tattoo probability is greater than the probability threshold, convert the skin image to be recognized with a probability greater than the probability threshold into a skin sequence to be recognized;
[0012] Obtain a tattoo classification label, and use the tattoo classification label to perform feature recognition on the skin sequence to be recognized to obtain a tattoo classification result.
[0013] In a second aspect, the present invention further provides a tattoo classification and recognition device, and the device includes:
[0014] An image annotation module, configured to obtain skin image data of multiple types, perform type annotation on the skin image data to obtain a skin type image;
[0015] A feature determination module, configured to obtain a plurality of skin images to be recognized, and determine the skin appearance features of the skin images to be recognized according to the skin type image;
[0016] An algorithm selection module, configured to select a feature extraction algorithm for the skin image to be recognized according to the skin appearance features;
[0017] An image convolution module, configured to perform point-by-point convolution and depth convolution on the skin image to be recognized according to the selected feature extraction algorithm to obtain the tattoo probability of each skin image to be recognized;
[0018] A first judgment result execution module, configured to, if the tattoo probability is less than or equal to a preset probability threshold, obtain that the skin type of the skin image to be recognized with a judgment result that the tattoo probability is less than or equal to the probability threshold is not a tattoo;
[0019] A second judgment result execution module, configured to, if the tattoo probability is greater than the probability threshold, convert the skin image to be recognized with a probability greater than the probability threshold into a skin sequence to be recognized;
[0020] A classification and recognition module, configured to obtain a tattoo classification label, and use the tattoo classification label to perform feature recognition on the skin sequence to be recognized to obtain a tattoo classification result.
[0021] In a third aspect, the present invention further provides an electronic device, and the electronic device includes:
[0022] At least one processor; and,
[0023] A memory communicatively connected to the at least one processor; wherein,
[0024] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the above-mentioned tattoo classification and recognition method.
[0025] In a fourth aspect, the present invention further provides a computer-readable storage medium storing at least one computer program, and the at least one computer program is executed by a processor in an electronic device to implement the tattoo classification and recognition method described above.
[0026] The present invention obtains various types of skin image data, performs type annotation on the skin image data to obtain skin type images, obtains a plurality of skin images to be recognized, determines the skin appearance features of the skin images to be recognized according to the skin type images, selects a feature extraction algorithm for the skin images to be recognized according to the skin appearance features, performs point-by-point convolution and depth convolution on the skin images to be recognized according to the selected feature extraction algorithm to obtain the tattoo probability of each skin image to be recognized. If the tattoo probability is less than or equal to a preset probability threshold, it is determined that the skin type of the skin image to be recognized with the tattoo probability less than or equal to the probability threshold is not a tattoo. If the tattoo probability is greater than the probability threshold, the skin image to be recognized with the tattoo probability greater than the probability threshold is converted into a skin image sequence to be recognized, a tattoo classification label is obtained, and the tattoo classification label is used to perform feature recognition on the skin image sequence to be recognized to obtain a tattoo classification result, effectively improving the accuracy of tattoo classification and recognition. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments of the present invention will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present invention, and those of ordinary skill in the art can also obtain other drawings based on these drawings without creative efforts.
[0028] Figure 1 It is a schematic flowchart of a tattoo classification and recognition method provided by an embodiment of the present invention;
[0029] Figure 2 It is a schematic block diagram of a tattoo classification and recognition device provided by an embodiment of the present invention;
[0030] Figure 3 It is a schematic structural diagram of an electronic device for implementing a tattoo classification and recognition method provided by an embodiment of the present invention;
[0031] Figure 4 It is another schematic structural diagram of an electronic device for implementing a tattoo classification and recognition method provided by an embodiment of the present invention.
[0032] The implementation, functional features and advantages of the objectives of the present invention will be further described with reference to the embodiments and the accompanying drawings. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0033] In order to enable those skilled in the art to better understand the technical solutions of the present disclosure, and to fully understand how the present disclosure uses technical means to solve technical problems and the implementation process of achieving corresponding technical effects and to implement accordingly, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only a part of the embodiments of the present disclosure, rather than all the embodiments. The embodiments of the present disclosure and each feature in the embodiments can be combined with each other on the premise of not conflicting, and the formed technical solutions are all within the protection scope of the present disclosure. Based on the embodiments in the present disclosure, all other embodiments obtained by those of ordinary skill in the art without making creative efforts shall fall within the protection scope of the present disclosure.
[0034] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and do not have to be used to describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, apparatus, product or device comprising a series of steps or units does not have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0035] The embodiment of the present application provides a tattoo classification and recognition method. The execution subject of the tattoo classification and recognition method includes, but is not limited to, at least one of electronic devices such as a server, a terminal, etc. that can be configured to execute the device provided in the embodiment of the present application. In other words, the tattoo classification and recognition method can be executed by software or hardware installed on a terminal device or a server device. The server includes, but is not limited to: a single server, a server cluster, a cloud server, or a cloud server cluster, etc. The server can be an independent server or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, Content Delivery Network (CDN), and big data and artificial intelligence platforms.
[0036] Refer to Figure 1 As shown, it is a schematic flowchart of a tattoo classification and recognition method provided by an embodiment of the present invention. In this embodiment, the tattoo classification and recognition method includes:
[0037] S1. Obtain skin image data of multiple types, perform type annotation on the skin image data, and obtain skin type images.
[0038] In the embodiments of the present invention, skin image data is collected through, for example, publicly available skin data sets, medical imaging libraries, skin disease databases, or through actual collection. The skin image data of multiple types includes: image data of tattoos, scars, and normal skin. Type annotation of tattoos, scars, and mixed features is performed on the skin image data to obtain skin type images with detailed annotations.
[0039] Specifically, the performing type annotation on the skin image data to obtain skin type images includes:
[0040] Convert the skin image data into a skin grayscale image;
[0041] Perform Gaussian smoothing on the skin grayscale image to obtain a smoothed grayscale image;
[0042] Calculate the horizontal gradient and vertical gradient of each pixel point in the smoothed grayscale image;
[0043] Calculate the gradient magnitude and gradient direction using the horizontal gradient and the vertical gradient;
[0044] Judging one by one along the gradient direction whether the gradient magnitude of each pixel point in the smoothed grayscale image is greater than a preset first threshold;
[0045] If the gradient magnitude of the pixel point is greater than the preset first threshold, then use the pixel point with the gradient magnitude greater than the first threshold as a strong edge;
[0046] If the gradient magnitude of the pixel point is less than or equal to the first threshold, then judge whether the gradient magnitude is less than a preset second threshold;
[0047] If the gradient magnitude is less than the second threshold, then delete the pixel point with the gradient magnitude less than the second threshold;
[0048] If the gradient magnitude is greater than or equal to the second threshold, then judge whether the adjacent pixel points of the pixel point with the gradient magnitude greater than or equal to the second threshold are the strong edges;
[0049] If the adjacent pixel points are not the strong edges, then delete the pixel point with the gradient magnitude greater than or equal to the second threshold;
[0050] If the adjacent pixel points are the strong edges, then use the pixel point with the gradient magnitude greater than or equal to the second threshold as a weak edge;
[0051] Perform an OR operation on the strong edges and the weak edges to obtain skin feature edges;
[0052] Obtain annotation rules and skin type labels, and use the annotation rules and the skin type labels to identify and mark the skin feature edges to obtain a skin type image.
[0053] Specifically, convert the skin image data into a skin grayscale image. The calculation formula is as follows: Gray = 0.2989×R + 0.5870×G + 0.1140×B, where R, G, and B respectively represent the pixel values of the red, green, and blue channels in the skin image data. Replace the original pixel values in the skin image data with the calculated grayscale values to obtain a skin grayscale image, which retains the brightness information of the image.
[0054] Specifically, performing Gaussian smoothing on the skin grayscale image to obtain a smoothed grayscale image includes:
[0055] Randomly select a pixel point in the skin grayscale image as the first target pixel point;
[0056] Take the adjacent pixel points of the first target pixel point as the second target pixel points;
[0057] Use a preset Gaussian filter to perform weighted averaging on the pixel values of the first target pixel point and the second target pixel points to obtain updated pixel values;
[0058] Generate a smoothed grayscale image using the updated pixel values.
[0059] Specifically, a Gaussian filter is a filter based on the Gaussian function (normal distribution function), which assigns weights to the pixel values in the skin grayscale image. The calculation formula is as follows:
[0060]
[0061] Among them, σ represents the standard deviation of the pixel values in the skin grayscale image, and (p, q) represents the pixel points in the skin grayscale image. Calculate the weights of each pixel point in the skin grayscale image according to the above formula, and perform weighted averaging on the pixel values of the first target pixel point and the second target pixel points to obtain updated pixel values. The calculation formula is as follows:
[0062]
[0063] Among them, I(p, q) represents the second target pixel point, D(p, q) represents the Gaussian weight, and I′ represents the updated pixel value.
[0064] Specifically, calculate the horizontal gradient and vertical gradient of each pixel point in the smoothed grayscale image. The calculation formula is as follows:
[0065]
[0066] Among them, A m represents the horizontal gradient, and A n represents the vertical gradient, S m represents the gradient operator in the horizontal direction, and S n represents the gradient operator in the vertical direction, and I(i,j) represents each pixel point in the smoothed grayscale image.
[0067] Specifically, the gradient magnitude and gradient direction are calculated using the horizontal gradient and the vertical gradient, and the calculation formula is as follows:
[0068]
[0069] θ = arctan2(A n , A m )
[0070] Among them, A m represents the horizontal gradient, A n represents the vertical gradient, A represents the gradient magnitude, and θ represents the gradient direction.
[0071] Specifically, the annotation rules are used to define how to distinguish different skin type labels, including: texture in the image, skin tone, etc. Skin type labels include: normal skin (such as healthy skin without any lesions), tattoos (tattoo patterns on the skin), scars (scars after skin injury), and mixed features, etc. For example, if the edge of the skin feature has no obvious texture and the skin tone is normal, it is marked as normal skin; if the edge of the skin feature shows obvious texture and the skin tone is normal, it is marked as suspected tattoo, etc.
[0072] The edge features in the skin image are effectively extracted through Gaussian smoothing and gradient detection methods, which helps to accurately identify and annotate skin types. Gaussian smoothing reduces the noise in the image and retains the important structural features in the image. By calculating the gradient magnitude and direction of each pixel point, the strong edges and weak edges in the image can be accurately identified, which helps to more carefully depict the details and texture of the skin. By stitching these edge features and combining the annotation rules of skin types, a skin type image with high precision and high interpretability can be generated, providing a reliable basis for subsequent skin analysis and classification.
[0073] S2. Obtain a plurality of skin images to be recognized, and determine the skin appearance features of the skin images to be recognized according to the skin type image.
[0074] In an embodiment of the present invention, the similarity between the image to be recognized and the known skin type image is calculated by a similarity measurement method based on cosine similarity, and the skin appearance features of the skin image to be recognized are determined according to the similarity.
[0075] Specifically, determining the skin appearance features of the skin image to be recognized according to the skin type image includes:
[0076] Converting the skin type image into a skin type image vector;
[0077] Converting the skin image to be recognized into a skin image vector to be recognized;
[0078] Multiplying the skin type image vector and the skin image vector to be recognized to obtain a first product result;
[0079] Calculating the norms of the skin type image vector and the skin image vector to be recognized respectively to obtain a first norm result and a second norm result;
[0080] Multiplying the first norm result and the second norm result to obtain a second product result;
[0081] Dividing the first product result by the second product result to obtain the skin type similarity;
[0082] Selecting the skin type images corresponding to the skin type similarity greater than a preset similarity threshold;
[0083] Generating the skin appearance features of the skin image to be recognized corresponding to the selected skin type images according to the selected skin type images.
[0084] Specifically, the similarity between the skin image to be recognized and the known skin type image is calculated by a similarity measurement method based on cosine similarity, and the calculation formula is as follows:
[0085]
[0086] Where x represents the skin image to be recognized and u represents the skin type image.
[0087] Select the skin type images with the skin type similarity greater than the preset similarity threshold, generate the appearance features of the skin type corresponding to the skin type images according to the annotation rules of the skin type images, and obtain the skin appearance features of the skin image to be recognized similar to the skin type images. Among them, the annotation rule is the annotation rule in step S1. For example, if there is no obvious texture at the edge of the skin feature and the skin tone is normal, it is marked as normal skin; if there is obvious texture at the edge of the skin feature and the skin tone is normal, it is marked as suspected tattoo, etc.
[0088] By converting the image into a vector and calculating the similarity, the appearance features of known skin types similar to the skin image to be recognized can be screened out, providing data support for subsequent selection of feature extraction algorithms based on the appearance features, helping to accurately analyze the tattoo type subsequently and improving the recognition efficiency.
[0089] S3. Select the feature extraction algorithm for the skin image to be recognized according to the skin appearance features.
[0090] In the embodiment of the present invention, the skin appearance feature refers to whether there are obvious textures in the skin image to be recognized, and the corresponding feature extraction algorithm is selected according to different skin appearance features.
[0091] Specifically, the selecting the feature extraction algorithm for the skin image to be recognized according to the skin appearance features includes:
[0092] If the skin appearance feature is no obvious texture, the feature extraction algorithm for the skin image to be recognized with no obvious texture is selected as the local binary pattern extraction algorithm;
[0093] If the skin appearance feature is obvious texture, the feature extraction algorithm for the skin image to be recognized with obvious texture is selected as the gray level co-occurrence matrix extraction algorithm.
[0094] Specifically, if there are no obvious textures or details on the skin surface, the local binary pattern (LBP) algorithm is suitable for extracting local features of the image. LBP can extract tiny texture changes from local regions of the image and can capture subtle differences in the skin.
[0095] If there are obvious textures (such as wrinkles, pores, etc.) on the skin surface, the gray level co-occurrence matrix (GLCM) algorithm can effectively extract spatial texture information from the texture-rich image, including texture features such as contrast, energy, and uniformity.
[0096] In the case where there are no obvious textures on the skin surface, the local binary pattern extraction algorithm can extract useful texture information through simple binarization operations, avoiding complex calculations. In skin images with complex textures, the gray level co-occurrence matrix extraction algorithm can provide richer and more accurate texture information, helping to better distinguish different skin features. By selecting different algorithms according to the skin surface features, key information helpful for skin type recognition can be better extracted, contributing to improving the subsequent classification or recognition effect.
[0097] S4. Perform point-by-point convolution and depth convolution on the skin image to be recognized according to the selected feature extraction algorithm to obtain the tattoo probability of each skin image to be recognized.
[0098] In an embodiment of the present invention, by using the initial screening model of MobileNet, it is determined whether there is a tattoo image or a suspected tattoo / scar image in the skin image to be recognized, and the skin image to be recognized is binary-classified to obtain the tattoo probability of each skin image to be recognized.
[0099] Specifically, the step of performing pointwise convolution and depth convolution on the skin image to be recognized according to the selected feature extraction algorithm to obtain the tattoo probability of each skin image to be recognized includes:
[0100] Generating an appearance feature label by using the skin appearance features;
[0101] Performing feature extraction on the skin image to be recognized according to the selected feature extraction algorithm to obtain the texture features of each skin image to be recognized;
[0102] Generating a prediction label of the texture features by using a preset initial screening model;
[0103] Generating a binary cross-entropy loss function by using the appearance feature label and the prediction label;
[0104] Minimizing the binary cross-entropy loss function to obtain a minimum loss function;
[0105] Optimizing the preset initial screening model by using the minimum loss function to obtain a first screening model;
[0106] Adjusting the skin image to be recognized by using a preset resolution factor to obtain an updated skin image;
[0107] Generating a first convolution kernel by using a preset depth convolution kernel and a preset width factor;
[0108] Obtaining a first stride, and using the first screening model to perform weighted averaging on each pixel value in the updated skin image one by one according to the first stride and the first convolution kernel to obtain a plurality of convolution pixel values;
[0109] Generating a first convolution image by using the convolution pixel values;
[0110] Performing weighted combination on the first convolution image and a preset pointwise convolution kernel to obtain the tattoo probability of each first convolution image.
[0111] Specifically, skin types include: normal skin (such as healthy skin without any lesions), tattoos (tattoo patterns on the skin), scars (scars after skin injury), and mixed features, etc. Each skin type image is labeled according to the skin type.
[0112] Specifically, feature extraction is performed on the skin image to be recognized according to the selected feature extraction algorithm to obtain the texture features of each skin image to be recognized. Among them, for the skin image to be recognized without obvious texture, the local binary pattern extraction algorithm is selected. The specific steps are as follows: The skin image to be recognized is grayscaled, the grayscaled skin image to be recognized is divided into several regions, and for each pixel in each small window, this pixel is selected as the center point, and the surrounding 8 neighboring pixels are used to generate a binary pattern. According to the comparison between the gray value of each neighboring pixel and the gray value of the central pixel, an 8-bit binary value is generated. If the gray value of the neighboring pixel is greater than or equal to the gray value of the central pixel, the position is 1, otherwise it is 0. The generated binary number is converted into a decimal number, and this decimal number represents the LBP value of this small region. The frequencies of all LBP values are counted to generate a histogram of LBP features. This histogram represents the texture features of the skin image to be recognized.
[0113] For the skin image to be recognized with obvious texture, the gray-level co-occurrence matrix extraction algorithm is selected. The specific steps are as follows: The skin image to be recognized is grayscaled, the direction and distance between each pixel in the grayscaled skin image to be recognized are defined, and by statistically counting the co-occurrence frequency of gray value pairs in the image at the specified distance and direction, a gray-level co-occurrence matrix is constructed. The texture features of the skin image to be recognized calculated through the gray-level co-occurrence matrix include: contrast, homogeneity, etc.
[0114] Specifically, the binary cross-entropy loss function is generated using the appearance feature label and the prediction label. The calculation formula is as follows:
[0115]
[0116] where y represents the appearance feature label, represents the prediction label.
[0117] Specifically, minimizing the binary cross-entropy loss function to obtain the minimum loss function includes:
[0118] Calculating the first gradient using the appearance feature label and the prediction label;
[0119] Obtaining the parameter weights of the preset preliminary screening model, and calculating the second gradient of the parameter weights using the first gradient and the prediction label;
[0120] Generating the final gradient of the binary cross-entropy loss function according to the second gradient;
[0121] Iterating the final gradient using the preset learning rate to obtain the minimum weight;
[0122] Adjust the binary cross-entropy loss function using the minimum weight to obtain the minimum loss function.
[0123] Minimize the binary cross-entropy loss function in detail to obtain the minimum loss function. The calculation formula is as follows:
[0124]
[0125] where y represents the appearance feature label, represents the predicted label, represents the first gradient.
[0126]
[0127] where, represents the first gradient, represents the predicted label, L represents the binary cross-entropy loss function, w represents the parameter weight of the preset initial screening model, represents the second gradient.
[0128]
[0129] where y represents the appearance feature label, represents the predicted label, L represents the binary cross-entropy loss function, w represents the parameter weight of the preset initial screening model, and x represents the skin image to be recognized.
[0130]
[0131] where w represents the parameter weight of the preset initial screening model, represents the second gradient, and η represents the preset learning rate. By iteratively updating the parameter weight multiple times, the binary cross-entropy loss function gradually decreases until convergence, and the minimum loss function is generated according to the parameter weight at convergence.
[0132] Specifically, the image size usually input by MobileNet is 224x224 or 299x299. Adjust the collected skin image to be recognized to a consistent size, and adjust the skin image to be recognized using the preset resolution factor to obtain the updated skin image. The calculation formula is as follows:
[0133] p2 = βp1
[0134] q2 = βq1
[0135] where (p1, q1) represents the pixel point of the skin image to be recognized, β represents the preset resolution factor, and (p2, q2) represents the pixel point of the updated skin image.
[0136] Specifically, assume that the size of the depth convolution kernel is 3*3*3 and the width factor is 2. Then the generated first convolution kernel is a 3*3*6 convolution kernel. The width factor scales the scale of the network by adjusting the number of convolution kernels in each layer of the network. The width factor is usually set as a floating value between 0 and 1, which determines the number of channels used in the convolution operation. For example, if the width factor is 0.5, the number of channels in each layer of the network will be reduced by half; if the width factor is 1, the number of channels in the network remains unchanged.
[0137] Specifically, the size of the first convolution kernel is M*N, each pixel point in the updated skin image is updated to (p2, q2), the weight of the first convolution kernel is K(m1, n1), and each pixel value in the updated skin image is weighted and averaged with the first convolution kernel one by one according to the first stride by using the first screening model, to obtain a number of convolution pixel values. The calculation formula is as follows:
[0138]
[0139] Wherein, M and N represent the size of the first convolution kernel, (p2, q2) represents each pixel point in the updated skin image, K(m1, n1) represents the weight of the first convolution kernel, and Q represents the area in the updated skin image. The calculated convolution result is filled into the corresponding pixel point to generate a new first convolution image.
[0140] Specifically, the first convolution image and a preset pointwise convolution kernel are weighted and combined. The calculation formula is as follows:
[0141]
[0142] Wherein, M T and N T represent the size of the preset pointwise convolution kernel, (p3, q3) represents each pixel point in the first convolution image, K T (m2, n2) represents the weight of the preset pointwise convolution kernel, and F represents the area in the first convolution image. The calculated convolution result is further normalized to the range of 0 to 1 through an activation function to obtain the tattoo probability of each first convolution image.
[0143] Through multi-level convolution and deep learning model optimization, accurate recognition of skin images has been achieved, especially the detection and probability assessment of tattoos. Using skin type images to generate labels, combining with a preliminary screening model to predict skin image labels, and optimizing model parameters by minimizing the binary cross-entropy loss function, thereby improving the recognition accuracy. Through normalization and resolution factor adjustment, the images remain consistent at different resolutions, enhancing the model's adaptability to image quality changes. The combination of pointwise convolution and depth convolution further improves the prediction accuracy of tattoo probability. Through multi-level optimization and refinement, not only the recognition accuracy is improved, but also the robustness and universality of the model are enhanced.
[0144] S5. Determine whether the tattoo probability is less than or equal to a preset probability threshold.
[0145] In an embodiment of the present invention, the tattoo probability of each skin image to be recognized is compared with a preset probability threshold. If the tattoo probability is less than or equal to the preset probability threshold, it is obtained that the skin type of the skin image to be recognized with the judgment result that the tattoo probability is less than or equal to the probability threshold is not a tattoo.
[0146] If the tattoo probability is greater than the probability threshold, execute S6. Convert the skin image to be recognized with a probability greater than the probability threshold into a skin sequence to be recognized.
[0147] In an embodiment of the present invention, the VIT model is used to perform further detailed recognition on the skin image to be recognized with a tattoo probability greater than the probability threshold, obtaining more accurate skin features, so as to reduce the computational resource requirements and improve the recognition efficiency and accuracy.
[0148] Specifically, the conversion of the skin image to be recognized with a probability greater than the probability threshold into a skin sequence to be recognized includes:
[0149] Slice the first convolutional image according to a preset block size to obtain a number of convolutional blocks;
[0150] Convert each convolutional block into a one-dimensional vector through a linear mapping;
[0151] Obtain the position encoding of each convolutional block, and add the position encoding to the one-dimensional vector corresponding to each convolutional block to obtain the skin sequence to be recognized.
[0152] Specifically, each convolutional block is mapped to a fixed vector dimension (e.g., 768 dimensions) through a linear projection layer, which determines the feature space processed in the subsequent Transformer model. Through positional encoding, positional information is attached to each one-dimensional vector to ensure that the model can understand the positional relationship between convolutional blocks. The one-dimensional vectors after linear mapping and the positional encoding are combined to obtain a long vector sequence. The long vector sequence constitutes the input sequence of the VIT model, that is, the skin sequence to be recognized.
[0153] By slicing the image into smaller convolutional blocks and generating one-dimensional vectors, the VIT model can effectively capture local features, thus avoiding the limitations of feature expression that may occur in traditional convolutional neural networks. By adding positional encoding, the model can retain the spatial information of each convolutional block, enabling the VIT to efficiently process complex tattoo details, extract accurate skin features, which helps to provide more accurate results in tasks such as tattoo detection and skin lesion recognition. Especially when dealing with images with subtle differences, it can improve the robustness and accuracy of tattoo classification and recognition.
[0154] S7. Obtain the tattoo classification label, and use the tattoo classification label to perform feature recognition on the skin sequence to be recognized to obtain the tattoo classification result.
[0155] In the embodiment of the present invention, the tattoo classification labels include: Beauty: for covering scars; General Aesthetics: common artistic / cultural / fashion tattoos; Violence / Extreme: with bloody, extreme symbols or gang signs, etc.; Other custom labels (such as religious symbols, personal commemorations, etc.).
[0156] Specifically, the step of using the tattoo classification label to perform feature recognition on the skin sequence to be recognized to obtain the tattoo classification result includes:
[0157] Add the tattoo classification label to the skin sequence to be recognized to obtain an updated skin sequence;
[0158] Capture the relationship between each vector in the updated skin sequence to obtain the correlation between each vector;
[0159] Fully connect the updated skin sequence according to the correlation to obtain a number of tattoo classification output values;
[0160] Use a preset activation function to optimize the tattoo classification output values to obtain the tattoo classification probability of each updated skin sequence;
[0161] Generate the tattoo classification result of each updated skin sequence according to the tattoo classification probability.
[0162] Specifically, the tattoo classification labels and the skin sequence to be recognized are concatenated in sequence to form a new updated skin sequence. The relationship between each vector in the updated skin sequence is captured through the multi-head self-attention mechanism to obtain the correlation between each vector.
[0163] Specifically, the VIT model includes a multi-layer perceptron module, which is usually composed of a fully connected layer, an activation function, and another fully connected layer. The multi-layer perceptron module is responsible for further processing the updated skin sequence to output a vector with the same number of categories (each dimension corresponds to the probability distribution of a category).
[0164] Specifically, the activation function is the Softmax function, and the calculation formula is as follows:
[0165]
[0166] where z a represents the output value of the a-th tattoo classification, z b represents the b-th tattoo classification category, and k represents the number of tattoo classification output values.
[0167] The output value of the tattoo classification is converted into the tattoo classification probability of each updated skin sequence through the Softmax activation function, and the features corresponding to the tattoo classification are obtained according to the probability of the tattoo classification, and finally the skin features are obtained.
[0168] Using the tattoo classification labels to perform feature recognition on the skin sequence to be recognized can effectively improve the accuracy and reliability of skin feature recognition. By combining the tattoo classification labels with the updated skin sequence, the system can more accurately capture the relationship between each vector, so as to better understand the correlation of skin features. The fully connected operation and activation function optimization further improve the efficiency and accuracy of the recognition process. The finally generated tattoo classification probability can provide clearer and more detailed information for subsequent skin feature analysis, which helps to achieve more efficient skin feature recognition and tattoo classification.
[0169] It should be understood that the magnitudes of the sequence numbers of the steps in the above embodiments do not mean the order of execution. The order of execution of each process should be determined according to its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.
[0170] As Figure 2 shown, it is a functional module diagram of a tattoo classification and recognition device provided by an embodiment of the present invention.
[0171] In the embodiments of the present disclosure, a tattoo classification and recognition device is provided. This tattoo classification and recognition device corresponds one-to-one with the above-mentioned tattoo classification and recognition method in the embodiment. As Figure 2As shown in the figure, the tattoo classification and recognition device 100 can be installed in an electronic device. According to the functions implemented, the tattoo classification and recognition device 100 includes an image annotation module 101, a feature determination module 102, an algorithm selection module 103, an image convolution module 104, a first judgment result execution module 105, a second judgment result execution module 106, and a classification and recognition module 107. The detailed description of each functional module is as follows:
[0172] The image annotation module 101 is used to obtain various types of skin image data, perform type annotation on the skin image data, and obtain a skin type image;
[0173] The feature determination module 102 is used to obtain a plurality of skin images to be recognized, and determine the skin appearance features of the skin images to be recognized according to the skin type image;
[0174] The algorithm selection module 103 is used to select a feature extraction algorithm for the skin images to be recognized according to the skin appearance features;
[0175] The image convolution module 104 is used to perform point-by-point convolution and depth convolution on the skin images to be recognized according to the selected feature extraction algorithm, and obtain the tattoo probability of each skin image to be recognized;
[0176] The first judgment result execution module 105 is used to, if the tattoo probability is less than or equal to a preset probability threshold, obtain a judgment result that the skin type of the skin image to be recognized with the tattoo probability less than or equal to the probability threshold is not a tattoo;
[0177] The second judgment result execution module 106 is used to, if the tattoo probability is greater than the probability threshold, convert the skin image to be recognized with the tattoo probability greater than the probability threshold into a skin image sequence to be recognized;
[0178] The classification and recognition module 107 is used to obtain a tattoo classification label, and perform feature recognition on the skin image sequence to be recognized by using the tattoo classification label, and obtain a tattoo classification result.
[0179] In an embodiment, when the image annotation module 101 performs type annotation on the skin image data to obtain a skin type image, it is used for:
[0180] Convert the skin image data into a skin grayscale image;
[0181] Perform Gaussian smoothing on the skin grayscale image to obtain a smoothed grayscale image;
[0182] Calculate the horizontal gradient and vertical gradient of each pixel point in the smoothed grayscale image;
[0183] Calculate the gradient magnitude and gradient direction using the horizontal gradient and the vertical gradient;
[0184] Judging one by one along the gradient direction whether the gradient magnitude of each pixel point in the smoothed grayscale image is greater than a preset first threshold;
[0185] If the gradient magnitude of a pixel point is greater than the preset first threshold, then use the pixel point with the gradient magnitude greater than the first threshold as a strong edge;
[0186] If the gradient magnitude of a pixel point is less than or equal to the first threshold, then judge whether the gradient magnitude is less than a preset second threshold;
[0187] If the gradient magnitude is less than the second threshold, then delete the pixel points with the gradient magnitude less than the second threshold;
[0188] If the gradient magnitude is greater than or equal to the second threshold, then judge whether the adjacent pixel points of the pixel points with the gradient magnitude greater than or equal to the second threshold are the strong edges;
[0189] If the adjacent pixel points are not the strong edges, then delete the pixel points with the gradient magnitude greater than or equal to the second threshold;
[0190] If the adjacent pixel points are the strong edges, then use the pixel points with the gradient magnitude greater than or equal to the second threshold as weak edges;
[0191] Perform an OR operation on the strong edges and the weak edges to obtain a skin feature edge;
[0192] Obtain an annotation rule and a skin type label, and use the annotation rule and the skin type label to identify and mark the skin feature edge to obtain a skin type image.
[0193] In one embodiment, the image annotation module 101 performs Gaussian smoothing on the skin grayscale image to obtain a smoothed grayscale image for:
[0194] Randomly select a pixel point of the skin grayscale image as a first target pixel point;
[0195] Use the adjacent pixel points of the first target pixel point as second target pixel points;
[0196] Use a preset Gaussian filter to perform weighted averaging on the pixel values of the first target pixel point and the second target pixel points to obtain an updated pixel value;
[0197] Generate a smoothed grayscale image using the updated pixel value.
[0198] In one embodiment, the image convolution module 104 performs point-by-point convolution and depth convolution on the skin image to be recognized according to the selected feature extraction algorithm, and obtains the tattoo probability of each skin image to be recognized for:
[0199] Generating an appearance feature label using the skin appearance features;
[0200] Performing feature extraction on the skin image to be recognized according to the selected feature extraction algorithm to obtain the texture features of each skin image to be recognized;
[0201] Generating a prediction label for the texture features using a preset preliminary screening model;
[0202] Generating a binary cross-entropy loss function using the appearance feature label and the prediction label;
[0203] Minimizing the binary cross-entropy loss function to obtain a minimum loss function;
[0204] Optimizing the preset preliminary screening model using the minimum loss function to obtain a first screening model;
[0205] Adjusting the skin image to be recognized using a preset resolution factor to obtain an updated skin image;
[0206] Generating a first convolution kernel using a preset depth convolution kernel and a preset width factor;
[0207] Obtaining a first stride, and using the first screening model to perform weighted averaging of each pixel value in the updated skin image with the first convolution kernel one by one according to the first stride to obtain a number of convolution pixel values;
[0208] Generating a first convolution image using the convolution pixel values;
[0209] Performing weighted combination of the first convolution image and a preset point-by-point convolution kernel to obtain the tattoo probability of each first convolution image.
[0210] In one embodiment, the image convolution module 104 performs minimizing the binary cross-entropy loss function to obtain a minimum loss function for:
[0211] Calculating a first gradient using the appearance feature label and the prediction label;
[0212] Obtaining the parameter weights of the preset preliminary screening model, and calculating a second gradient of the parameter weights using the first gradient and the prediction label;
[0213] Generating a final gradient of the binary cross-entropy loss function according to the second gradient;
[0214] Iterate the final gradient using a preset learning rate to obtain the minimum weight;
[0215] Adjust the binary cross - entropy loss function using the minimum weight to obtain the minimum loss function.
[0216] In one embodiment, the second judgment result execution module 106 executes converting the skin image to be recognized that is greater than the probability threshold into a skin sequence to be recognized for:
[0217] Slice the first convolutional image according to a preset block size to obtain a number of convolutional blocks;
[0218] Convert each convolutional block into a one - dimensional vector through linear mapping;
[0219] Obtain the position encoding of each convolutional block, and add the position encoding to the one - dimensional vector corresponding to each convolutional block to obtain the skin sequence to be recognized.
[0220] In one embodiment, the classification and recognition module 107 executes feature recognition of the skin sequence to be recognized using the tattoo classification label to obtain a tattoo classification result for:
[0221] Add the tattoo classification label to the skin sequence to be recognized to obtain an updated skin sequence;
[0222] Capture the relationship between each vector in the updated skin sequence to obtain the correlation between each vector;
[0223] Fully connect the updated skin sequence according to the correlation to obtain a number of tattoo classification output values;
[0224] Optimize the tattoo classification output values using a preset activation function to obtain the tattoo classification probability of each updated skin sequence;
[0225] Generate the tattoo classification result of each updated skin sequence according to the tattoo classification probability.
[0226] In the present invention, for a tattoo classification and recognition method, by acquiring various types of skin image data, performing type annotation on the skin image data to obtain skin type images, acquiring a plurality of skin images to be recognized, determining the skin appearance features of the skin images to be recognized according to the skin type images, selecting a feature extraction algorithm for the skin images to be recognized according to the skin appearance features, performing point-by-point convolution and depth convolution on the skin images to be recognized according to the selected feature extraction algorithm to obtain the tattoo probability of each skin image to be recognized, if the tattoo probability is less than or equal to a preset probability threshold, then the judgment result is that the skin type of the skin image to be recognized with the tattoo probability less than or equal to the probability threshold is not a tattoo, if the tattoo probability is greater than the probability threshold, then the skin image to be recognized with the probability greater than the probability threshold is converted into a skin image sequence to be recognized, acquiring a tattoo classification label, and using the tattoo classification label to perform feature recognition on the skin image sequence to be recognized to obtain a tattoo classification result, effectively improving the accuracy of tattoo classification and recognition. For the specific limitations of a tattoo classification and recognition device, reference may be made to the limitations of a tattoo classification and recognition method in the foregoing text, which will not be elaborated herein. Each module in the foregoing tattoo classification and recognition device can be implemented in whole or in part by software, hardware, and their combination. The foregoing modules can be embedded in or independent of a processor in a computer device in the form of hardware, or stored in a memory in the computer device in the form of software, so as to facilitate the processor to call and execute the operations corresponding to the foregoing modules.
[0227] In one embodiment, a computer device is provided. The computer device can be a server, and its internal structure diagram can be as Figure 3 shown. The computer device includes a processor, a memory, a network interface, and a database connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile and / or volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external client through a network connection. When the computer program is executed by the processor, it realizes the functions or steps on the server side of a tattoo classification and recognition method.
[0228] In one embodiment, a computer device is provided. The computer device can be a client, and its internal structure diagram can be as Figure 4As shown in the figure. The computer device includes a processor, a memory, a network interface, a display screen, and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external server through a network connection. When the computer program is executed by the processor, it realizes the functions or steps on the client side of a tattoo classification and recognition method.
[0229] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, the following steps are implemented:
[0230] Obtain various types of skin image data, perform type annotation on the skin image data to obtain skin type images;
[0231] Obtain several skin images to be recognized, and determine the skin appearance features of the skin images to be recognized according to the skin type images;
[0232] Select a feature extraction algorithm for the skin images to be recognized according to the skin appearance features;
[0233] Perform point-by-point convolution and depth convolution on the skin images to be recognized according to the selected feature extraction algorithm to obtain the tattoo probability of each skin image to be recognized;
[0234] If the tattoo probability is less than or equal to a preset probability threshold, then obtain a judgment result that the skin type of the skin image to be recognized with the tattoo probability less than or equal to the probability threshold is not a tattoo;
[0235] If the tattoo probability is greater than the probability threshold, then convert the skin image to be recognized with the tattoo probability greater than the probability threshold into a skin image sequence to be recognized;
[0236] Obtain a tattoo classification label, and use the tattoo classification label to perform feature recognition on the skin image sequence to be recognized to obtain a tattoo classification result.
[0237] In several embodiments provided by the present invention, it should be understood that the disclosed devices and apparatuses can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the modules is only a logical function division, and there can be other division methods in actual implementation.
[0238] In addition, in each embodiment of the present invention, each functional module can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above integrated unit can be implemented in the form of hardware, or in the form of a combination of hardware and software functional modules.
[0239] Therefore, from any perspective, the embodiments should be regarded as exemplary and non-limiting. The scope of the present invention is defined by the appended claims rather than the above description. Therefore, all changes falling within the meaning and scope of the equivalent elements of the claims are intended to be embraced by the present invention. Any reference signs in the claims should not be construed as limiting the claims involved.
[0240] For those skilled in the art, it is obvious that the present invention is not limited to the details of the above exemplary embodiments, and can be implemented in other specific forms without departing from the spirit or basic characteristics of the present invention.
[0241] In some embodiments of this embodiment, a computer-readable storage medium is provided, on which a computer program is stored, and characterized in that when the computer program is executed by a processor, the steps of the method described in the above embodiment are implemented.
[0242] The readable storage medium described in the present invention stores a computer program, and when the computer program is executed by a processor of an electronic device, it can implement:
[0243] Obtain various types of skin image data, perform type annotation on the skin image data to obtain a skin type image;
[0244] Obtain a number of skin images to be recognized, and determine the skin appearance features of the skin images to be recognized according to the skin type image;
[0245] Select a feature extraction algorithm for the skin images to be recognized according to the skin appearance features;
[0246] Perform point-by-point convolution and depth convolution on the skin images to be recognized according to the selected feature extraction algorithm to obtain the tattoo probability of each skin image to be recognized;
[0247] If the tattoo probability is less than or equal to a preset probability threshold, then obtain a judgment result that the skin type of the skin image to be recognized with the tattoo probability less than or equal to the probability threshold is not a tattoo;
[0248] If the tattoo probability is greater than the probability threshold, then convert the skin image to be recognized with the tattoo probability greater than the probability threshold into a skin image sequence to be recognized;
[0249] Obtain a tattoo classification label, and use the tattoo classification label to perform feature recognition on the skin sequence to be recognized, so as to obtain a tattoo classification result.
[0250] It should be noted that for the functions or steps that can be achieved by the above computer-readable storage medium or computer device, reference can be made to the relevant descriptions on the server side and the client side in the foregoing method embodiments. To avoid repetition, they will not be described one by one here.
[0251] The computer-readable storage medium can also store at least one computer-executable program / instructions, and the computer-executable program / instructions are, for example, computer-readable instructions. The computer-readable storage medium includes, but is not limited to, for example, volatile memory and / or non-volatile memory. Volatile memory may include, for example, random access memory (RAM) and / or cache memory, etc. The computer-readable storage medium may include, for example, read-only memory (ROM), hard disk, flash memory, etc. For example, a non-transitory computer-readable storage medium can be connected to a computing device such as a computer. Then, when the computing device runs the computer-readable instructions stored on the computer-readable storage medium, the various methods described above can be performed.
[0252] In addition, the computer device may also include (but is not limited to) a data bus, an input / output (I / O) bus, a display, and input / output devices (such as a keyboard, a mouse, a speaker, etc.).
[0253] The processor can communicate with external devices via the I / O bus through a wired or wireless network.
[0254] In one embodiment, the at least one computer-executable instruction can also be compiled into or form a software product / computer program product, and when one or more computer-executable instructions are run by a processor, the steps of each function and / or method in the embodiments described in the present technology are executed.
[0255] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to a memory, storage, database, or other medium used in the various embodiments provided in the present application can include non-volatile and / or volatile memories. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and Rambus dynamic RAM (RDRAM), etc.
[0256] Those skilled in the art can clearly understand that for the convenience and brevity of description, only the above division of each functional unit and module is used as an example. In actual applications, the above functions can be allocated to different functional units and modules according to needs, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0257] In the embodiments provided in the present disclosure, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely illustrative. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architectures, functions, and operations of devices, methods, and computer program products according to multiple embodiments of the present disclosure. In this regard, each block in the flowchart or block diagram may represent a module, a program segment, or a part of code, and the above-mentioned module, program segment, or part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than that marked in the accompanying drawings. For example, two consecutive blocks can actually be executed substantially in parallel, and they can sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, as well as the combination of blocks in the block diagram and / or flowchart, can be implemented by a dedicated hardware-based device for performing the specified functions or actions, or can be implemented by a combination of dedicated hardware and computer instructions.
[0258] It should be noted that in the present disclosure, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or device. Without further limitation, an element limited by the statement "comprising a..." does not exclude the existence of additional identical elements in the process, method, article, or device comprising the element.
[0259] The above-described embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit them. Although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments or perform equivalent replacements for some of the technical features. These modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention and should all be included in the protection scope of the present invention.
[0260] It should be noted that if non-company software tools or components appear in the embodiments of this application, they are only used for illustrative introduction and do not represent actual use.
Claims
1. A method for tattoo classification and recognition, characterized in that, The method includes: Obtaining skin image data of multiple types, performing type annotation on the skin image data to obtain skin type images; Obtaining a plurality of skin images to be recognized, and determining the skin appearance features of the skin images to be recognized according to the skin type images; Selecting a feature extraction algorithm for the skin images to be recognized according to the skin appearance features; Performing point-by-point convolution and depth convolution on the skin images to be recognized according to the selected feature extraction algorithm to obtain the tattoo probability of each skin image to be recognized; If the tattoo probability is less than or equal to a preset probability threshold, the determination result is that the skin type of the skin image to be recognized with the tattoo probability less than or equal to the probability threshold is not a tattoo; If the tattoo probability is greater than the probability threshold, the skin images to be recognized with the probability greater than the probability threshold are converted into a sequence of skin images to be recognized; Obtaining tattoo classification labels, and performing feature recognition on the sequence of skin images to be recognized by using the tattoo classification labels to obtain a tattoo classification result.
2. The tattoo classification and recognition method according to claim 1, wherein The performing type annotation on the skin image data to obtain skin type images includes: Converting the skin image data into a skin grayscale image; Performing Gaussian smoothing on the skin grayscale image to obtain a smoothed grayscale image; Calculating the horizontal gradient and vertical gradient of each pixel point in the smoothed grayscale image; Calculating the gradient magnitude and gradient direction by using the horizontal gradient and the vertical gradient; Judging one by one along the gradient direction whether the gradient magnitude of each pixel point in the smoothed grayscale image is greater than a preset first threshold; If the gradient magnitude of a pixel point is greater than the preset first threshold, the pixel point with the gradient magnitude greater than the first threshold is used as a strong edge; If the gradient magnitude of a pixel point is less than or equal to the first threshold, it is judged whether the gradient magnitude is less than a preset second threshold; If the gradient magnitude is less than the second threshold, the pixel points with the gradient magnitude less than the second threshold are deleted; If the gradient magnitude is greater than or equal to the second threshold, it is judged whether the adjacent pixel points of the pixel points with the gradient magnitude greater than or equal to the second threshold are the strong edges; If the adjacent pixel points are not the strong edges, the pixel points with the gradient magnitude greater than or equal to the second threshold are deleted; If the adjacent pixel points are the strong edges, the pixel points with the gradient magnitude greater than or equal to the second threshold are used as weak edges; Performing an OR operation on the strong edges and the weak edges to obtain a skin feature edge; Obtaining annotation rules and skin type labels, and performing recognition and marking on the skin feature edge by using the annotation rules and the skin type labels to obtain a skin type image.
3. The tattoo classification and recognition method according to claim 2, wherein, The performing Gaussian smoothing on the skin grayscale image to obtain a smoothed grayscale image includes: Randomly selecting a pixel point of the skin grayscale image as a first target pixel point; Taking the adjacent pixel points of the first target pixel point as second target pixel points; Performing weighted average on the pixel values of the first target pixel point and the second target pixel points by using a preset Gaussian filter to obtain an updated pixel value; Generate a smoothed grayscale image using the updated pixel values.
4. The tattoo classification and recognition method according to claim 1, wherein, Performing pointwise convolution and depth convolution on the skin image to be recognized according to the selected feature extraction algorithm to obtain the tattoo probability of each skin image to be recognized, including: Generate an appearance feature label using the skin appearance features; Extract features from the skin image to be recognized according to the selected feature extraction algorithm to obtain the texture features of each skin image to be recognized; Generate a prediction label for the texture features using a preset preliminary screening model; Generate a binary cross-entropy loss function using the appearance feature label and the prediction label; Minimize the binary cross-entropy loss function to obtain a minimum loss function; Optimize the preset preliminary screening model using the minimum loss function to obtain a first screening model; Adjust the skin image to be recognized using a preset resolution factor to obtain an updated skin image; Generate a first convolution kernel using a preset depth convolution kernel and a preset width factor; Obtain a first stride, and use the first screening model to perform weighted averaging of each pixel value in the updated skin image with the first convolution kernel one by one according to the first stride to obtain a number of convolution pixel values; Generate a first convolution image using the convolution pixel values; Perform weighted combination of the first convolution image and a preset pointwise convolution kernel to obtain the tattoo probability of each first convolution image.
5. The tattoo classification and recognition method according to claim 4, wherein, The minimizing the binary cross-entropy loss function to obtain a minimum loss function includes: Calculate a first gradient using the appearance feature label and the prediction label; Obtain the parameter weights of the preset preliminary screening model, and calculate a second gradient of the parameter weights using the first gradient and the prediction label; Generate a final gradient of the binary cross-entropy loss function according to the second gradient; Iterate the final gradient using a preset learning rate to obtain minimum weights; Adjust the binary cross-entropy loss function using the minimum weights to obtain a minimum loss function.
6. The tattoo classification and recognition method according to claim 1, wherein The converting the skin image to be recognized with a probability greater than the probability threshold into a skin sequence to be recognized includes: Slice the first convolution image according to a preset block size to obtain a number of convolution blocks; Convert each convolution block into a one-dimensional vector through linear mapping; Obtain the position encoding of each convolution block, and add the position encoding to the one-dimensional vector corresponding to each convolution block to obtain a skin sequence to be recognized.
7. The tattoo classification and recognition method according to claim 1, characterized in that, The performing feature recognition on the skin sequence to be recognized using the tattoo classification label to obtain a tattoo classification result includes: Add the tattoo classification label to the skin sequence to be recognized to obtain an updated skin sequence; Capture the relationship between each vector in the updated skin sequence to obtain the correlation between each vector; Fully connect the updated skin sequence according to the correlation to obtain a number of tattoo classification output values; Optimize the tattoo classification output values using a preset activation function to obtain the tattoo classification probability of each updated skin sequence; Generate a tattoo classification result for each updated skin sequence according to the tattoo classification probability.
8. A tattoo classification and recognition device, characterized in that The device includes: An image annotation module, configured to obtain skin image data of multiple types, perform type annotation on the skin image data, and obtain a skin type image; A feature determination module, configured to obtain a plurality of skin images to be recognized, and determine the skin appearance features of the skin images to be recognized according to the skin type image; An algorithm selection module, configured to select a feature extraction algorithm for the skin images to be recognized according to the skin appearance features; An image convolution module, configured to perform point-by-point convolution and depth convolution on the skin images to be recognized according to the selected feature extraction algorithm, and obtain the tattoo probability of each skin image to be recognized; A first judgment result execution module, configured to, if the tattoo probability is less than or equal to a preset probability threshold, obtain a judgment result that the skin type of the skin image to be recognized with the tattoo probability less than or equal to the probability threshold is not a tattoo; A second judgment result execution module, configured to, if the tattoo probability is greater than the probability threshold, convert the skin image to be recognized with the tattoo probability greater than the probability threshold into a skin image sequence to be recognized; A classification and recognition module, configured to obtain a tattoo classification label, and perform feature recognition on the skin image sequence to be recognized by using the tattoo classification label, so as to obtain a tattoo classification result.
9. An electronic device, characterized in that, The electronic device includes: At least one processor; and A memory communicatively connected to the at least one processor; wherein The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor, so that the at least one processor can execute the tattoo classification and recognition method according to any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the tattoo classification and recognition method according to any one of claims 1 to 7.