Cross-domain underwater image recognition method, device and system, and storage medium

Through the cross-domain underwater image recognition method, supervised training and pseudo-label comparison learning are used to optimize feature space, and data scarcity and domain deviation problems in underwater image recognition are solved, improving the adaptability and accuracy of the model.

CN120510499APending Publication Date: 2025-08-19HUNAN UNIV OF SCI & TECH SANYA RES INST
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510604937.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-12
Publication Date
2025-08-19

AI Technical Summary

Technical Problem

The prior art is difficult to effectively use land image data for underwater image recognition, resulting in poor adaptability of models in underwater environments, and the scarcity of underwater labeling data affects the generalization ability and accuracy of classification models.

Method used

Through the cross-domain underwater image recognition method, the source domain image data set with labels is used for supervision and training, and the sample weight is dynamically allocated to optimize the intra-class aggregation and inter-class separation of feature space. Combined with pseudo-labels and contrast learning, triple samples are constructed for comparison learning, and a new loss function is designed to optimize feature space.

Benefits of technology

It improves the generalization ability and adaptability of the underwater image recognition model, reduces dependence on underwater data, and enhances the discrimination and identification accuracy of features.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120510499A_ABST
    Figure CN120510499A_ABST
Patent Text Reader

Abstract

The invention discloses a cross-domain underwater image recognition method, device and system, and a storage medium. The method comprises the steps of obtaining a to-be-recognized target domain image; inputting the target domain image to be recognized into an image recognition model for processing, and outputting a recognition result; wherein the image recognition model is trained through a training set, the intra-class aggregation and inter-class separability of a feature space are optimized by calculating comparison loss and dynamically distributing sample weights, a target domain model is optimized until convergence, and the training set is a source domain image data set with labels. According to the method, the recognition task of underwater image cross-domain migration is effectively solved, and a new thought is provided for the problems of limited data and cross-domain distribution difference in the target field.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of underwater image recognition technology, and in particular to a cross-domain underwater image recognition method and device, system, and storage medium. Background Art

[0002] Underwater image classification has a wide range of applications in ocean exploration, underwater robot navigation, aquatic life monitoring, underwater target detection, and other fields. However, due to the complexity of the underwater environment, such as lighting changes, color attenuation, imaging blur, and water medium scattering, underwater images often suffer from low contrast, color shift, and noise interference, making feature extraction extremely difficult. In addition, compared with terrestrial environments, underwater scene data acquisition is more difficult. Due to factors such as the high cost of underwater operations, limited sensor equipment, and the difficulty of manual labeling, the available high-quality underwater annotated data is extremely limited. This data scarcity makes it difficult to effectively train supervised classification methods based on deep learning, seriously affecting the generalization ability and accuracy of the classification model.

[0003] Current mainstream underwater image classification methods typically rely on training deep neural network models with large-scale annotated data. However, due to the limited availability of annotated underwater data, models are prone to overfitting, resulting in poor classification performance in real underwater environments. To alleviate this data scarcity, some studies have employed unsupervised or semi-supervised learning methods, optimizing through techniques such as transfer learning, pseudo-labeling, or data augmentation. However, these methods still struggle to address the domain bias between underwater and terrestrial images, resulting in poor model adaptability in underwater environments. Furthermore, some studies have attempted to use synthetic data for underwater model training, but due to the significant distribution discrepancy between synthetic data and real underwater images, accurate classification remains difficult to achieve.

[0004] Therefore, a classification method that can fully utilize existing terrestrial image data and effectively adapt to underwater environments is urgently needed to reduce the reliance on large amounts of underwater annotated data and improve the generalization and discrimination capabilities of underwater image classification. In particular, when data is limited, how to effectively extract discriminative features that are shared across domains while reducing the impact of underwater environmental interference on classification results has become a key challenge in the current field of underwater image classification. Summary of the Invention

[0005] In order to solve the technical problems existing in the above-mentioned prior art, the present invention proposes a cross-domain underwater image recognition method and device, system, and storage medium. Especially in the absence of underwater image data, it can make full use of existing land image data, effectively adapt to the recognition method of underwater environment, reduce dependence on underwater data, and improve the generalization ability and adaptability of the model.

[0006] On the one hand, to achieve the above-mentioned object, the present invention provides a cross-domain underwater image recognition method, comprising:

[0007] Obtain the target domain image to be identified;

[0008] Inputting the target domain image to be identified into the image recognition model for processing, and outputting the recognition result;

