Ship image retrieval method, device, equipment and storage medium

Through the ship image retrieval method based on visual and language models, the image embedding layer and the feature extraction layer are used to extract the target feature vector of the ship image, and combined with the position and class label information, it solves the problem of accurate fine-grained ship image retrieval in the existing technology. Problems with low degree of similarity achieve a higher similarity matching effect.

CN117763182BActive Publication Date: 2024-09-06TSINGHUA SHENZHEN INTERNATIONAL GRADUATE SCHOOL
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311520512.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-11-14
Publication Date
2024-09-06
Estimated Expiration
2043-11-14

AI Technical Summary

Technical Problem

The accuracy of fine-grained ship image retrieval in the existing technology is not high, mainly because the visual measurement model only uses image modal features and cannot effectively measure the similarity between remote sensing images.

Method used

The first vision model is used, which is trained based on the second vision model and language model. It extracts the target feature vector of the ship image through the image embedding layer and feature extraction layer, and combines the position matrix and class label vector for feature extraction to calculate the remote sensing image. Cosine similarity with the target image to improve retrieval accuracy.

Benefits of technology

By combining image and text features, the accuracy of fine-grained ship image retrieval is significantly improved, making the retrieved target ship image more similar to the image to be retrieved, and improving the accuracy of the retrieval results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117763182B
    Figure CN117763182B
Patent Text Reader

Abstract

The present invention relates to the technical field of remote sensing images, and provides a ship image retrieval method, device, equipment and storage medium. The method comprises: obtaining a ship image to be retrieved; using a first visual model, extracting features of the ship image to be retrieved, and obtaining a target feature vector corresponding to the ship image to be retrieved; the first visual model is obtained by training a second visual model and a language model; the model parameters of the first visual model and the second visual model are the same; using the first visual model, extracting features of at least one first remote sensing image respectively, and obtaining first feature vectors corresponding to each first remote sensing image; obtaining a target ship image according to the first feature vectors corresponding to each first remote sensing image and the target feature vector. The target ship image retrieved in the present invention has a higher similarity with the ship image to be retrieved, and the accuracy of fine-grained ship image retrieval is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of remote sensing image technology, and in particular to a ship image retrieval method, device, equipment and storage medium. Background Art

[0002] With the continuous development of space-based ocean monitoring systems, remote sensing (RS) as an important monitoring technology has become the focus of attention. With the increasing number of remote sensing images, retrieving specific target ship images from big data according to people's needs has become an important task. It is widely used in many marine applications, such as national defense security construction, ship monitoring, marine search and rescue, and ship re-identification. However, due to the characteristics of large intra-class differences, small inter-class differences and complex background of ship images, fine-grained ship image retrieval (FGSIR) is a challenging task.

[0003] Fine-grained ship image retrieval refers to the process of giving a specific ship query image and then searching for all other images of the same ship category in a large amount of remote sensing images. The large amount of remote sensing images that need to be retrieved is called a gallery set. In actual application scenarios, not only target ship images are included in the gallery set, but also non-ship background images and other ship type images. Given a specific ship image, all similar images of the same fine-grained category are retrieved in the gallery set. In order to achieve this goal, the model used for fine-grained ship image retrieval needs to be able to measure the similarity between different remote sensing images.

[0004] In the prior art, although many retrieval methods have been applied to fine-grained ship image retrieval in remote sensing, most of the existing methods are based only on vision-based measurement models (VMMs). VMMs usually use a standard pre-trained model as the backbone network (Backbone), and then use a metric learning loss function (such as a triplet loss function) to train and fine-tune the Backbone. During the training process, VMM first maps the image to a high-dimensional feature space through the Backbone, and then reduces the distance between image features of the same category in the high-dimensional feature space, and increases the distance between images of different categories. However, VMM only uses image modality features to measure similarity, resulting in low accuracy in fine-grained ship image retrieval. Summary of the invention

[0005] The present invention provides a ship image retrieval method, device, equipment and storage medium, which are used to solve the defect of low retrieval accuracy in the prior art and improve the accuracy of ship image retrieval.

[0006] In a first aspect, the present invention provides a ship image retrieval method, the method comprising:

[0007] Acquire the ship image to be retrieved;

[0008] Using a first visual model, feature extraction is performed on the ship image to be retrieved to obtain a target feature vector corresponding to the ship image to be retrieved; the first visual model is obtained by training according to a second visual model and a language model; and the model parameters of the first visual model and the second visual model are the same;

[0009] Using the first visual model, respectively extracting features from at least one first remote sensing image to obtain first feature vectors corresponding to each of the first remote sensing images;

[0010] A target ship image is obtained according to the first feature vectors corresponding to each of the first remote sensing images and the target feature vector.

[0011] Optionally, the first visual model includes an image embedding layer and at least one feature extraction layer; and using the first visual model to extract features of the ship image to be retrieved to obtain a target feature vector corresponding to the ship image to be retrieved includes:

[0012] Mapping the to-be-retrieved ship image into a target feature matrix corresponding to the to-be-retrieved ship image using the image embedding layer of the first visual model;

[0013] The target feature matrix and the position matrix corresponding to the target feature matrix are added to obtain an input feature matrix of the first feature extraction layer in the first visual model; the position matrix corresponding to the target feature matrix is ​​obtained according to the position information corresponding to each element in the target feature matrix;

[0014] For any layer of the feature extraction layer, feature extraction is performed on the input feature matrix of the feature extraction layer to obtain the output feature matrix of the feature extraction layer; wherein the input feature matrix of the feature extraction layer of the next layer in the first visual model is the output feature matrix of the feature extraction layer of the previous layer in the first visual model;

[0015] The one-dimensional feature vector corresponding to the class label vector in the output feature matrix of the last feature extraction layer in the first visual model is determined as the target feature vector.

[0016] Optionally, mapping the to-be-retrieved ship image into a target feature matrix corresponding to the to-be-retrieved ship image by using the image embedding layer of the first visual model includes:

[0017] Cutting the ship image to be retrieved into at least one image block;

[0018] For any of the image blocks, using the image embedding layer of the first visual model, mapping the image block into a first vector corresponding to the image block;

[0019] splicing the first vectors corresponding to the image blocks to obtain a second vector corresponding to the ship image to be retrieved;

[0020] The target feature matrix is ​​obtained by concatenating the second vector corresponding to the ship image to be retrieved and the preset class label vector; the preset class label vector is used to indicate the category corresponding to the ship image to be retrieved.

[0021] Optionally, obtaining the target ship image according to the first feature vectors corresponding to each of the first remote sensing images and the target feature vector includes:

[0022] Calculating the cosine similarity between each of the first feature vectors and the target feature vector respectively, and obtaining the cosine similarity value corresponding to each of the first feature vectors;

[0023] The cosine similarity values ​​are arranged in descending order, and the second remote sensing images corresponding to the first preset number of cosine similarity values ​​in the sorting result are determined as the target ship images.

[0024] Optionally, the first visual model is trained by the following steps:

[0025] At least one batch of sample data is collected from an image training set; any batch of sample data includes a first image and a second image in at least one preset category and a class label corresponding to each of the preset categories; the preset category is a ship category;

[0026] For any batch of sample data, using the first visual model, perform feature extraction on the first image to obtain a second feature vector corresponding to the first image;