[0009] The image recognition model is trained through a training set, and by calculating contrast loss, dynamically allocating sample weights to optimize the intra-class aggregation and inter-class separation of the feature space, and optimizing the target domain model until convergence. The training set is a labeled source domain image dataset.

[0010] Preferably, using the labeled source domain image dataset for supervised training includes:

[0011] Use the labeled source domain image dataset for supervised training to obtain the source domain pre-training model;

[0012] Initialize the target domain model according to the source domain pre-trained model parameters, and input the labeled source domain image and the unlabeled target domain image into the source domain feature extractor and the target domain feature extractor respectively to obtain source domain features and target domain features respectively;

[0013] After assigning domain labels, the source domain features and the target domain features are respectively input into the discriminator for adversarial training, and the discriminator loss and the target domain mapping loss are respectively calculated;

[0014] The target domain features are input into the source classifier to predict the pseudo labels and obtain the pseudo label prediction results.

[0015] Preferably, the labeled source domain image dataset is P S (x S ,y S ), where x S Represents the data of the input source domain, including cars, ships, containers, people, S Indicates the label corresponding to the image, y S ={0,1,2,3,…} represent cars, ships, containers, and people respectively.

[0016] Preferably, calculating the contrast loss includes:

[0017] According to the pseudo-label prediction results, triple samples are constructed for contrastive learning, the contrastive loss is calculated, and sample weights are dynamically allocated to optimize intra-class aggregation and inter-class separation in the feature space.

[0018] Preferably, the contrast loss is calculated as:

[0019] Construct triplets using anchor samples, similar positive samples, and different negative samples;

[0020] According to the dynamic difference between the intra-class distance and the inter-class distance, the weight factor is assigned and combined with the boundary parameter to define the contrast loss function as follows:

[0021]

[0022] Where, is the weight factor, L Triplet is the contrast loss, N is the number of samples in the batch, a is the anchor point, p is the pseudo positive sample with the same pseudo label, δ is the weight, n is the pseudo negative sample with different pseudo labels, margin is the boundary parameter, and σ(·) is the activation function.

[0023] Preferably, constructing the image recognition model further includes:

[0024] The discriminator is updated using the discriminator loss, and the target feature extractor is updated respectively using the target domain mapping loss and the contrast loss, the target domain model is updated, and the image recognition model is obtained.

[0025] On the other hand, to achieve the above-mentioned object, the present invention further provides a cross-domain underwater image recognition device, comprising:

[0026] Image acquisition module: used to obtain the target domain image to be identified;

[0027] Processing output module: used to input the target domain image to be identified into the image recognition model for processing and output the recognition result;

[0028] The image recognition model is trained through a training set, and by calculating contrast loss, dynamically allocating sample weights to optimize the intra-class aggregation and inter-class separation of the feature space, and optimizing the target domain model until convergence. The training set is a labeled source domain image dataset.

[0029] Preferably, the processing output module includes a model building submodule and an identification submodule, wherein the model building submodule includes a training unit and a processing unit;

[0030] The training unit is used to perform supervised training using the labeled source domain image dataset, including:

[0031] Use the labeled source domain image dataset for supervised training to obtain the source domain pre-training model;

[0032] Initialize the target domain model according to the source domain pre-trained model parameters, and input the labeled source domain image and the unlabeled target domain image into the source domain feature extractor and the target domain feature extractor respectively to obtain source domain features and target domain features respectively;

[0033] After assigning domain labels, the source domain features and the target domain features are respectively input into the discriminator for adversarial training, and the discriminator loss and the target domain mapping loss are respectively calculated;

[0034] Input the target domain features into the source classifier to predict the pseudo label and obtain the pseudo label prediction result;

[0035] The processing unit is used to construct triple samples for contrastive learning based on the pseudo-label prediction results, calculate the contrast loss, dynamically allocate sample weights to optimize the intra-class aggregation and inter-class separation of the feature space, and update the discriminator using the discriminator loss, and update the target feature extractor using the target domain mapping loss and the contrast loss respectively, update the target domain model, and obtain the image recognition model.

[0036] The present invention provides a cross-domain underwater image recognition system, comprising: a memory and a processor, wherein the memory stores a computer program run by the processor, and the computer program executes the steps of a cross-domain underwater image recognition method when run by the processor.

[0037] The present invention also provides a storage medium, on which a computer program is stored, and when the computer program is run, the steps of the cross-domain underwater image recognition method are executed.

[0038] Compared with the prior art, the present invention has the following advantages and technical effects:

[0039] This paper constructs triplet samples through pseudo-labels for comparative learning, enhances intra-class aggregation and inter-class separation within the domain, and thus optimizes the feature space. A new loss function is designed to assign different weights according to the degree of confusion of samples within the domain, accelerating the optimization of the adjustment space. For complex underwater cross-domain migration image recognition and classification tasks, a joint inter-domain alignment and intra-domain feature space optimization strategy is designed. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] The accompanying drawings, which constitute part of this application, are intended to provide a further understanding of this application. The exemplary embodiments and descriptions of this application are intended to explain this application and do not constitute an improper limitation on this application. In the accompanying drawings:

[0041] Figure 1 This is a flow chart of a cross-domain underwater image recognition method according to an embodiment of the present invention;

[0042] Figure 2 A data set constructed according to actual needs in an embodiment of the present invention;

[0043] Figure 3 This is an algorithm flow chart of the joint inter-domain alignment and intra-domain feature space optimization strategy according to an embodiment of the present invention;

[0044] Figure 4 A schematic diagram illustrating the visualization of features of an embodiment of the present invention;

[0045] Figure 5 This is a schematic diagram of the visualization results of the target domain model for underwater image category prediction according to an embodiment of the present invention. DETAILED DESCRIPTION

[0046] It should be noted that, in the absence of conflict, the embodiments and features of the embodiments in this application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0047] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0048] This paper proposes a cross-domain underwater image recognition method, such as Figure 1 ,include:

[0049] Obtain the target domain image to be identified;

[0050] Input the target domain image to be identified into the image recognition model for processing and output the recognition result;

[0051] The image recognition model is trained through a training set, and by calculating contrast loss, dynamically allocating sample weights to optimize the intra-class aggregation and inter-class separation of the feature space, and optimizing the target domain model until convergence. The training set is a labeled source domain image dataset.

[0052] This paper constructs triplet samples through pseudo-labels for comparative learning, enhances intra-class aggregation and inter-class separation within the domain, and thus optimizes the feature space. A new loss function is designed to assign different weights according to the degree of confusion of samples within the domain, accelerating the optimization of the adjustment space. For complex underwater cross-domain migration image recognition and classification tasks, a joint inter-domain alignment and intra-domain feature space optimization strategy is designed.

[0053] Furthermore, supervised training is performed using a labeled source domain image dataset, including:

[0054] Use the labeled source domain image dataset for supervised training to obtain the source domain pre-training model;

[0055] Initialize the target domain model according to the source domain pre-trained model parameters, and input the labeled source domain image and the unlabeled target domain image into the source domain feature extractor and the target domain feature extractor respectively to obtain source domain features and target domain features respectively;

[0056] After assigning domain labels, the source domain features and the target domain features are respectively input into the discriminator for adversarial training, and the discriminator loss and the target domain mapping loss are respectively calculated;

[0057] The target domain features are input into the source classifier to predict the pseudo labels and obtain the pseudo label prediction results.

[0058] Specifically, we select common objects on land as the source domain and label them, and use underwater environment images corresponding to these objects as the target domain. The labeled source domain image dataset is P S (x S ,y S ), where x S Represents the data of the input source domain, including cars, ships, containers, people, S Indicates the label corresponding to the image, y S ={0,1,2,3,…} represent cars, ships, containers, and people respectively.

[0059] When assigning domain labels for adversarial training, in order to avoid the discriminator converging too quickly in the early stages of training, which leads to gradient vanishing, gradient reversal is not used to maximize the discriminator's loss. Instead, the domain labels of the source and target domains are reversed. The purpose is to confuse the discriminator's ability to distinguish domain labels, forcing it to learn more refined feature differentiation capabilities, and providing more effective gradients to stabilize training.

[0060] Furthermore, calculating the contrast loss includes:

[0061] According to the pseudo-label prediction results, triple samples are constructed for contrastive learning, the contrastive loss is calculated, and sample weights are dynamically allocated to optimize intra-class aggregation and inter-class separation in the feature space.

[0062] Specifically, the pre-trained source classifier is used to predict pseudo labels. As the number of iterations increases, the prediction of pseudo labels becomes more and more accurate, thereby achieving the goal of optimizing the feature space and accurate prediction.

[0063] Furthermore, the contrast loss is calculated as:

[0064] Construct triplets using anchor samples, similar positive samples, and different negative samples;

[0065] The weight factor is assigned according to the dynamic difference between the intra-class distance and the inter-class distance, and the contrast loss function is defined in combination with the boundary parameter.

[0066] Specifically, contrastive learning is integrated into the training process of the target domain model to enhance the intra-class aggregation and inter-class separation within the domain, thereby optimizing the feature space of the target domain and making the target domain features more discriminable.