[0027] Obtaining a second feature matrix according to the second feature vector corresponding to the first image contained in each batch of sample data;

[0028] For any of the batches of sample data, using the second visual model, perform feature extraction on the second image to obtain a third feature vector corresponding to the second image;

[0029] Obtaining a third characteristic matrix according to the third characteristic vectors corresponding to the second images contained in the sample data of each batch;

[0030] For any batch of sample data, using the language model, extracting features of the class label to obtain a fourth feature vector corresponding to the class label;

[0031] Obtaining a fourth characteristic matrix according to fourth characteristic vectors corresponding to class labels contained in each batch of sample data;

[0032] Multiplying the second feature matrix and the third feature matrix to obtain a first similarity matrix;

[0033] Multiplying the second feature matrix and the fourth feature matrix to obtain a second similarity matrix;

[0034] Multiplying the third characteristic matrix and the fourth characteristic matrix to obtain a third similarity matrix;

[0035] Minimize the cross entropy loss in the row and column directions corresponding to the first similarity matrix, the second similarity matrix, and the third similarity matrix respectively;

[0036] When each of the cross entropy losses is a minimum value, the model parameters corresponding to the minimum value of each of the cross entropy losses are determined as the target model parameters of the first visual model.

[0037] Optionally, the first visual model, the second visual model and the language model are constructed based on the Transformer architecture; any of the feature extraction layers includes a multi-head attention layer, a first normalization layer, a fully connected layer and a second normalization layer.

[0038] In a second aspect, the present invention further provides a ship image retrieval device, comprising:

[0039] An acquisition module, used for acquiring the ship image to be retrieved;

[0040] a processing module, configured to extract features of the ship image to be retrieved by using a first visual model, and obtain a target feature vector corresponding to the ship image to be retrieved; the first visual model is obtained by training according to a second visual model and a language model; and the model parameters of the first visual model and the second visual model are the same;

[0041] Using the first visual model, respectively extracting features from at least one first remote sensing image to obtain first feature vectors corresponding to each of the first remote sensing images;

[0042] A target ship image is obtained according to the first feature vectors corresponding to each of the first remote sensing images and the target feature vector.

[0043] In a third aspect, the present invention further provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the ship image retrieval method as described above is implemented.

[0044] In a fourth aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any of the ship image retrieval methods described above.

[0045] In a fifth aspect, the present invention further provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the ship image retrieval method as described above is implemented.

[0046] The present invention provides a ship image retrieval method, device, equipment and storage medium, which obtains a ship image to be retrieved; then, uses a first visual model to extract features of the ship image to be retrieved, and obtains a target feature vector corresponding to the ship image to be retrieved; wherein the first visual model is obtained by training according to a second visual model and a language model, and the model parameters of the first visual model and the second visual model are the same; uses the first visual model to extract features of at least one first remote sensing image, respectively, to obtain first feature vectors corresponding to each first remote sensing image; and then, according to the first feature vectors corresponding to each first remote sensing image and the target feature vector, obtains the target ship image.

[0047] In the present invention, since the first visual model is obtained by training based on the second visual model and the language model, when the first visual model is used to extract image features, the first visual model can be guided to extract the target feature vector of the ship image to be retrieved and the first feature vector corresponding to the remote sensing image respectively based on the image features and the text features, and the feature information represented in the extracted feature vector is more significant; then, based on the first feature vector and the target feature vector corresponding to each remote sensing image, the target ship image is determined, so that the retrieved target ship image has a higher similarity with the ship image to be retrieved, thereby improving the accuracy of fine-grained ship image retrieval. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0049] Figure 1 This is one of the flow charts of the ship image retrieval method provided by the present invention;

[0050] Figure 2 This is the second flow chart of the ship image retrieval method provided by the present invention;

[0051] Figure 3 is a schematic diagram of the structure of the vision and language model provided by the present invention;

[0052] Figure 4 It is a structural schematic diagram of the ship image retrieval device provided by the present invention;

[0053] Figure 5 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0054] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0055] Combine the following Figure 1-Figure 5 The invention describes a ship image retrieval method, device, equipment and storage medium.

[0056] Figure 1 FIG. 1 is one of the flow charts of the ship image retrieval method provided by the present invention. Figure 1 As shown, the method includes:

[0057] Step 101: Acquire a ship image to be retrieved;

[0058] Specifically, the ship image to be retrieved is generally a specific ship query image given, based on which other ship images of the same category as the ship image to be retrieved need to be retrieved in the gallery. It is understandable that the remote sensing images in the gallery include not only a small number of similar target ship images, but also a large number of non-ship background images (Backdrop) and other ship images (Other-Ships).

[0059] Step 102: using the first visual model, extracting features of the ship image to be retrieved, and obtaining a target feature vector corresponding to the ship image to be retrieved; the first visual model is obtained by training according to the second visual model and the language model; the model parameters of the first visual model and the second visual model are the same;

[0060] The first visual model in this embodiment is obtained by training the second visual model and the language model. During the model training process, the ship image is aligned with the corresponding class label, wherein the class label text feature can guide the first visual model to pay more attention to the ship area during the iteration process and establish a hierarchical relationship between ship categories.

[0061] It can be understood that the model parameters of the first visual model and the second visual model are the same, that is, the first visual model and the second visual model share weights, and the effects of extracting features from images using the first visual model and the second visual model are consistent.

[0062] Specifically, the first visual model is used to extract features of the ship image to be retrieved, and a target feature vector corresponding to the ship image to be retrieved is obtained. The final target feature vector of the ship image to be retrieved can be expressed as:

[0063] ;

[0064] in, represents the target feature vector corresponding to the ship image to be retrieved, The vector dimension representing the target feature vector.

[0065] Step 103: using the first visual model, extracting features from at least one first remote sensing image to obtain first feature vectors corresponding to each first remote sensing image;

[0066] Specifically, the first visual model can be used to perform feature extraction on at least one first remote sensing image in the gallery to obtain a first feature vector corresponding to the first remote sensing image. For example, the first feature vector corresponding to the first first remote sensing image is expressed as: ; The first eigenvector corresponding to the second first remote sensing image is expressed as: ; The first eigenvector corresponding to the third first remote sensing image is expressed as: ;in, Vector dimensionality representing the first eigenvector.

[0067] Step 104: Obtain a target ship image according to the first feature vectors corresponding to each first remote sensing image and the target feature vector.

[0068] Specifically, after obtaining the target feature vector corresponding to the ship image to be retrieved and the first feature vector corresponding to each remote sensing image in the gallery, the similarity between each first feature vector and the target feature vector can be calculated. For example, the similarity between each remote sensing image and the ship image to be retrieved is obtained by calculating the cosine similarity between each first feature vector and the target feature vector; further, at least one second remote sensing image with a higher similarity can be determined as the retrieved target ship image.

[0069] In the method provided in this embodiment, a ship image to be retrieved is acquired; then, a first visual model is used to perform feature extraction on the ship image to be retrieved, so as to obtain a target feature vector corresponding to the ship image to be retrieved; wherein, the first visual model is obtained by training according to a second visual model and a language model, and the model parameters of the first visual model and the second visual model are the same; the first visual model is used to perform feature extraction on at least one first remote sensing image, so as to obtain a first feature vector corresponding to each first remote sensing image; and further, according to the first feature vectors corresponding to each first remote sensing image and the target feature vector, the target ship image is obtained.