[0067] Use the source classifier to predict the pseudo-label of the target domain, construct triplet samples for comparative learning, set the target domain sample feature as anchor a, and the sample with the same pseudo-label as the positive sample p, and the sample with the opposite pseudo-label as the negative sample n, so as to bring the feature space of the positive sample closer and the feature space of the negative sample farther away. Define the sample with the intra-class distance greater than the inter-class distance as the difficult sample, and dynamically assign different weights δ according to the degree of difficulty. In order to avoid excessive punishment or unnecessary distance adjustment, specify the boundary parameter margin and weight factor That is, the contrast loss L Triplet It can be defined as:

[0068]

[0069] Where, is the weight factor, L Triplet is the contrast loss, N is the number of samples in the batch, a is the anchor point, p is the pseudo positive sample with the same pseudo label, δ is the weight, n is the pseudo negative sample with different pseudo labels, margin is the boundary parameter, and σ(·) is the activation function.

[0070] Furthermore, building an image recognition model also includes:

[0071] The discriminator is updated using the discriminator loss, and the target feature extractor is updated respectively using the target domain mapping loss and the contrast loss, the target domain model is updated, and the image recognition model is obtained.

[0072] Specifically, during pre-training, only the source domain data X S and Y S Train and continuously update M S To reduce L cls , we need to fix the source domain M when training the target model. S and C S , on this basis, optimize L advD 、 and L Triplet It is worth noting that although both adversarial loss and triplet loss are TUpdates are performed, but the two losses optimize different objectives: the former is a strategy for cross-domain alignment, competing with the domain discriminator while potentially sacrificing some discriminative properties of the target domain features; the latter is a strategy for intra-domain discrimination and is independent of the domain discriminator. To avoid gradient conflicts during updates while achieving the dual goals of domain adaptation and class discrimination and ensuring training stability, these two losses are optimized separately.

[0073] Repeat the above steps to continuously align the source domain features with the target domain features, narrowing the gap between their feature distributions. As the number of iterations increases, the predicted pseudo-labels gradually become closer to the true labels, and the feature space is gradually optimized, making the target domain features more discriminative. When the maximum number of training iterations is reached, stop training and save the model.

[0074] This embodiment further provides a cross-domain underwater image recognition device, including:

[0075] Image acquisition module: used to obtain the target domain image to be identified;

[0076] Processing output module: used to input the target domain image to be identified into the image recognition model for processing and output the recognition result;

[0077] The image recognition model is trained through a training set, and by calculating contrast loss, dynamically allocating sample weights to optimize the intra-class aggregation and inter-class separation of the feature space, and optimizing the target domain model until convergence. The training set is a labeled source domain image dataset.

[0078] Furthermore, the processing output module includes a model building submodule and an identification submodule, wherein the model building submodule includes a training unit and a processing unit;

[0079] The training unit is used to perform supervised training using a labeled source domain image dataset, including:

[0080] Use the labeled source domain image dataset for supervised training to obtain the source domain pre-training model;

[0081] Initialize the target domain model according to the source domain pre-trained model parameters, and input the labeled source domain image and the unlabeled target domain image into the source domain feature extractor and the target domain feature extractor respectively to obtain the source domain features and the target domain features respectively;

[0082] After assigning domain labels, the source domain features and the target domain features are input into the discriminator for adversarial training, and the discriminator loss and the target domain mapping loss are calculated respectively;

[0083] Input the target domain features into the source classifier to predict the pseudo label and obtain the pseudo label prediction result;

[0084] The processing unit is used to construct triple samples for contrastive learning based on the pseudo-label prediction results, calculate the contrast loss, dynamically allocate sample weights to optimize the intra-class aggregation and inter-class separation of the feature space, and update the discriminator using the discriminator loss, and update the target feature extractor using the target domain mapping loss and the contrast loss respectively, update the target domain model, and obtain the image recognition model.

[0085] Specifically, it is used to assign domain labels for adversarial training. In order to avoid the discriminator converging too quickly in the early stages of training, which leads to gradient vanishing, gradient reversal is not used to maximize the discriminator's loss. Instead, the domain labels of the source and target domains are reversed. The purpose is to confuse the discriminator's ability to distinguish domain labels, forcing it to learn more refined feature discrimination capabilities, and providing more effective gradients to stabilize training.

[0086] The pre-trained source classifier is used to predict pseudo labels. As the number of iterations increases, the prediction of pseudo labels becomes more and more accurate, thereby achieving the goal of optimizing the feature space and accurate prediction.