[0070] In the present invention, since the first visual model is obtained by training based on the second visual model and the language model, when the first visual model is used to extract image features, the first visual model can be guided to extract the target feature vector of the ship image to be retrieved and the first feature vector corresponding to the remote sensing image respectively based on the image features and the text features, and the feature information represented in the extracted feature vector is more significant; then, based on the first feature vector and the target feature vector corresponding to each remote sensing image, the target ship image is determined, so that the retrieved target ship image has a higher similarity with the ship image to be retrieved, thereby improving the accuracy of fine-grained ship image retrieval.

[0071] Optionally, the first visual model includes an image embedding layer and at least one feature extraction layer; using the first visual model, extracting features of the ship image to be retrieved to obtain a target feature vector corresponding to the ship image to be retrieved, including:

[0072] Mapping the to-be-retrieved ship image into a target feature matrix corresponding to the to-be-retrieved ship image using the image embedding layer of the first visual model;

[0073] The target feature matrix and the position matrix corresponding to the target feature matrix are added to obtain the input feature matrix of the first feature extraction layer in the first visual model; the position matrix corresponding to the target feature matrix is ​​obtained according to the position information corresponding to each element in the target feature matrix;

[0074] For any feature extraction layer, feature extraction is performed on the input feature matrix of the feature extraction layer to obtain the output feature matrix of the feature extraction layer; wherein the input feature matrix of the feature extraction layer of the next layer in the first visual model is the output feature matrix of the feature extraction layer of the previous layer in the first visual model;

[0075] The one-dimensional feature vector corresponding to the class label vector in the output feature matrix of the last feature extraction layer in the first visual model is determined as the target feature vector.

[0076] Specifically, the first visual model includes an image embedding layer and at least one feature extraction layer. The image embedding layer is used to map the input ship image to be retrieved into a high-dimensional space, convert it into an input feature matrix, and input it into the feature extraction layer. Each feature extraction layer is used to extract features from the input feature matrix layer by layer to obtain a target feature vector corresponding to the ship image to be retrieved.

[0077] In some embodiments, step 102 may be implemented by:

[0078] First, using the image embedding layer of the first visual model, the ship image to be retrieved is mapped into a target feature matrix corresponding to the ship image to be retrieved. The target feature matrix is, for example, expressed as:

[0079] ;

[0080] in, represents the target feature matrix, Indicates the number of image blocks cut from the ship image to be retrieved, Represents the dimension of the target feature matrix.

[0081] Then, the position matrix corresponding to the target feature matrix can be obtained based on the target feature matrix. The position matrix corresponding to the target feature matrix can be obtained according to the position information corresponding to each element in the target feature matrix. For example, the position matrix corresponding to the target feature matrix is ​​expressed as:

[0082] ;

[0083] in, Represents the position matrix corresponding to the target feature matrix, Indicates the number of image blocks cut from the ship image to be retrieved, Represents the dimension of the target feature matrix. It can be understood that the dimension of the position matrix is ​​the same as the dimension of the target feature matrix.

[0084] Furthermore, the target feature matrix and the position matrix corresponding to the target feature matrix are added to obtain the input feature matrix of the first feature extraction layer in the first visual model: , the process example is as follows:

[0085]

[0086] in, represents the target feature matrix, Respectively represent the first vectors corresponding to each image block contained in each ship image to be retrieved, represents a preset class label vector, which is used to represent the category corresponding to the ship image to be retrieved;

[0087] ;

[0088] in, represents the input feature matrix of the first feature extraction layer in the first visual model, represents the target feature matrix, Represents the position matrix corresponding to the target feature matrix.

[0089] Furthermore, for any feature extraction layer, feature extraction is performed on the input feature matrix of the feature extraction layer to obtain the output feature matrix of the feature extraction layer; wherein the input feature matrix of the next feature extraction layer in the first visual model is the output feature matrix of the previous feature extraction layer in the first visual model. Specifically, after obtaining the input feature matrix of the first feature extraction layer After that, Input to the first feature extraction layer, and get the output feature matrix after the first feature extraction layer , and then Input to the second feature extraction layer to get the output feature matrix , the first visual model contains L feature extraction layers in sequence, where the input feature matrix of the lth submodule is , the output feature matrix is , Represents the output feature matrix of the previous feature extraction layer. The input features of each feature extraction layer are as follows: And the feature extraction layer outputs the feature matrix The dimension size remains unchanged and is always the same as For example, the calling relationship between the input feature matrix and the output feature matrix of each feature extraction layer of the first visual model is shown in the following formula:

[0090] ;

[0091] ;

[0092] in, represents the output feature matrix of the lth feature extraction layer, represents the input feature matrix of the l-1th feature extraction layer (also the The output feature matrix of the feature extraction layer), Represents the output of the first normalization layer plus the input feature matrix of the l-1th feature extraction layer The intermediate result after extraction; l represents the number of feature extraction layers, and the value range is preset to 1-12.

[0093] Furthermore, the one-dimensional feature vector corresponding to the class label vector in the output feature matrix of the last feature extraction layer in the first visual model can be determined as the target feature vector. The one-dimensional feature vector at the position of the class label vector is selected as the final target feature vector of the ship image to be retrieved ,in, Represents the vector dimension of the target feature vector. It can be understood that the one-dimensional feature at the position of the class marker vector in the output feature matrix of the last feature extraction layer is The first row of the feature matrix is ​​the feature vector. In general, the visual model extracts features and maps each image into a one-dimensional feature vector .

[0094] In the method provided in this embodiment, by utilizing the first visual model, feature extraction is performed on the ship image to be retrieved, and a target feature vector corresponding to the ship image to be retrieved is obtained. The target feature vector contains category information corresponding to the ship image to be retrieved, and the accuracy of retrieving the target ship image based on the target feature vector is high.

[0095] Optionally, mapping the to-be-retrieved ship image into a target feature matrix corresponding to the to-be-retrieved ship image using the image embedding layer of the first visual model includes:

[0096] Cutting the ship image to be retrieved into at least one image block;

[0097] For any image block, using the image embedding layer of the first visual model, the image block is mapped into a first vector corresponding to the image block;

[0098] The first vectors corresponding to the image blocks are concatenated to obtain the second vector corresponding to the ship image to be retrieved;

[0099] The second vector corresponding to the ship image to be retrieved and the preset class label vector are concatenated to obtain a target feature matrix; the preset class label vector is used to indicate the category corresponding to the ship image to be retrieved.

[0100] Specifically, in some embodiments, mapping the to-be-retrieved ship image to a target feature matrix corresponding to the to-be-retrieved ship image using the image embedding layer of the first visual model can be achieved by the following steps:

[0101] First, the ship image to be retrieved is cut into at least one image block.

[0102] For example, the ship image to be retrieved is represented as x , where x represents the ship image to be retrieved, H, W are the height and width of the ship image to be retrieved, and C is the number of channels of the ship image to be retrieved; then the ship image to be retrieved is cut according to the preset resolution of each image block, and the preset resolution of each image block is expressed as (P, P), then the number of image blocks can be expressed as: , where M represents the number of image blocks cut from the ship image to be retrieved, H and W are the height and width of the ship image to be retrieved, Indicates the resolution of each image block.

[0103] Then, for any image block, the image block is mapped into a first vector corresponding to the image block using the image embedding layer of the first visual model.

[0104] For example, each image block is flattened and mapped to a vector through an image embedding layer, and the first vector to which the image block is mapped is represented as: ,in, represents the first vector corresponding to the i-th image block in the ship image to be retrieved, and d represents the dimension of the first vector.

[0105] Furthermore, the first vectors corresponding to the image blocks are concatenated to obtain the second vector corresponding to the ship image to be retrieved. For example, the second vector corresponding to the ship image to be retrieved is expressed as: ,in, represents the first vector corresponding to the i-th image block in the ship image to be retrieved, represents the number of image blocks cut from the ship image to be retrieved, and d represents the dimension of the second vector.

[0106] Furthermore, the second vector corresponding to the ship image to be retrieved and the preset class label vector are concatenated to obtain a target feature matrix, wherein the preset class label vector is used to indicate the category corresponding to the ship image to be retrieved.

[0107] For example, in the second vector corresponding to the ship image to be retrieved Concatenate a class label vector in front , and obtain a target feature matrix, expressed as:

[0108] ;

[0109] in, represents the target feature matrix, Indicates the number of image blocks cut from the ship image to be retrieved, Represents the dimension of the target feature matrix.

[0110] In the method provided in this embodiment, the image embedding layer of the first visual model is used to map the ship image to be retrieved into a target feature matrix corresponding to the ship image to be retrieved, and then subsequent feature extraction is performed based on the target feature matrix, and the feature information obtained is relatively accurate.

[0111] Optionally, obtaining a target ship image according to the first feature vectors and the target feature vector corresponding to each first remote sensing image includes:

[0112] Calculate the cosine similarity between each first eigenvector and the target eigenvector respectively, and obtain the cosine similarity value corresponding to each first eigenvector;

[0113] The values ​​of the cosine similarities are arranged in descending order, and the second remote sensing images corresponding to the first preset number of cosine similarity values ​​in the sorting result are determined as the target ship images.

[0114] Specifically, in some embodiments, step 103 may be implemented by the following method:

[0115] First, the cosine similarity between each first feature vector and the target feature vector is calculated respectively to obtain the cosine similarity value corresponding to each first feature vector, wherein cosine similarity is a similarity measurement method used to compare the similarity between two vectors. In this embodiment, cosine similarity is used to represent the similarity between each first feature vector and the target feature vector; it can be understood that other parameters that can be used to represent the similarity between features can also be used to measure the similarity between the ship image to be retrieved and the first remote sensing image, and this embodiment does not limit this.

[0116] Exemplarily, the process of calculating the cosine similarity between the target feature vector corresponding to the ship image to be retrieved and the first feature vector corresponding to the first remote sensing image is as follows:

[0117] First, given the target feature vector q (one-dimensional feature vector) of the ship image to be retrieved and the first feature vector k (one-dimensional feature vector) of the first remote sensing image, the cosine distance The calculation formula is as follows:

[0118] ;

[0119] Where: q represents the target feature vector of the ship image to be retrieved, k represents the first feature vector of the first remote sensing image, " represents the inner product of two vectors, that is, the corresponding elements of the two vectors are multiplied and then added;

[0120] ||q||: represents the norm of the target feature vector q, usually the L2 norm, which represents the length or modulus of the vector.

[0121] ||k||: represents the norm of the first eigenvector k, which is usually the L2 norm and represents the length or modulus of the vector.

[0122] Then, the cosine distance is used to represent the cosine similarity between two vectors. It can be understood that the smaller the cosine distance between two vectors, the higher the cosine similarity between the two vectors.

[0123] It can be understood that the idea of ​​calculating similarity through cosine similarity is to measure the similarity of two vectors by calculating the inner product of them, and then divide the result by the product of their norms to normalize the result. This ensures that the value of the similarity is between -1 and 1, where values ​​closer to 1 indicate that the vectors are more similar, values ​​closer to -1 indicate that the vectors are less similar, and values ​​close to 0 indicate that there is no significant similarity or difference between the vectors. Cosine similarity is often used in image retrieval, text similarity, natural language processing and other fields to measure the similarity between two vectors, thereby helping to find the target image with the highest similarity.

[0124] Then, the values ​​of the cosine similarities are arranged in descending order, and the second remote sensing images corresponding to the first preset number of cosine similarity values ​​in the sorting result are determined as the target ship images. For example, the first five second remote sensing images are determined as the target ship images, or the first three second remote sensing images are determined as the target ship images.

[0125] In the method provided in this embodiment, the cosine similarity between each first feature vector and the target feature vector is calculated respectively to obtain the cosine similarity value corresponding to each first feature vector; then, the cosine similarity values ​​are arranged in descending order, and the second remote sensing images corresponding to the first preset number of cosine similarity values ​​in the sorting result are determined as the target ship image. The target ship image retrieved by the method provided in this embodiment has a high similarity with the ship image to be retrieved, and the accuracy of the retrieval result is high.

[0126] Optionally, the first visual model is trained by the following steps:

[0127] At least one batch of sample data is collected from the image training set; any batch of sample data includes a first image, a second image and a class label corresponding to each preset category in at least one preset category; the preset category is a category of ships;

[0128] For any batch of sample data, using the first visual model, extract features from the first image to obtain a second feature vector corresponding to the first image;

[0129] Obtaining a second feature matrix according to the second feature vector corresponding to the first image contained in each batch of sample data;

[0130] For any batch of sample data, using the second visual model, extracting features from the second image to obtain a third feature vector corresponding to the second image;

[0131] Obtaining a third characteristic matrix according to the third characteristic vector corresponding to the second image contained in each batch of sample data;

[0132] For any batch of sample data, use the language model to extract features of the class label to obtain the fourth feature vector corresponding to the class label;

[0133] A fourth characteristic matrix is ​​obtained according to the fourth characteristic vector corresponding to the class label contained in each batch of sample data;

[0134] Multiply the second feature matrix and the third feature matrix to obtain a first similarity matrix;

[0135] Multiply the second characteristic matrix and the fourth characteristic matrix to obtain a second similarity matrix;

[0136] Multiply the third characteristic matrix and the fourth characteristic matrix to obtain a third similarity matrix;

[0137] Minimize the cross entropy loss in the row and column directions of the first similarity matrix, the second similarity matrix, and the third similarity matrix;

[0138] When each cross entropy loss is a minimum value, the model parameters corresponding to the minimum value of each cross entropy loss are determined as the target model parameters of the first visual model.

[0139] Specifically, in some embodiments, the first visual model is trained by the following steps:

[0140] First, at least one batch of sample data is collected from the image training set; the purpose of training the first visual model is to make the first visual model a highly discriminative model, which encourages the features of similar fine-grained category images to be close in the feature space and pushes the features of different categories apart.

[0141] To achieve this, how to sample batches of sample data, such as mini-batches, from the image training set D is very important during the training process. Figure 2FIG. 2 is a flow chart of the ship image retrieval method provided by the present invention. Figure 2 As shown, the class balanced sampling method of the balanced sampler can be used to collect data from the image training set. After sampling, each batch of sample data contains a first image, a second image in at least one preset category, and a class label corresponding to each preset category, wherein the preset category is a ship category, and the ship category includes 8 base categories and 25 fine-grained categories, and each base class contains several fine-grained categories, such as 1 ship, 2 ships, 3 ships, 4 ships, etc.