[0087] This embodiment also provides a cross-domain underwater image recognition system, including: a memory and a processor, wherein the memory stores a computer program executed by the processor, and the computer program executes the steps of the cross-domain underwater image recognition method when executed by the processor.

[0088] This embodiment also provides a storage medium, on which a computer program is stored. When the computer program is run, the steps of the cross-domain underwater image recognition method are executed.

[0089] In order to more clearly express the technical solution of the present invention, the following specific embodiments are provided to introduce the solution:

[0090] Example 1

[0091] A cross-domain underwater image recognition method, specifically comprising:

[0092] Step 1: Perform supervised training on the source domain image dataset with labeled data to obtain a pre-trained model of the source domain;

[0093] In step 1, underwater image recognition is used as the background to fully utilize the existing land image data and migrate it to underwater for accurate underwater image recognition. Figure 2As shown, labeled land images serve as the source domain, and images of the corresponding underwater environment serve as the target domain. To prevent the target domain model from degrading in the absence of labeled data during knowledge transfer, a classification pre-training is first performed on labeled source domain images to learn the most effective feature representation, providing a good starting point for the target domain classification task. This initialization method reduces the difficulty of learning the target model from scratch and helps it effectively adapt to the target domain under unsupervised conditions.

[0094] Assume that the source domain image dataset is P S (x S ,y S ), x S Represents the data of the input source domain, including categories such as cars, ships, containers, people, etc., y S Indicates the label corresponding to the image, y S = {0, 1, 2, 3, ...} represent cars, ships, containers, people, etc. respectively. The feature extractors of the source domain and the target domain are decoupled. In this embodiment, the ResNet50 network is used to design the source domain feature extractor M S (·) and the target domain feature extractor M T (·). Shared source domain classifier C S It can be used directly in the target domain feature classification. In order to convert the category score into a probability distribution, the Softmax function is usually used in the last layer of the classifier to convert the score into a probability distribution. The formula is:

[0095]

[0096] Where z i is the score of the i-th category, K is the total number of categories, Exponentiate this score (to amplify the variability).

[0097] The source domain model is supervised by minimizing the cross entropy loss function, and the source classifier loss L cls It can be expressed as:

[0098]

[0099] Step 2: Initialize the target domain model based on the source domain model parameters, including the feature extractor and domain discriminator;

[0100] In step 2, it is assumed that the target domain model and the source domain model have the same model structure but different model parameters. The purpose is to enable the feature extractor to learn the mapping relationship between the source domain and the target domain more effectively. Specifically: the feature extractors of the source domain and the target domain are decoupled, and a more flexible asymmetric mapping is adopted, allowing the feature extractor model to focus on extracting the data features of the domain. By decoupling the feature extractor, it is also possible to avoid excessive migration of source domain features to the target domain, and to better adjust the representation of each domain in adversarial training. The overall algorithm flow is as follows: Figure 3 shown.

[0101] The target domain and the source domain should maintain consistency in the feature extraction model. In the early stage of training, the target domain model is initialized using the source domain model, that is, the parameters of the source domain model are used as the starting point of the target domain model to reduce the difficulty of model training.

[0102] Step 3: Extract source domain and target domain features;

[0103] In step 3, the labeled source domain image and the unlabeled target domain image are input into the source domain feature extractor and the target domain feature extractor respectively to obtain the source domain features and the target domain features respectively in preparation for subsequent training.

[0104] Step 4: After assigning domain labels, input the features of the source domain and target domain into the discriminator for adversarial training, and calculate the discriminator loss L respectively. advD and the target domain mapping loss ;

[0105] First, assuming that the labels of the source domain and target domain are 1 and 0 respectively, the source domain and target domain features extracted in step 3 are input into the discriminator D, and gradually decrease from 1024, 512, 256 through the fully connected layer, and finally a scalar value is output. Batch normalization is used after each fully connected layer to accelerate training and improve the stability of the model. LeakyReLU is used as the activation function, and the negative slope is set to 0.2. This helps prevent the problem of neuron death. Dropout is applied after multiple layers to prevent overfitting. The last layer is a fully connected layer that outputs a scalar value and maps it to the range of [0,1] through the Sigmoid function, indicating the probability that the input data is true data.

[0106] Discriminator loss L advD The form is expressed as:

[0107]

[0108] Where, is the expectation of source domain samples, D(M S (xS )) is the domain label of the predicted source domain, is the expectation of the target domain samples, D(M T (x T )) is the domain label of the predicted target domain.