[0142] Exemplarily, the batch sample data after sampling is expressed as:

[0143] ;

[0144] in, Represents a batch of sample data collected, represents the first image in the jth image category, represents the second image in the jth image category, represents the class label corresponding to the jth preset category, and n represents the total number of preset categories. It can be understood that in the sample data of a batch of size n, the image categories of n groups of samples are different from each other.

[0145] Optionally, data enhancement can be performed on the sample data of each batch. The advantage of data enhancement is that it is more convenient to extract feature information of the sample data.

[0146] For example, the sample data The data is input to the image enhancement module. The image enhancement module uses a data enhancement method based on RandAugment, and adds horizontal and vertical flipping on the basis of RandAugment to obtain the sample data after image enhancement, which is expressed as follows:

[0147] ;

[0148] in, represents the first enhanced image in the jth image category, represents the enhanced second image in the j-th image category, and n represents the total number of preset categories.

[0149] For another example, the text data class labels in the sample data are extended with label prompts, such as:

[0150] The label hint extension method is used to convert discrete class label names The prompt sentence is represented as: "a remote sensing image of {label}, a type of ship", where label represents the class label, so as to obtain the sample data after text enhancement. .

[0151] Furthermore, the sample data of the batch can be Input into the first visual model, the second visual model and the third visual model respectively for model training:

[0152] The first step is to input the first image (or the enhanced first image) into the first visual model for any batch of sample data, and use the first visual model to extract features of the first image to obtain a second feature vector corresponding to the first image;

[0153] For example, first, the first image is cut into at least one first image block, and then each of the first image blocks is mapped into a vector using the image embedding layer of the first visual model, and the vectors mapped into the first image blocks are spliced ​​to obtain a vector corresponding to the first image; then, the vector corresponding to the first image is input into at least one feature extraction layer in the first visual model, and features of the first image are extracted using each feature extraction layer in the first visual model to obtain a second feature vector corresponding to the first image. , It can be expressed as:

[0154] ;

[0155] in, represents the second eigenvector corresponding to the jth first image, Represents the dimension of the second eigenvector corresponding to the j-th first image.

[0156] In the second step, the second feature matrix is ​​obtained according to the second feature vector corresponding to the first image contained in each batch of sample data. The second feature matrix can be expressed as:

[0157] ;

[0158] in, represents the second eigenvector corresponding to the jth first image, represents the dimension of the second feature vector corresponding to the first image, and n represents the total number of batches of batch sample data, that is, the total number of first images.

[0159] The third step is to input the second image (or the enhanced second image) into the second visual model for any batch of sample data, and use the second visual model to extract features from the second image to obtain the third feature vector corresponding to the second image. The obtained third feature vector can be expressed as:

[0160] ;

[0161] in, represents the third eigenvector corresponding to the jth second image, represents the dimension of the third eigenvector.

[0162] The fourth step is to obtain the third characteristic matrix according to the third characteristic vector corresponding to the second image contained in each batch of sample data. The third characteristic matrix can be expressed as:

[0163]

[0164] in, represents the third eigenvector corresponding to the jth second image, represents the dimension of the second feature vector corresponding to the second image, and n represents the total number of batches of batch sample data, that is, the total number of second images.

[0165] The fifth step is to input the class label (the prompt sentence corresponding to the class label) into the language model for any batch of sample data. The language model is used to extract the features of the class label to obtain the fourth feature vector corresponding to the class label. The fourth feature vector can be expressed as:

[0166] ;

[0167] in, represents the fourth eigenvector corresponding to the j-th class label, represents the dimension of the fourth eigenvector.

[0168] The sixth step is to obtain the fourth characteristic matrix according to the fourth characteristic vector corresponding to the class label contained in each batch of sample data. The fourth characteristic matrix can be expressed as:

[0169]

[0170] in, represents the fourth eigenvector corresponding to the j-th class label, represents the dimension of the fourth eigenvector, and n represents the total number of batches of batch sample data, that is, the total number of class labels.

[0171] It can be understood that the language model is also a Transfomer architecture. The difference between the process of obtaining the fourth eigenvector using the language model and obtaining the second eigenvector using the first visual model and obtaining the third eigenvector using the first visual model is that a word input by the language model is equivalent to an image block in the visual model, and other operations are the same, which will not be repeated here.

[0172] Furthermore, after obtaining the second feature matrix, the third feature matrix and the fourth feature matrix corresponding to the batch of sample data, the second feature matrix, the third feature matrix and the fourth feature matrix can be further used to calculate the similarity to measure the correlation between the label text and the ship image. Considered as a training set D The sampled k The size is n The batch sample data of k The size is n After feeding the model with batch sample data, the following three regularized visual and text feature matrices are output . It can be understood that during the model training process, the parameters of the language model are frozen, and the main goal is to train the first visual model. In the k-th batch sample data of size n, the distance between similar ships is minimized while maximizing the distance between dissimilar ships. In order to guide the measurement of visual features, in the k-th batch sample data of size n, the text features with higher semantics are used as the center point to attract the visual features of the corresponding category and push away the unmatched visual features. In order to achieve this training goal, contrast loss such as cross entropy loss can be used to achieve it. An example of the process of similarity calculation is as follows:

[0173] In the first step, the second feature matrix corresponding to the first image and the third feature matrix corresponding to the second image are multiplied to obtain a first similarity matrix. Figure 2 As shown, the second feature matrix corresponding to the first image The third characteristic matrix corresponding to the second image Multiply to get the first similarity matrix , the first similarity matrix is an n×n similarity matrix, which represents the number of preset categories contained in the batch of sample data.

[0174] In the second step, the second feature matrix corresponding to the first image and the fourth feature matrix corresponding to the class label are multiplied to obtain a second similarity matrix; for example, Figure 2 As shown, the second eigenvector corresponding to the first image The fourth eigenvector corresponding to the class label Multiply to get the second similarity matrix , the second similarity matrix is an n×n similarity matrix, which represents the number of preset categories contained in the batch of sample data.

[0175] In the third step, the third feature matrix corresponding to the second image and the fourth feature matrix corresponding to the class label are multiplied to obtain a third similarity matrix; for example, Figure 2 As shown, the third characteristic matrix corresponding to the second image The fourth feature matrix corresponding to the class label Multiply to get the third similarity matrix , the third similarity matrix is an n×n similarity matrix, which represents the number of preset categories contained in the batch of sample data.

[0176] The fourth step is to minimize the cross entropy loss in the row and column directions of the first similarity matrix, the second similarity matrix, and the third similarity matrix. Specifically, taking the first similarity matrix as an example, the first similarity matrix An example of contrastive loss on is as follows:

[0177] ;

[0178] in, Represents the first similarity matrix The cross entropy loss in the row direction, n is the number of preset categories in the batch sample data, i and j represent the index in the batch sample data of size n, represents the image features of the i-th first image, represents the image features of the i-th second image, represents the image features of the j-th second image, Represents the similarity value between the image feature of the i-th first image and the image feature of the i-th second image. The similarity value is the image feature of the i-th first image. and the image features of the i-th second image The inner product (dotproduct), It is the preset temperature parameter, which is a positive number and is used to adjust the scale of the similarity value to make the scale function smoother.

[0179] ;

[0180] in, Represents the first similarity matrix The cross entropy loss in the column direction, n is the number of preset categories in the batch sample data, i and j represent the index in the batch sample data of size n, represents the image features of the i-th second image, represents the image features of the i-th first image, represents the image features of the j-th first image, Represents the similarity value between the image feature of the i-th second image and the image feature of the i-th first image. The similarity value is the image feature of the i-th second image. and the image features of the i-th first image The inner product (dotproduct), It is the preset temperature parameter, which is a positive number and is used to adjust the scale of the similarity value to make the scale function smoother.

[0181] The first similarity matrix The goal of the contrastive loss on is to maximize the similarity value of the positive sample pairs and minimize the similarity values ​​of other sample pairs. The positive sample pair refers to the first image and the second image in the same preset category.

[0182] Similarly, the second similarity matrix An example of contrastive loss on is as follows:

[0183] ;

[0184] in, Represents the second similarity matrix The cross entropy loss in the row direction, n is the number of preset categories in the batch sample data, i and j represent the index in the batch sample data of size n, represents the image features of the i-th first image, express The i-th prompt sentence text feature in express The j-th prompt sentence text feature in Represents the similarity value between the image feature of the i-th first image and the text feature of the i-th prompt sentence. The similarity value is the image feature of the i-th first image. and the text features of the i-th prompt sentence The dot product, It is the preset temperature parameter, which is a positive number and is used to adjust the scale of the similarity value to make the loss function smoother.

[0185] ;

[0186] in, Represents the second similarity matrix The cross entropy loss in the column direction, n is the number of preset categories in the batch sample data, i and j represent the index in the batch sample data of size n, express The i-th prompt sentence text feature in represents the image features of the i-th first image, represents the image features of the j-th first image, Represents the text features of the i-th prompt sentence The similarity value of the image feature of the i-th first image is the text feature of the i-th prompt sentence. and the image features of the i-th first image The dot product, It is the preset temperature parameter, which is a positive number and is used to adjust the scale of the similarity value to make the loss function smoother.

[0187] The second similarity matrix The goal of the contrast loss on is to maximize the similarity value of the positive sample pair and minimize the similarity values ​​of other sample pairs. The positive sample pair refers to the category corresponding to the second image in the same preset category and the class label prompt sentence.

[0188] Similarly, the contrast loss on the third similarity matrix is ​​similar and will not be described here.

[0189] Finally, the total loss can be calculated as:

[0190] ;

[0191] in, Represents the final loss function, which is obtained by adding the above contrast losses.

[0192] In the fifth step, when each cross entropy loss is a minimum value, the model parameters corresponding to the minimum value of each cross entropy loss are determined as the target model parameters of the first visual model.

[0193] In the method provided in this embodiment, at least one batch of sample data is collected from the image training set, and the target model parameters of the first visual model are obtained by training the second visual model and the language model according to the sample data of each batch. By aligning the ship image with the corresponding class label, the class label text feature can guide the first visual model to pay more attention to the ship area in the iterative process, and establish a hierarchical relationship between ship categories, so as to extract features and retrieve the target ship image using the trained first visual model, and the retrieval accuracy is high.

[0194] Optionally, the first visual model, the second visual model and the language model are constructed based on the Transformer architecture; any feature extraction layer includes a multi-head attention layer, a first normalization layer, a fully connected layer and a second normalization layer.

[0195] Specifically, in some embodiments, the first visual model, the second visual model and the language model are constructed based on the Transformer architecture; for example, the first visual model, the second visual model are constructed based on the VisionTransformer architecture, the language model is constructed based on the Transformer architecture, and the first visual model, the second visual model and the language model are pre-trained on the CLIP dataset.

[0196] For example, the first visual model includes an image embedding layer and at least one feature extraction layer. Any feature extraction layer includes a multi-head self-attention layer (MSA), a first normalization layer (LN), a fully connected layer (MLP) and a second normalization layer (LN). Among them, the multi-head self-attention layer MSA is one of the core components in Transformer, which is used to capture the relationship between different positions in the input sequence; the first normalization layer is a technique for reducing internal covariate drift during neural network training; the fully connected layer MLP is a feedforward neural network consisting of two linear transformations (fully connected layers) and a nonlinear activation function; the second normalization LN layer is similar to the first normalization LN layer, and is used to standardize the output of the fully connected layer MLP to maintain the stability of the first visual model.

[0197] For example, Figure 3 It is a schematic diagram of the structure of the visual and language model provided by the present invention, such as Figure 3 As shown in the figure, the structure of the visual model includes from bottom to top: image embedding layer and L-layer feature extraction layer. Each feature extraction layer includes a multi-head attention layer (MSA), a first normalization layer (LN), a fully connected layer (MLP) and a second normalization layer (LN). The input image is converted into the input feature matrix of the feature extraction layer through the image embedding layer.

[0198] Similarly, the structure of the language model from bottom to top includes: image embedding layer and L-layer feature extraction layer, each feature extraction layer includes multi-head attention layer (MSA), first normalization layer (LN), fully connected layer (MLP) and second normalization layer (LN). The input class label text information is converted into the input feature matrix of the feature extraction layer through the image embedding layer.

[0199] In the method provided in this embodiment, the first visual model, the second visual model and the language model are constructed based on the Transformer architecture, wherein any feature extraction layer includes a multi-head attention layer, a first normalization layer, a fully connected layer and a second normalization layer. The feature information of the feature vector extracted based on the first visual model is sufficient.

[0200] The ship image retrieval device provided by the present invention is described below. The ship image retrieval device described below and the ship image retrieval method described above can be referred to each other.

[0201] Figure 4 FIG. 4 is a schematic diagram of the structure of a ship image retrieval device 400 provided by the present invention. Figure 4 As shown, the device comprises:

[0202] An acquisition module 410 is used to acquire a ship image to be retrieved;

[0203] The processing module 420 is used to extract features of the ship image to be retrieved by using the first visual model to obtain a target feature vector corresponding to the ship image to be retrieved; the first visual model is obtained by training according to the second visual model and the language model; the model parameters of the first visual model and the second visual model are the same;

[0204] Using the first visual model, respectively extracting features from at least one first remote sensing image to obtain first feature vectors corresponding to each of the first remote sensing images;

[0205] A target ship image is obtained according to the first feature vectors corresponding to each of the first remote sensing images and the target feature vector.

[0206] In the device provided by this embodiment, the acquisition module 410 acquires the ship image to be retrieved; then, the processing module 420 uses the first visual model to extract features of the ship image to be retrieved, and obtains the target feature vector corresponding to the ship image to be retrieved; wherein, the first visual model is obtained by training according to the second visual model and the language model, and the model parameters of the first visual model and the second visual model are the same; using the first visual model, feature extraction is performed on at least one first remote sensing image respectively, and the first feature vector corresponding to each first remote sensing image is obtained; and then, according to the first feature vectors corresponding to each first remote sensing image and the target feature vector, the target ship image is obtained.

[0207] In the present invention, since the first visual model is obtained by training based on the second visual model and the language model, when the first visual model is used to extract image features, the first visual model can be guided to extract the target feature vector of the ship image to be retrieved and the first feature vector corresponding to the remote sensing image respectively based on the image features and the text features, and the feature information represented in the extracted feature vector is more significant; then, based on the first feature vector and the target feature vector corresponding to each remote sensing image, the target ship image is determined, so that the retrieved target ship image has a higher similarity with the ship image to be retrieved, thereby improving the accuracy of fine-grained ship image retrieval.