[0109] In order to avoid the discriminator's rapid convergence in the early stages of training, which leads to the disappearance of gradients, we do not use gradient reversal to maximize the discriminator's loss. Instead, we reverse the domain labels of the source and target domains. This is to confuse the discriminator's ability to distinguish domain labels, forcing it to learn more refined feature differentiation capabilities, providing more effective gradients to stabilize training. At the same time, it creates an adversarial effect with the previous discriminator, encouraging M S (·) and M T (·) The extracted features are difficult to distinguish in their distribution, which makes the feature distribution of the source domain and the target domain aligned. At this time, the loss of the target domain mapping Expressed as:

[0110]

[0111] Step 5: Input the target domain features into the source classifier to predict the pseudo label;

[0112] In step 5, the pre-trained source domain model parameters are used as the initialization of the target domain model, and the weight parameters of the source classifier are shared. The target domain model itself has a certain discriminator for the target domain data at the beginning of training. As the number of iterations increases, the target domain feature extractor is continuously optimized, and the prediction of pseudo labels will gradually increase, providing a basis for subsequent feature space optimization.

[0113] Step 6: Based on the predicted pseudo labels, construct triplet samples for comparative learning and calculate the contrast loss L contrast :

[0114] In step 6, contrastive learning is integrated into the training process of the target domain model to enhance the intra-class aggregation and inter-class separation within the domain, thereby optimizing the feature space of the target domain and making the target domain features more discriminable. Figure 4 The feature visualization in effectively demonstrates the optimization and improvement of the feature space.

[0115] Use the source classifier to predict the pseudo-label of the target domain, construct triplet samples for comparative learning, set the target domain sample feature as anchor a, and the sample with the same pseudo-label as the positive sample p, and the sample with the opposite pseudo-label as the negative sample n, so as to bring the feature space of the positive sample closer and the feature space of the negative sample farther away. Define the sample with the intra-class distance greater than the inter-class distance as the difficult sample, and dynamically assign different weights δ according to the degree of difficulty. In order to avoid excessive punishment or unnecessary distance adjustment, specify the boundary parameter margin and weight factor That is, the contrast loss LTriplet It can be defined as:

[0116]

[0117] Where, is the weight factor, L Triplet is the contrast loss, N is the number of samples in the batch, a is the anchor point, p is the pseudo positive sample with the same pseudo label, δ is the weight, n is the pseudo negative sample with different pseudo labels, margin is the safety margin parameter, and σ(·) is the activation function.

[0118] Step 7: Use the discriminator loss L advD Update the discriminator with the loss of the target domain mapping and contrast loss L contrast Update the target feature extractor separately;

[0119] During pre-training, only the source domain data X S and Y S Train and continuously update M S To reduce L cls , we need to fix the source domain M when training the target model. S and C S , on this basis, optimize L advD 、 and L Triplet It is worth noting that although both adversarial loss and triplet loss are T However, the two loss optimization goals are different: the former is an inter-domain alignment strategy, which may sacrifice the discriminability of some target domain features while competing with the domain discriminator; while the latter is an intra-domain discriminative strategy and has nothing to do with the domain discriminator.

[0120] In order to avoid gradient conflicts during updates, achieve the dual goals of domain adaptation and class discrimination, and ensure the stability of training, these two losses are optimized separately.

[0121] Step 8: Repeat steps 3 to 7 to update the target domain model and obtain a trained training image recognition model.

[0122] Specifically, the source domain features are continuously aligned with the target domain features, narrowing the gap between their distributions. As the number of iterations increases, the predicted pseudo-labels gradually become closer to the true labels, and the feature space is gradually optimized, making the target domain features more discriminative. When the maximum number of training iterations is reached, training is stopped and the model is saved.

[0123] This embodiment performs target optimization based on the constraints of the mapping between the source domain and the target domain. Step 8 continuously repeats steps 3 to 7 to minimize all losses in the steps. The loss optimization formula is as follows (min is the minimized loss):

[0124]

[0125]

[0126] Where, To minimize classification loss and make recognition more accurate;

[0127] To minimize the discriminator loss, the feature extractor can learn the mapping relationship between the source domain and the target domain more effectively;

[0128] To minimize the loss of target domain mapping, the discriminator’s ability to distinguish domain labels is confused, forcing it to learn more refined feature differentiation capabilities, thereby achieving the goal of cross-domain recognition;

[0129] In order to minimize the contrast loss and optimize the feature space of the target domain, the target domain features are made more discriminable.

[0130] Step 9: Use the trained image recognition model to identify and classify the image data in the target domain.

[0131] The feature extractor converts the input data into high-dimensional features, and the classifier outputs the category score based on these features. The visualization results of the underwater image category prediction results are as follows Figure 5 The comparison with other methods is shown in Table 1.