[0208] Optionally, the first visual model includes an image embedding layer and at least one feature extraction layer;

[0209] The processing module 420 is specifically used for:

[0210] Mapping the to-be-retrieved ship image into a target feature matrix corresponding to the to-be-retrieved ship image using the image embedding layer of the first visual model;

[0211] The target feature matrix and the position matrix corresponding to the target feature matrix are added to obtain an input feature matrix of the first feature extraction layer in the first visual model; the position matrix corresponding to the target feature matrix is ​​obtained according to the position information corresponding to each element in the target feature matrix;

[0212] For any layer of the feature extraction layer, feature extraction is performed on the input feature matrix of the feature extraction layer to obtain the output feature matrix of the feature extraction layer; wherein the input feature matrix of the feature extraction layer of the next layer in the first visual model is the output feature matrix of the feature extraction layer of the previous layer in the first visual model;

[0213] The one-dimensional feature vector corresponding to the class label vector in the output feature matrix of the last feature extraction layer in the first visual model is determined as the target feature vector.

[0214] Optionally, the processing module 420 is further configured to:

[0215] Cutting the ship image to be retrieved into at least one image block;

[0216] For any of the image blocks, using the image embedding layer of the first visual model, mapping the image block into a first vector corresponding to the image block;

[0217] splicing the first vectors corresponding to the image blocks to obtain a second vector corresponding to the ship image to be retrieved;

[0218] The target feature matrix is ​​obtained by concatenating the second vector corresponding to the ship image to be retrieved and the preset class label vector; the preset class label vector is used to indicate the category corresponding to the ship image to be retrieved.

[0219] Optionally, the processing module 420 is further configured to:

[0220] Calculating the cosine similarity between each of the first feature vectors and the target feature vector respectively, and obtaining the cosine similarity value corresponding to each of the first feature vectors;

[0221] The cosine similarity values ​​are arranged in descending order, and the second remote sensing images corresponding to the first preset number of cosine similarity values ​​in the sorting result are determined as the target ship images.

[0222] Optionally, the device further comprises a model training module;

[0223] The model training module is used to:

[0224] At least one batch of sample data is collected from an image training set; any batch of sample data includes a first image and a second image in at least one preset category and a class label corresponding to each of the preset categories; the preset category is a ship category;

[0225] For any batch of sample data, using the first visual model, perform feature extraction on the first image to obtain a second feature vector corresponding to the first image;

[0226] Obtaining a second feature matrix according to the second feature vector corresponding to the first image contained in each batch of sample data;

[0227] For any of the batches of sample data, using the second visual model, perform feature extraction on the second image to obtain a third feature vector corresponding to the second image;

[0228] Obtaining a third characteristic matrix according to the third characteristic vectors corresponding to the second images contained in the sample data of each batch;

[0229] For any batch of sample data, using the language model, extracting features of the class label to obtain a fourth feature vector corresponding to the class label;

[0230] Obtaining a fourth characteristic matrix according to fourth characteristic vectors corresponding to class labels contained in each batch of sample data;

[0231] Multiplying the second feature matrix and the third feature matrix to obtain a first similarity matrix;

[0232] Multiplying the second feature matrix and the fourth feature matrix to obtain a second similarity matrix;

[0233] Multiplying the third characteristic matrix and the fourth characteristic matrix to obtain a third similarity matrix;

[0234] Minimize the cross entropy loss in the row and column directions corresponding to the first similarity matrix, the second similarity matrix, and the third similarity matrix respectively;

[0235] When each of the cross entropy losses is a minimum value, the model parameters corresponding to the minimum value of each of the cross entropy losses are determined as the target model parameters of the first visual model.

[0236] Optionally, the first visual model, the second visual model and the language model are constructed based on the Transformer architecture; any of the feature extraction layers includes a multi-head attention layer, a first normalization layer, a fully connected layer and a second normalization layer.

[0237] Figure 5 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 5 As shown, the electronic device may include: a processor 510, a communication interface 520, a memory 530 and a communication bus 540, wherein the processor 510, the communication interface 520 and the memory 530 communicate with each other through the communication bus 540. The processor 510 may call the logic instructions in the memory 530 to execute the ship image retrieval method, which includes:

[0238] Acquire the ship image to be retrieved;

[0239] Using a first visual model, feature extraction is performed on the ship image to be retrieved to obtain a target feature vector corresponding to the ship image to be retrieved; the first visual model is obtained by training according to a second visual model and a language model; and the model parameters of the first visual model and the second visual model are the same;

[0240] Using the first visual model, respectively extracting features from at least one first remote sensing image to obtain first feature vectors corresponding to each of the first remote sensing images;

[0241] A target ship image is obtained according to the first feature vectors corresponding to each of the first remote sensing images and the target feature vector.

[0242] In addition, the logic instructions in the above-mentioned memory 530 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.

[0243] On the other hand, the present invention further provides a computer program product, the computer program product includes a computer program, the computer program can be stored in a non-transitory computer-readable storage medium, when the computer program is executed by a processor, the computer can execute the ship image retrieval method provided by the above methods, the method includes:

[0244] Acquire the ship image to be retrieved;

[0245] Using a first visual model, feature extraction is performed on the ship image to be retrieved to obtain a target feature vector corresponding to the ship image to be retrieved; the first visual model is obtained by training according to a second visual model and a language model; and the model parameters of the first visual model and the second visual model are the same;

[0246] Using the first visual model, respectively extracting features from at least one first remote sensing image to obtain first feature vectors corresponding to each of the first remote sensing images;

[0247] A target ship image is obtained according to the first feature vectors corresponding to each of the first remote sensing images and the target feature vector.

[0248] In another aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the ship image retrieval method provided by the above methods is implemented, and the method includes:

[0249] Acquire the ship image to be retrieved;

[0250] Using a first visual model, feature extraction is performed on the ship image to be retrieved to obtain a target feature vector corresponding to the ship image to be retrieved; the first visual model is obtained by training according to a second visual model and a language model; and the model parameters of the first visual model and the second visual model are the same;

[0251] Using the first visual model, respectively extracting features from at least one first remote sensing image to obtain first feature vectors corresponding to each of the first remote sensing images;

[0252] A target ship image is obtained according to the first feature vectors corresponding to each of the first remote sensing images and the target feature vector.