[0132] In order to convert the category score into a probability distribution, the Softmax function is usually used in the last layer of the classifier to convert the score into a probability distribution, and the category with the largest probability is selected as the predicted label, that is:

[0133]

[0134] Here, i is the sample number.

[0135] The calculation formula for accuracy is:

[0136]

[0137] Among them, Number of Correct Predictions is the number of samples predicted correctly by the model, and Total of Correct Predictions is the total number of samples in the test dataset.

[0138] Table 1

[0139]

[0140] Example 2

[0141] A cross-domain underwater image recognition device, comprising:

[0142] Image acquisition module: used to obtain the target domain image to be identified

[0143] Processing output module: used to input the target domain image to be identified into the image recognition model for processing and output the recognition result;

[0144] Among them, the image recognition model is trained through a training set, and by calculating the contrast loss, dynamically allocating sample weights to optimize the intra-class aggregation and inter-class separation of the feature space, and optimizing the target domain model until convergence. The training set is a labeled source domain image dataset.

[0145] Furthermore, the processing output module includes a model building submodule and an identification submodule, wherein the model building submodule includes a training unit and a processing unit;

[0146] The training unit is used to perform supervised training using a labeled source domain image dataset, including:

[0147] Use the source domain image dataset on land for supervised training to obtain the source domain model. Initialize the target domain model based on the source domain model parameters, and extract the features of the source and target domains for subsequent target domain training.

[0148] The discriminator's ability to distinguish domain labels is confused, forcing it to learn more refined feature differentiation capabilities. At the same time, it antagonizes the discriminator, encouraging the feature extractor to extract features that are difficult to distinguish in its distribution, and aligning the feature distributions of the source and target domains.

[0149] The features of the target domain are input into the source classifier to give pseudo labels to the target domain feature samples.

[0150] The processing unit is used to construct triple samples for contrast learning based on the pseudo-label prediction results, calculate the contrast loss, dynamically allocate sample weights to optimize the intra-class aggregation and inter-class separation of the feature space, and update the discriminator using the discriminator loss, and update the target feature extractor using the target domain mapping loss and the contrast loss respectively, update the target domain model, and obtain an image recognition model.

[0151] Specifically, based on the target domain samples with pseudo labels, triple samples are constructed and the contrast loss L is used. contrastTo optimize the feature space, the features of samples predicted to be of the same type are brought closer together, and the features of samples of different types are pulled further apart, thereby optimizing the feature space;

[0152] Take the discriminator loss L advD To update the discriminator, the loss of the target domain mapping and contrast loss L contrast Update the target feature extractor separately;

[0153] The target domain model is updated to obtain a trained image recognition model, and the trained image recognition model is used to identify and classify the image data of the target domain.

[0154] As an implementation method of the present invention, images of common objects on land are selected as the source domain and labeled, and the underwater environment images corresponding to these objects are used as the target domain. The source domain dataset is P S (x S ,y S ), x S Represents the data of the input source domain, including cars, ships, containers, people, etc., y S Indicates the label corresponding to the image, y S ={1, 2, 3, ...} represent cars, ships, containers, people, ... respectively.

[0155] As one implementation of this invention, domain labels are assigned for adversarial training. To avoid vanishing gradients due to the discriminator converging too quickly in the early stages of training, this embodiment does not directly maximize the discriminator's loss through gradient reversal. Instead, domain label reversal is used to guide adversarial training. The goal is to confuse the discriminator's ability to distinguish domain labels, forcing it to learn more refined feature differentiation capabilities, providing more effective gradients and promoting training stability.

[0156] The pre-trained source classifier is used to predict pseudo labels. As the number of iterations increases, the prediction of pseudo labels becomes more and more accurate, thereby achieving the goal of optimizing the feature space and accurate prediction.

[0157] Example 3

[0158] A cross-domain underwater image recognition system comprises: a memory and a processor, wherein the memory stores a computer program executed by the processor, and the computer program executes the steps of a cross-domain underwater image recognition method when executed by the processor.

[0159] Example 4

[0160] A storage medium stores a computer program, which executes the steps of a cross-domain underwater image recognition method when running.

[0161] The above are merely preferred embodiments of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of the present application. Therefore, the scope of protection of the present application should be based on the scope of protection of the claims.

Claims

1. A cross-domain underwater image recognition method, characterized in that: include: Obtain the target domain image to be identified; Inputting the target domain image to be identified into the image recognition model for processing, and outputting the recognition result; The image recognition model is trained through a training set, and by calculating contrast loss, dynamically allocating sample weights to optimize the intra-class aggregation and inter-class separation of the feature space, and optimizing the target domain model until convergence. The training set is a labeled source domain image dataset.