[0253] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0254] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0255] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A ship image retrieval method, It is characterized in that include: Acquire the ship image to be retrieved; Using a first visual model, extracting features of the ship image to be retrieved, and obtaining a target feature vector corresponding to the ship image to be retrieved; the first visual model is obtained by training based on the second visual model and the language model; The model parameters of the first visual model and the second visual model are the same; The first visual model includes an image embedding layer and at least one feature extraction layer; The step of extracting features of the ship image to be retrieved by using the first visual model to obtain a target feature vector corresponding to the ship image to be retrieved includes: Mapping the to-be-retrieved ship image into a target feature matrix corresponding to the to-be-retrieved ship image using the image embedding layer of the first visual model; The target feature matrix and the position matrix corresponding to the target feature matrix are added to obtain an input feature matrix of the first feature extraction layer in the first visual model; the position matrix corresponding to the target feature matrix is ​​obtained according to the position information corresponding to each element in the target feature matrix; For any layer of the feature extraction layer, feature extraction is performed on the input feature matrix of the feature extraction layer to obtain the output feature matrix of the feature extraction layer; wherein the input feature matrix of the feature extraction layer of the next layer in the first visual model is the output feature matrix of the feature extraction layer of the previous layer in the first visual model; Determine the one-dimensional feature vector corresponding to the class label vector in the output feature matrix of the last feature extraction layer in the first visual model as the target feature vector; Using the first visual model, respectively extracting features from at least one first remote sensing image to obtain first feature vectors corresponding to each of the first remote sensing images; Obtaining a target ship image according to the first feature vectors corresponding to each of the first remote sensing images and the target feature vector; The first visual model is trained by the following steps: At least one batch of sample data is collected from an image training set; any batch of sample data includes a first image and a second image in at least one preset category and a class label corresponding to each of the preset categories; the preset category is a ship category; For any batch of sample data, using the first visual model, perform feature extraction on the first image to obtain a second feature vector corresponding to the first image; Obtaining a second feature matrix according to the second feature vector corresponding to the first image contained in each batch of sample data; For any of the batches of sample data, using the second visual model, perform feature extraction on the second image to obtain a third feature vector corresponding to the second image; Obtaining a third characteristic matrix according to the third characteristic vectors corresponding to the second images contained in the sample data of each batch; For any batch of sample data, using the language model, extracting features of the class label to obtain a fourth feature vector corresponding to the class label; Obtaining a fourth characteristic matrix according to fourth characteristic vectors corresponding to class labels contained in each batch of sample data; Multiplying the second feature matrix and the third feature matrix to obtain a first similarity matrix; Multiplying the second feature matrix and the fourth feature matrix to obtain a second similarity matrix; Multiplying the third characteristic matrix and the fourth characteristic matrix to obtain a third similarity matrix; Minimize the cross entropy loss in the row and column directions corresponding to the first similarity matrix, the second similarity matrix, and the third similarity matrix respectively; When each of the cross entropy losses is a minimum value, the model parameters corresponding to the minimum value of each of the cross entropy losses are determined as the target model parameters of the first visual model.

2. The ship image retrieval method according to claim 1, It is characterized in that The using the image embedding layer of the first visual model to map the to-be-retrieved ship image into a target feature matrix corresponding to the to-be-retrieved ship image includes: Cutting the ship image to be retrieved into at least one image block; For any of the image blocks, using the image embedding layer of the first visual model, mapping the image block into a first vector corresponding to the image block; splicing the first vectors corresponding to the image blocks to obtain a second vector corresponding to the ship image to be retrieved; The target feature matrix is ​​obtained by concatenating the second vector corresponding to the ship image to be retrieved and the preset class label vector; the preset class label vector is used to indicate the category corresponding to the ship image to be retrieved.

3. The ship image retrieval method according to claim 1, It is characterized in that The step of obtaining a target ship image according to the first feature vectors corresponding to each of the first remote sensing images and the target feature vector comprises: Calculating the cosine similarity between each of the first feature vectors and the target feature vector respectively, and obtaining the cosine similarity value corresponding to each of the first feature vectors; The cosine similarity values ​​are arranged in descending order, and the second remote sensing images corresponding to the first preset number of cosine similarity values ​​in the sorting result are determined as the target ship images.

4. The ship image retrieval method according to any one of claims 1 to 3, It is characterized in that The first visual model, the second visual model and the language model are constructed based on the Transformer architecture; any of the feature extraction layers includes a multi-head attention layer, a first normalization layer, a fully connected layer and a second normalization layer.

5. A ship image retrieval device, It is characterized in that include: An acquisition module, used for acquiring the ship image to be retrieved; A processing module, configured to extract features of the ship image to be retrieved by using a first visual model to obtain a target feature vector corresponding to the ship image to be retrieved; the first visual model is obtained by training based on the second visual model and the language model; The model parameters of the first visual model and the second visual model are the same; the first visual model includes an image embedding layer and at least one feature extraction layer; The method of using the first visual model to extract features from the ship image to be retrieved to obtain a target feature vector corresponding to the ship image to be retrieved includes: using the image embedding layer of the first visual model to map the ship image to be retrieved into a target feature matrix corresponding to the ship image to be retrieved; adding the target feature matrix and the position matrix corresponding to the target feature matrix to obtain an input feature matrix of the first feature extraction layer in the first visual model; the position matrix corresponding to the target feature matrix is ​​obtained according to the position information corresponding to each element in the target feature matrix; for any layer of the feature extraction layer, extracting features from the input feature matrix of the feature extraction layer to obtain an output feature matrix of the feature extraction layer; wherein the input feature matrix of the feature extraction layer of the next layer in the first visual model is the output feature matrix of the feature extraction layer of the previous layer in the first visual model; determining the one-dimensional feature vector corresponding to the class label vector in the output feature matrix of the feature extraction layer of the last layer in the first visual model as the target feature vector; Using the first visual model, respectively extracting features from at least one first remote sensing image to obtain first feature vectors corresponding to each of the first remote sensing images; Obtaining a target ship image according to the first feature vectors corresponding to each of the first remote sensing images and the target feature vector; A model training module is used to collect at least one batch of sample data from an image training set; any batch of sample data includes a first image and a second image in at least one preset category and a class label corresponding to each preset category; the preset category is a ship category; for any batch of sample data, using the first visual model, feature extraction is performed on the first image to obtain a second feature vector corresponding to the first image; according to the second feature vector corresponding to the first image contained in each batch of sample data, a second feature matrix is ​​obtained; for any batch of sample data, using the second visual model, feature extraction is performed on the second image to obtain a third feature vector corresponding to the second image; according to the third feature vector corresponding to the second image contained in each batch of sample data, a third feature matrix is ​​obtained; for any batch of sample data, The method comprises the following steps: extracting features of the class label by using the language model and obtaining a fourth feature vector corresponding to the class label according to the fourth feature vector corresponding to the class label contained in each batch of sample data; obtaining a fourth feature matrix according to the fourth feature vector corresponding to the class label contained in each batch of sample data; multiplying the second feature matrix and the third feature matrix to obtain a first similarity matrix; multiplying the second feature matrix and the fourth feature matrix to obtain a second similarity matrix; multiplying the third feature matrix and the fourth feature matrix to obtain a third similarity matrix; minimizing the cross entropy loss in the row and column directions corresponding to the first similarity matrix, the second similarity matrix and the third similarity matrix respectively; and when each cross entropy loss is a minimum value, determining the model parameters corresponding to each minimum cross entropy loss as the target model parameters of the first visual model.

6. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the computer program, the ship image retrieval method according to any one of claims 1 to 4 is implemented.

7. A non-transitory computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the ship image retrieval method according to any one of claims 1 to 4 is implemented.

8. A computer program product comprising a computer program, It is characterized in that When the computer program is executed by a processor, the ship image retrieval method according to any one of claims 1 to 4 is implemented.

Citation Information

Patent Citations

  • Feature extraction model training method, image retrieval method, device and equipment

    CN113536003A

  • Image processing method and device, storage medium and terminal

    CN116128784A