2. The cross-domain underwater image recognition method according to claim 1, characterized in that: Supervised training is performed using the labeled source domain image dataset, including: Use the labeled source domain image dataset for supervised training to obtain the source domain pre-training model; Initialize the target domain model according to the source domain pre-trained model parameters, and input the labeled source domain image and the unlabeled target domain image into the source domain feature extractor and the target domain feature extractor respectively to obtain source domain features and target domain features respectively; After assigning domain labels, the source domain features and the target domain features are respectively input into the discriminator for adversarial training, and the discriminator loss and the target domain mapping loss are respectively calculated; The target domain features are input into the source classifier to predict the pseudo labels and obtain the pseudo label prediction results.

3. The cross-domain underwater image recognition method according to claim 2, characterized in that: The labeled source domain image dataset is P S (x S ,y S ), where x S Represents the data of the input source domain, including cars, ships, containers, people, S Indicates the label corresponding to the image, y S ={0,1,2,3,···} represent cars, ships, containers, and people respectively.

4. The cross-domain underwater image recognition method according to claim 2, characterized in that: Calculating contrast loss involves: According to the pseudo-label prediction results, triple samples are constructed for contrastive learning, the contrastive loss is calculated, and sample weights are dynamically allocated to optimize intra-class aggregation and inter-class separation in the feature space.

5. The cross-domain underwater image recognition method according to claim 4, characterized in that: The contrast loss is calculated as: Construct triplets using anchor samples, similar positive samples, and different negative samples; According to the dynamic difference between the intra-class distance and the inter-class distance, the weight factor is assigned and combined with the boundary parameter to define the contrast loss function as follows: Where, is the weight factor, L Triplet is the contrast loss, N is the number of samples in the batch, a is the anchor point, p is the pseudo positive sample with the same pseudo label, δ is the weight, n is the pseudo negative sample with different pseudo labels, margin is the boundary parameter, and σ(·) is the activation function.

6. The cross-domain underwater image recognition method according to claim 4, characterized in that: Building the image recognition model also includes: The discriminator is updated using the discriminator loss, and the target feature extractor is updated respectively using the target domain mapping loss and the contrast loss, the target domain model is updated, and the image recognition model is obtained.

7. A cross-domain underwater image recognition device, characterized in that: include: Image acquisition module: used to obtain the target domain image to be identified; Processing output module: used to input the target domain image to be identified into the image recognition model for processing and output the recognition result; The image recognition model is trained through a training set, and by calculating contrast loss, dynamically allocating sample weights to optimize the intra-class aggregation and inter-class separation of the feature space, and optimizing the target domain model until convergence. The training set is a labeled source domain image dataset.

8. The cross-domain underwater image recognition device according to claim 7, characterized in that: The processing output module includes a model building submodule and an identification submodule, wherein the model building submodule includes a training unit and a processing unit; The training unit is used to perform supervised training using the labeled source domain image dataset, including: Use the labeled source domain image dataset for supervised training to obtain the source domain pre-training model; Initialize the target domain model according to the source domain pre-trained model parameters, and input the labeled source domain image and the unlabeled target domain image into the source domain feature extractor and the target domain feature extractor respectively to obtain source domain features and target domain features respectively; After assigning domain labels, the source domain features and the target domain features are respectively input into the discriminator for adversarial training, and the discriminator loss and the target domain mapping loss are respectively calculated; Input the target domain features into the source classifier to predict the pseudo label and obtain the pseudo label prediction result; The processing unit is used to construct triple samples for contrastive learning based on the pseudo-label prediction results, calculate the contrast loss, dynamically allocate sample weights to optimize the intra-class aggregation and inter-class separation of the feature space, and update the discriminator using the discriminator loss, and update the target feature extractor using the target domain mapping loss and the contrast loss respectively, update the target domain model, and obtain the image recognition model.

9. A cross-domain underwater image recognition system, characterized in that: include: A memory and a processor, wherein the memory stores a computer program executed by the processor, and when the computer program is executed by the processor, the steps of the cross-domain underwater image recognition method according to any one of claims 1 to 6 are executed.

10. A storage medium, characterized in that: The storage medium stores a computer program, which, when running, executes the steps of the cross-domain underwater image recognition method according to any one of claims 1 to 6.

Citation Information

Cited By

  • Visual recognition method and device based on local region adaptive training enhancement

    CN122368747A