Image retrieval method and related equipment thereof

By extracting and matching feature vectors through the target image retrieval model, the efficiency of image retrieval and the generalization of the model are achieved, and the problem of high resource consumption in the existing technology is solved.

CN118535756AInactive Publication Date: 2024-08-23GUANGDONG AOPUTE TECH CO LTD

Patent Information

Application Number
CN202410533313.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-04-29
Publication Date
2024-08-23
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Existing image retrieval methods require customized artificial intelligence models for specific detection requirements, resulting in huge consumption of computing resources and limiting the generalization and versatility of the models.

Method used

The target prompt feature vector to be retrieved is extracted through the image feature extraction network in the target image retrieval model, the matching retrieval category is determined from the pre-registered prompt feature vector set of multiple retrieval categories, and in the original retrieval image of the target retrieval category Retrieve target prompts small pictures to achieve image retrieval.

Benefits of technology

The image retrieval efficiency is improved, and through the management of pre-registered prompt feature vector sets, the need to retrain the model is avoided, and the generalization ability and versatility of the model are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118535756A
    Figure CN118535756A
Patent Text Reader

Abstract

The invention discloses an image retrieval method and related equipment thereof, and aims to solve the problem of huge resource consumption caused by the fact that an existing image retrieval method needs to customize a corresponding artificial intelligence model for a specific detection demand to realize a specific image retrieval demand. The method comprises the following steps: extracting a target prompt feature vector of a target prompt small image to be retrieved through an image feature extraction network in a target image retrieval model; determining a target retrieval category corresponding to a prompt feature vector matched with the target prompt feature vector from a prompt feature vector set pre-registered with prompt feature vectors corresponding to a plurality of retrieval categories; and by using the target prompt feature vector as prompt information through the target image retrieval model, retrieving the target prompt small image in a retrieval original image corresponding to the target retrieval category to obtain an image retrieval result of the target prompt small image in the retrieval original image corresponding to the target retrieval category.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and in particular to an image retrieval method, device, electronic device, storage medium and computer program product. Background Art

[0002] In the industrial field, product category perception retrieval and detection technology refers to analyzing the image to be detected based on the prompt image block, and then searching for the image area with the same semantic information as the prompt image block in the image to be detected. The prompt image block can be a local area that includes the same semantic information, such as a folding defect in the battery cell tab area or a screw hole on the surface of the workpiece in the area of ​​interest. This technology can be applied to a variety of downstream task scenarios, such as: retrieval of similar workpieces or partially similar workpieces, quality inspection of product surfaces, and other scenarios. In the early days, the above-mentioned product category perception retrieval and detection related tasks were completed manually, but it is obvious that it only relies on the judgment of the human eye, which is prone to problems such as fatigue and subjective judgment errors. In recent years, with the popularization of deep learning technology in machine vision applications, more and more companies have adopted deep learning-based visual systems to replace or assist manual labor to complete the above tasks.

[0003] Deep learning technology can accurately analyze and measure the details, colors, and defects on the surface of products through algorithms and models to ensure the consistency and stability of product quality. However, when dealing with a variety of visual demand tasks, deep learning algorithms need to retrain the corresponding artificial intelligence models based on the product categories and defect categories that need to be detected in the scenes corresponding to various demand tasks, and then deploy the corresponding artificial intelligence models in different detection demand scenarios. In other words, the existing image retrieval methods need to customize the corresponding artificial intelligence models according to specific detection needs to achieve specific image retrieval needs. Obviously, this consumes a lot of computing resources and is not conducive to the generalization and versatility of artificial intelligence models in the field of image retrieval. Summary of the invention

[0004] The embodiment of the present application provides an image retrieval method to solve the problem that the existing image retrieval method needs to customize the corresponding artificial intelligence model according to the specific detection requirements to achieve specific image retrieval requirements, thereby causing huge resource consumption.

[0005] Embodiments of the present application also provide an image retrieval device, an electronic device, a computer-readable storage medium, and a computer program product.

[0006] The present application embodiment adopts the following technical solutions:

[0007] In a first aspect, the present application provides an image retrieval method, comprising:

[0008] Extracting a target cue feature vector of a target cue thumbnail to be retrieved through an image feature extraction network in a target image retrieval model;

[0009] Determining a target retrieval category corresponding to a prompt feature vector that matches the target prompt feature vector from a prompt feature vector set that is pre-registered with prompt feature vectors corresponding to a plurality of retrieval categories;

[0010] The target image retrieval model uses the target prompt feature vector as prompt information to retrieve the target prompt thumbnail in the retrieval original image corresponding to the target retrieval category, and obtains an image retrieval result of the target prompt thumbnail in the retrieval original image corresponding to the target retrieval category.

[0011] In a second aspect, the present application provides an image retrieval device, comprising:

[0012] A feature extraction module, used to extract a target cue feature vector of a target cue thumbnail to be retrieved through an image feature extraction network in a target image retrieval model;

[0013] A category determination module, for determining a target retrieval category corresponding to a prompt feature vector matching the target prompt feature vector from a prompt feature vector set pre-registered with prompt feature vectors corresponding to a plurality of retrieval categories;

[0014] An image retrieval module is used to retrieve the target hint sub-image in the retrieval original image corresponding to the target retrieval category through the target image retrieval model using the target hint feature vector as hint information, and obtain an image retrieval result of the target hint sub-image in the retrieval original image corresponding to the target retrieval category.

[0015] In a third aspect, the present application provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the steps in the image retrieval method described above when executed by the processor.

[0016] In a fourth aspect, the present application provides a computer-readable storage medium, characterized in that a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the steps in the image retrieval method as described above are implemented.

[0017] In a fifth aspect, the present application provides a computer program product, including a computer program, which implements the steps in the image retrieval method as described above when executed by a processor.

[0018] At least one of the above technical solutions adopted in the embodiments of the present application can achieve the following beneficial effects:

[0019] By adopting the method provided by the embodiment of the present application, the target prompt feature vector of the target prompt thumbnail to be retrieved is extracted through the image feature extraction network in the target image retrieval model; the target retrieval category corresponding to the prompt feature vector matching the target prompt feature vector is determined from the prompt feature vector set in which the prompt feature vectors corresponding to multiple retrieval categories are pre-registered; the target image retrieval model uses the target prompt feature vector as the prompt information to retrieve the target prompt thumbnail in the retrieval original image corresponding to the target retrieval category, and the image retrieval result of the target prompt thumbnail in the retrieval original image corresponding to the target retrieval category can be obtained. On the one hand, the image retrieval efficiency can be effectively improved. On the other hand, since the prompt feature vector set has the prompt feature vectors corresponding to multiple retrieval categories pre-registered, and these prompt feature vectors are also extracted by the image feature extraction network in the target image retrieval model, the addition and deletion operations can be performed according to the needs, and the retrieval category of the target image retrieval model can be changed, and there is no need to retrain the target retrieval model according to the new retrieval requirements, which effectively improves the generalization ability and versatility of the target image retrieval model. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0021] Figure 1 A schematic diagram of an implementation flow of an image retrieval method provided in an embodiment of the present application;

[0022] Figure 2 A schematic diagram of the registration process of a thumbnail feature vector in the image retrieval method provided in an embodiment of the present application;

[0023] Figure 3 A schematic diagram of a process for deleting a feature vector of a small image in an image retrieval method provided in an embodiment of the present application;

[0024] Figure 4 A schematic diagram of the process of adding a prompt thumbnail feature vector in the image retrieval method provided in an embodiment of the present application;

[0025] Figure 5 A schematic diagram of a process of applying the image retrieval method provided in an embodiment of the present application to an actual scenario;

[0026] Figure 6 A schematic diagram of post-processing of image retrieval results in the image retrieval method provided in an embodiment of the present application;

[0027] Figure 7 A schematic diagram of an exemplary process in the image retrieval method provided in an embodiment of the present application;

[0028] Figure 8 A schematic diagram of the structure of an image retrieval network provided in an embodiment of the present application;

[0029] Fig. 9 A schematic diagram of the input and output of an image feature extraction network in an image retrieval network provided in an embodiment of the present application;

[0030] Fig.10 A schematic diagram of the process of training an image retrieval network based on a public dataset and an industrial dataset provided in an embodiment of the present application;

[0031] Fig.11 A schematic diagram of the structure of an image retrieval device provided in an embodiment of the present application;

[0032] Fig.12 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

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

[0034] The technical solutions provided by various embodiments of the present application are described in detail below in conjunction with the accompanying drawings.

[0035] At present, the existing image retrieval method needs to customize the corresponding artificial intelligence model according to the specific detection requirements to achieve specific image retrieval requirements, and frequent model training will cause huge consumption of computing resources. The embodiment of the present application provides an image retrieval method to solve this problem.

[0036] The execution subject of the method may be various types of computing devices, or an application or application (Application, APP) installed on the computing device. The computing device may be, for example, a user terminal such as a mobile phone, a tablet computer, a smart wearable device, or a server.

[0037] For ease of description, the present application embodiment takes the execution subject of the method as an example of a server to introduce the method. Those skilled in the art can understand that the present application embodiment takes the server as an example to introduce the method, which is only an exemplary description and does not limit the scope of protection of the claims corresponding to the present solution.

[0038] First, the terms involved in one or more embodiments of the present application are explained.

[0039] ROI: The full name of ROI is Region of Interest. In deep learning, a common application is to use convolutional neural networks for object detection. When processing images or videos, the network needs to identify objects in the image, and usually, it is only interested in some specific areas of the image, not the entire image. This specific area can be called ROI.

[0040] Mask: The English name is mask. It uses a selected image, graphic or object to block the processed image (all or part) to control the area or process of image processing. The specific image or object used for covering is called a mask or template. The mask is a binary image composed of 0 and 1. When a mask is applied to a function, the 1-value area is processed, and the masked 0-value area is not included in the calculation. The image mask is defined by specifying data values, data ranges, finite or infinite values, areas of interest, and annotation files. Any combination of the above options can also be used as input to establish a mask. A mask is a template for an image filter. For example, in product quality inspection under machine vision scenarios, when extracting surface defects of products, an N*N matrix is ​​used to filter the image pixels, and then the marks we need are highlighted. This matrix is ​​a kind of mask.

[0041] Image segmentation: The technology and process of dividing an image into several specific regions with unique properties and proposing objects of interest. It is a key step from image processing to image analysis. Existing image segmentation methods are mainly divided into the following categories: threshold-based segmentation methods, region-based segmentation methods, edge-based segmentation methods, and segmentation methods based on specific theories, such as deep learning. From a mathematical point of view, image segmentation is the process of dividing a digital image into non-overlapping regions. The image segmentation process is also a labeling process, that is, pixels belonging to the same region are assigned the same number.

[0042] Specifically, the implementation process of the method provided in the embodiment of the present application is as follows: Figure 1 As shown, the following steps are included:

[0043] Step 110 , extracting a target prompt feature vector of the target prompt thumbnail to be retrieved through an image feature extraction network in the target image retrieval model.

[0044] The method of obtaining the target prompt thumbnail may include:

[0045] Get the target hint thumbnail from the local area of ​​the specified image; or,

[0046] Get multiple hint thumbnails from the image segmentation result of the specified image as multiple target hint thumbnails.

[0047] Alternatively, the target prompt thumbnail may also be a defect image used for defect detection.

[0048] For a given target hint thumbnail Pro_Imgs, the image feature extraction network Pro_Net in the target image retrieval model can be used to extract its target hint feature vector Pro_Fs.

[0049] Step 120 , determining a target retrieval category corresponding to a prompt feature vector that matches a target prompt feature vector from a prompt feature vector set that has pre-registered prompt feature vectors corresponding to a plurality of retrieval categories.

[0050] Wherein, determining the target retrieval category corresponding to the prompt feature vector matching the target prompt feature vector from the prompt feature vector set pre-registered with prompt feature vectors corresponding to multiple retrieval categories comprises:

[0051] determining a similarity between a target cue feature vector and each cue feature vector in a set of cue feature vectors;

[0052] When the similarity between the target prompt feature vector and one or several prompt feature vectors in the prompt feature vector set is greater than a preset similarity threshold, the target retrieval category corresponding to the prompt feature vector having the similarity greater than the preset similarity threshold is determined.

[0053] Optionally, the method provided in the embodiment of the present application further includes:

[0054] If there is no cue feature vector matching the target cue feature vector in the set of pre-registered cue feature vectors, assigning a retrieval category to the target cue feature vector;

[0055] Based on the assigned retrieval category, registering the target cue feature vector in a set of pre-registered cue feature vectors;

[0056] A search category library corresponding to the assigned search category is established, and a search original image corresponding to the search category is assigned to the search category library.

[0057] Figure 2 A schematic diagram of the registration process of the prompt thumbnail feature vector in the image retrieval method provided in the embodiment of the present application. If there is no prompt feature vector matching the target prompt feature vector in the pre-registered prompt feature vector set, the target prompt feature vector can be registered in the prompt feature vector set Reg_Set through the feature vector registration module. During registration, an ID can be assigned to the target prompt feature vector, which corresponds to a retrieval category.

[0058] Among them, a retrieval category library corresponding to the assigned retrieval category is established, and a retrieval original image corresponding to the retrieval category is assigned to the retrieval category library. Specifically, the target image retrieval model can be used to take the target prompt feature vector as a prompt to search for the retrieval original image containing the target prompt feature vector and the corresponding confidence score in all the retrieval original images; then based on the confidence score, the retrieval original image most likely to contain the target prompt thumbnail is screened out from the retrieval original image containing the target prompt feature vector, and added to the retrieval category library corresponding to the assigned retrieval category.

[0059] As an example, for each prompt thumbnail Pro_Imgs, the image feature extraction network Pro_Net can extract features to obtain a 1×256 prompt feature vector Pro_Fs, and then match the feature vector Pro_Fs with each Pro_Fs in the feature vector set Reg_Set to select the ID number of the search category contained in the prompt thumbnail Pro_Imgs. If only one ID number is matched, it means that the prompt thumbnail contains one search category, and if multiple ID numbers are matched, it means that the prompt thumbnail contains multiple search categories.

[0060] As an example, the feature vector registration module can also be used to update the prompt feature vector registered in the feature vector set Reg_Set. For each type of search category that needs to be searched, the corresponding prompt feature vector Pro_Fs can be generated by the image feature extraction network Pro_Net, and the feature vector set Reg_Set is the feature vector set of all search categories. Among them, updating the feature vector set Reg_Set can include deleting and adding search categories.

[0061] For example, the search category can be deleted, and the feature vector set Reg_Set(R N×(1×256) ) has an ID for each category to be searched, and the feature vector set Reg_Set(R N×(1×256) ) in any search category, and obtain a new feature vector set Reg_Set_New(R (N-1)×(1×256) ). Figure 3 A schematic diagram of the process of deleting a small image feature vector in the image retrieval method provided in an embodiment of the present application.

[0062] Alternatively, the target prompt feature vector Pro_Fs can be added to the feature vector set Reg_Set (where Reg_Set∈R (N×(1×256) )), N represents the number of search categories. Figure 4 This is a schematic diagram of the process of adding a small image feature vector in the image retrieval method provided in the embodiment of the present application. Figure 4As shown in FIG. 1 , when adding a retrieval category, the image feature extraction network Pro_Net can be used to extract the target prompt feature vector Pro_Fs of the target prompt thumbnail Pro_Img to be added, and then the target prompt feature vector Pro_Fs is calculated with the existing feature vectors in the feature vector set for similarity S, and a threshold T is set. If there is a similarity S≤T with any existing feature vector, the target prompt feature vector Pro_Fs is considered to correspond to a new retrieval category, and the feature vector registration module is used to add it to the feature vector set Reg_Set (R N×(1×256) ), we get the new feature vector set Reg_Set_New(R (N+1)×(1×256) ).

[0063] Step 130, using the target image retrieval model and the target prompt feature vector as prompt information, retrieves the target prompt thumbnail in the retrieval original image corresponding to the target retrieval category, and obtains an image retrieval result of the target prompt thumbnail in the retrieval original image corresponding to the target retrieval category.

[0064] Specifically, Figure 5 A flowchart of the image retrieval method provided in the embodiment of the present application applied in an actual scenario. Given a target hint thumbnail Def_Images of an image to be retrieved, the ID number of the target retrieval category contained in the target hint thumbnail Def_Images can be first queried based on the pre-registered feature vector set Reg_Set, and then the query original image Obj_Images corresponding to the target retrieval category can be obtained by conditional query of the target image retrieval model Mat_Net. The deep features and shallow features of the query original image Obj_Images corresponding to the target retrieval category are extracted by the image encoder of the target image retrieval model; then, the deep features and shallow features of the retrieval original image are fused by the feature fusion module of the target image retrieval model to obtain the image feature vector of the retrieval original image; finally, the mask decoder is used to retrieve the image mask result Obj_Mask and the confidence score (i.e., the score in the figure) from the image feature vector using the target hint thumbnail feature vector as a hint.

[0065] Based on the confidence score, the obtained image mask result Obj_Mask is preliminarily screened. If the score is low, the image mask result Obj_Mask is considered invalid. After the preliminary screening, the image mask result Obj_Mask is post-processed to filter out irrelevant segmentation areas to obtain the final predicted segmentation mask Mask. Figure 6 A schematic diagram of post-processing of image retrieval results in the image retrieval method provided in an embodiment of the present application.

[0066] As an example, when obtaining a target hint thumbnail from a local area of ​​a specified image, an image similar to the target in the hint thumbnail can be retrieved from the image set Search_Set to be retrieved based on the given target hint thumbnail. Specifically, a local image of a given specified image can be used as a hint thumbnail Pro_Imgs, and the corresponding feature vector Pro_Fs is first generated through Pro_Net; based on whether the feature hint vector has a corresponding class prototype ID number in the feature vector set Reg_Set, if the corresponding class prototype ID exists, the search image corresponding to the ID number is returned; otherwise, Pro_Fs is added to the feature vector set Reg_Set, and the images of Search_Set are retrieved in sequence based on Mat_Net, and the specified number of images and predicted confidence scores are returned and saved.

[0067] As an example, the image retrieval method provided in the embodiment of the present application can also be applied to defect detection tasks. Specifically, the defect detection task can be given a defect image as a target prompt thumbnail, and according to the target prompt thumbnail, an image with the same defect class as the target prompt thumbnail is retrieved from the image set Search_Set to be retrieved, and the defect area is segmented and the confidence score of the prediction is obtained.

[0068] For example, a defect image can be given as the target prompt thumbnail Pro_Imgs. The image block contains certain defect classes to be queried. First, the corresponding target prompt feature vector Pro_Fs is generated through Pro_Net, and the ID number of the corresponding defect category is matched in the feature vector set Reg_Set. According to the ID number, the image consistent with the defect category in the target prompt thumbnail is retrieved in the retrieval original image data set Search_Set, and the defect area is segmented out, and the corresponding prediction score (i.e., confidence score) is assigned to the area.

[0069] Optionally, the image retrieval method provided in the embodiment of the present application can also retrieve objects contained in the prompt thumbnails belonging to multiple retrieval categories from a search original image. Specifically, when multiple prompt thumbnails are obtained from the image segmentation result of the specified image as multiple target prompt thumbnails, the method provided in the embodiment of the present application also includes:

[0070] Extracting multiple target prompt feature vectors corresponding to multiple target prompt thumbnails through an image feature extraction network in a target image retrieval model;

[0071] Using a target image retrieval model, multiple target prompt feature vectors are used as prompts to determine multiple image retrieval results corresponding to multiple target prompt thumbnails in the target retrieval original image;

[0072] The multiple image retrieval results are fused to obtain the image retrieval results of multiple target prompt thumbnails in the target retrieval original image.

[0073] As an example, the image retrieval task can be to decompose a given retrieval image Img into multiple target prompt thumbnails Pro_Imgs, and then calculate the category masks and corresponding confidence scores of the multiple target prompt thumbnails and the retrieval original image Search_Img according to the retrieval results of the multiple target prompt thumbnails. The figure is a schematic diagram of an exemplary process in the image retrieval method provided in the embodiment of the present application, which may include:

[0074] Step 1: Using the SAM model, set the coordinates of M*N points in the prompt encoder, generate M*N segmentation masks in the decoder, and then use the non-maximum suppression algorithm to filter out masks with high overlap and low confidence.

[0075] Step 2, select a specified number of regions of interest Pro_Imgs manually or through rules.

[0076] Among them, manual selection is to manually select the local image area that best represents the whole image based on the SAM segmentation result. Rule selection is to sort by area and select the local image area corresponding to the middle distribution of area.

[0077] Step 3, based on Mat_Net, calculate the retrieval results (mask representation) mP of the retrieval Search_Img and the selected prompt local thumbnail Pro_Img one by one. For the mP whose retrieval score is greater than the preset threshold, record the array into mPs.

[0078] Step 4, merge and process all the search results mPs to obtain Pre_Mask.

[0079] Step 5, define the similarity Sim between the search image Img and the image to be searched as the ratio of Pre_Mask to 1. The calculation formula is: Sim(Img,Search_Img)=Sum(Pre_Mask) / H*W

[0080] Among them, H and W are the height and width of the original search image Search_Img, respectively, and Sum(Pre_Mask) is the area sum of the segmented mask.

[0081] Step 6, return the original search image Search_Img, similarity Sim and the corresponding search result Pre_Mask.

[0082] In some exemplary embodiments, the training process of the target image retrieval model includes:

[0083] Acquire a segmentation task dataset, the segmentation task dataset comprising a prompt image dataset and a to-be-retrieved image dataset; wherein the prompt image dataset comprises a prompt thumbnail containing multiple categories, and annotation information based on the category information of the prompt thumbnail of the multiple categories; the to-be-retrieved image dataset comprises an original image to be retrieved containing multiple categories, a category label mask image corresponding to the prompt thumbnail of the multiple categories, and annotation information based on the category information of the original image to be retrieved of the multiple categories;

[0084] Based on multiple categories of hint thumbnails, and annotation information based on category information of multiple categories of hint thumbnails, as well as multiple categories of original images to be retrieved, category label mask images corresponding to multiple categories of hint thumbnails, and annotation information based on category information of multiple categories of original images to be retrieved, an image feature extraction network and a mask decoder in a pre-constructed image retrieval network are trained to obtain a target image retrieval model.

[0085] The source of the segmentation task dataset can include two parts. One part is the industrial dataset, which collects characteristic images Ind_Data in industrial scenes, including 2 million images of industries such as 3C, lithium battery, semiconductor, and food. The collected images can be divided by product type, and the images of each product type are annotated according to project experience and actual project requirements. The other part is the public dataset, which can be a commercially available public dataset for image segmentation, including public datasets for natural scenes, biology, medical, and industrial scenes.

[0086] For industrial scenario datasets, they are divided by product category, and each product category is a sub-training set Sub_Train_Set. For example, threaded hole thread defect detection, 3319 sand hole detection, etc. For commercially available public datasets, they can be divided according to the actual dataset form, and each dataset is a sub-training set Sub_Train_Set.

[0087] Then, each sub-training set Sub_Train_Set is integrated. Specifically, first, for each sub-training set Sub_Train_Set, a category label mask image, category information, and a corresponding original image can be constructed; wherein the category label mask image is a mask showing the area where the target object corresponding to the category information is located in the original image, and the category information is the category information determined based on the category of the object in the mask area. Then, each sub-training set is further integrated into two categories, including a prompt image dataset (Pro_Set) and a to-be-searched image dataset (Search_Set).

[0088] Among them, the prompt image dataset Pro_Set is composed of multiple categories of prompt thumbnails Pro_Img (i.e., the circumscribed rectangular area of ​​the target object of interest) and the category information Pro_Label of each prompt thumbnail (the category information is the labeling information of the prompt thumbnail). The image set to be searched Search_Set is composed of multiple categories of search original images Ori_Img, the category label mask image GT_Mask corresponding to each search original image, and the category information Pro_Label (the category information is the labeling information of the search original image). The shape of the mask area of ​​the category label mask image GT_Mask corresponding to each search original image is consistent with the shape of the target object corresponding to the category information of the prompt thumbnail in the prompt thumbnail matching each search original image.

[0089] The pre-built image retrieval network is composed of an image feature extraction network, and an image encoder and a mask decoder of an image segmentation network. As an example, the image segmentation network can be constructed based on a segmentation model SAM.

[0090] Optionally, to improve the training efficiency of the image retrieval network, the network parameters of the image encoder of the image segmentation network are not changed during the training process of the pre-built image retrieval network.

[0091] Normally, the mask decoder of the SAM large model will generate valid masks of three different sizes: small, medium, and large, according to the prompt information (English name: Prompt Token). Therefore, the mask decoder of the SAM large model has four outputs, namely three valid masks of different sizes and their confidence scores. Subsequently, the SAM large model is required to select the mask that best meets the requirements as the result for model training based on the confidence score of each mask. For subsequent segmentation tasks, the three different valid masks are all uncertain masks, and generating uncertain masks will increase the computational complexity of the training model to a certain extent.

[0092] Based on this, the embodiment of the present application improves the output of the mask decoder, that is, the mask decoder of the SAM large model will generate a unique and definite mask and a corresponding confidence score according to the prompt token. In other words, the generated valid masks of three different sizes, small, medium and large, are screened according to the confidence score inside the mask decoder to select a unique and definite mask and a corresponding confidence score.

[0093] Figure 8 An exemplary structural diagram of an image retrieval network provided in an embodiment of the present application. Figure 8In the image retrieval network, Pro_Net is an image feature extraction network, Image Encoder is an image segmentation network, and Mask Decoder is an image encoder. The image feature extraction network Pro_Net is used to extract features from the input hint thumbnail Pro_Img, and obtain the hint thumbnail feature vector Pro_Fs of the hint thumbnail Pro_Img. The hint thumbnail feature vector Pro_Fs has a dimension of 1×256, and is input into the Mask Decoder as a hint of the image segmentation network. The Image Encoder is used to perform feature encoding on the input retrieval original image B_Ori_Img to obtain the deep features and shallow features of the retrieval original image.

[0094] like Figure 8 As shown in the figure, the mask decoder uses the prompt small image feature vector Pro_Fs as a prompt (Prompt Token) and outputs an Output Token including a Mask Token and an IOU Token corresponding to the Mask Token. Among them, the Mask Token is the image mask result B_GT_Mask, and the IOU Token corresponds to the score of the image mask result.

[0095] Since the image encoder Image Encoder performs feature encoding on the retrieval original image B_Ori_Img, it will go through multiple layers of convolution, resulting in an increase in the receptive field, that is, some local information will be lost after obtaining a large amount of total information. In order to avoid this problem, the embodiment of the present application adds a global-local fusion module (Global-local Fusion) between the image encoder Image Encoder and the mask decoder Mask Decoder, referred to as a feature fusion module, which is used to fuse the deep features and shallow features of the retrieval original image output by the image encoder ImageEncoder to obtain the image feature vector of the retrieval original image. Finally, the mask decoder Mask Decoder is used to retrieve the image mask result Pre_Mask and the confidence score Output Score from the image feature vector using the prompt small image feature vector Pro_Fs as a prompt.

[0096] Specifically, the image segmentation network also includes a feature fusion module; wherein the image feature extraction network is used to extract a hint thumbnail feature vector from the input hint thumbnail, and input it into the mask decoder as a hint of the image segmentation network;

[0097] The image encoder is used to perform feature encoding on the input retrieval original image to obtain the deep features and shallow features of the retrieval original image; the feature fusion module is used to fuse the deep features and shallow features of the retrieval original image to obtain the image feature vector of the retrieval original image; the mask decoder is used to retrieve the image mask result and confidence score from the image feature vector using the hint thumbnail feature vector as a hint.

[0098] In order to improve the training efficiency of the image retrieval network Mat_Net, the embodiment of the present application can train Pro_Net as an independent image feature extraction network separately, and train the mask decoder Mask_Decoder network separately. Among them, the image encoder Image Encoder of the SAM large model often occupies most of the parameters of SAM. This module can use the public pre-trained weights and does not participate in the training of the image retrieval network Mat_Net. Therefore, the image retrieval network Mat_Net only trains the network weights corresponding to the two modules of the image feature extraction network Pro_Net and the mask decoder Mask_Decoder.

[0099] As an example, the image feature extraction network Pro_Net can be designed based on a conventional deep convolutional neural network suitable for image classification tasks, and its backbone network includes but is not limited to lightweight classification network structures such as LeNet, ResNet18, and MobileNet. The image feature extraction network Pro_Net is usually very applicable. It does not fix the input size, and can use a multi-layer convolutional network to realize high-level feature extraction of images, and map the input prompt small image into a 1×256 feature vector representation based on the fully connected layer through adaptive pooling. Therefore, compared with the training of the large model SAM, the amount of data and computational cost relied on for the training of the two modules of the image feature extraction network Pro_Net and the mask decoder Mask_Decoder are greatly reduced, thereby further ensuring the feasibility of the implementation of the embodiments of the present application.

[0100] Fig. 9 This is a schematic diagram of the input and output of the image feature extraction network in the image retrieval network provided in the embodiment of the present application. Fig. 9 In the example, the prompt thumbnail Pro_Img is input to the image feature extraction network Pro_Net, and the multi-layer convolutional network realizes the high-level feature extraction of the image. The input prompt thumbnail is mapped into a 1×256 prompt thumbnail feature vector Pro_Fs based on the fully connected layer through adaptive pooling, and is input into the mask decoder of the image segmentation network as the prompt information Prompt Token. Specifically, the image feature extraction network is designed based on the deep convolutional network used for image classification tasks;

[0101] Among them, the backbone network of the image feature extraction network is a lightweight classification network. The image feature extraction network is used to extract high-level features of the input image and map the extracted high-level features into a 1×256 feature vector representation.

[0102] As an exemplary embodiment, the image feature extraction network and the mask decoder in the pre-built image retrieval network are trained to obtain a target image retrieval model, including:

[0103] A positive sample dataset and a negative sample dataset are constructed based on the segmentation task dataset, wherein the positive sample dataset is composed of multiple positive sample pairs, and the negative sample dataset is composed of multiple negative sample pairs; a positive sample pair is composed of a retrieval original image, a category mask image of the retrieval original image, a hint thumbnail matching the retrieval original image, and category information of the hint thumbnail matching the retrieval original image; a negative sample pair is composed of a retrieval original image, a category mask image of the retrieval original image, a hint thumbnail not matching the retrieval original image, and category information of the hint thumbnail not matching the retrieval original image;

[0104] Based on the positive sample data set and the score labels corresponding to each positive sample pair in the positive sample data set, as well as the negative sample data set and the score labels corresponding to each negative sample pair in the negative sample data set, the image feature extraction network and the mask decoder in the image retrieval network are trained to obtain the target image retrieval model.

[0105] Among them, the score label corresponding to the positive sample is 1, and the score label corresponding to the negative sample is 0.

[0106] As an exemplary embodiment, based on the positive sample data set and the score labels corresponding to each positive sample pair in the positive sample data set, and the negative sample data set and the score labels corresponding to each negative sample pair in the negative sample data set, the image feature extraction network and the mask decoder in the image retrieval network are trained to obtain a target image retrieval model, including:

[0107] Based on the image retrieval prediction results and category mask labels corresponding to each positive sample pair in the positive sample data set, the segmentation loss corresponding to each positive sample pair is determined, and based on the score labels and confidence scores corresponding to each positive sample pair in the positive sample data set, the confidence loss corresponding to each positive sample pair is determined;

[0108] Based on the image retrieval prediction results and category mask labels corresponding to each negative sample pair in the negative sample data set, determining the segmentation loss corresponding to each negative sample pair, and based on the score labels and confidence scores corresponding to each negative sample pair in the negative sample data set, determining the confidence loss corresponding to each negative sample pair;

[0109] Based on the segmentation loss and confidence loss corresponding to each positive sample pair, as well as the segmentation loss and confidence loss corresponding to each negative sample pair, the network parameters of the image feature extraction network and the mask decoder in the image retrieval network are updated by gradient backpropagation to obtain the target image retrieval model.

[0110] Among them, the confidence loss Loss_Conf can consider the Cross Emtropy Loss, and its calculation formula is as follows:

[0111] Loss_Conf(p,q)=-∑(plogq+(1-p)log(1-q))

[0112] Where p is the confidence score and q is the score label (0 or 1).

[0113] The segmentation loss Loss_Seg comprehensively considers the two losses of Dice Loss and Focal loss, and its calculation formula is as follows:

[0114] Loss_Seg=λ1Dice(Gt,Preds)+λ2Focal(Gt,Preds)

[0115]

[0116]

[0117] Among them, Gt is the category mask label image B_GT_Mask.

[0118] Finally, the confidence loss Loss_Conf and the segmentation loss Loss_Seg are weighted and summed to obtain the total loss for gradient backpropagation to update the network parameters of the image segmentation network. The calculation formula is as follows:

[0119] Loss=ε1Loss_Conf+ε2Loss_Seg

[0120] Among them, ε1 and ε2 are the corresponding weights respectively.

[0121] Optionally, in order to make full use of public datasets and industrial datasets, the segmentation task dataset includes public datasets and industrial datasets, and the image feature extraction network and mask decoder in the pre-built image retrieval network are trained to obtain a target image retrieval model, including:

[0122] Based on the public dataset, the image feature extraction network and the mask decoder in the pre-built image retrieval network are trained to obtain the first target image retrieval model;

[0123] Based on the industrial dataset, the image feature extraction network and mask decoder in the first target image retrieval model are trained to obtain the target image retrieval model.

[0124] Fig.10 A schematic diagram of the process of training an image retrieval network based on a public dataset and an industrial dataset provided in an embodiment of the present application. Fig.10 As shown, the public pre-trained model model_pre (i.e., the pre-built image retrieval network) can be first trained based on the public data set. Specifically, the image feature extraction network Pro_Net can be first trained based on the public data set, and then the mask decoder Mask_Decoder can be trained based on the public data set, and then the image feature extraction network Pro_Net (whose network parameters are obtained by the aforementioned training based on the public training set) and the mask decoder Mask_Decoder (whose network parameters are obtained by the aforementioned training based on the public training set) can be trained based on the public data set, and finally the model weight model_pub of the first target image retrieval model obtained by the training based on the public data set can be obtained. Then, the first target image retrieval model is trained based on the industrial data set. Specifically, the image feature extraction network Pro_Net can be first trained based on the industrial data set, and then the mask decoder Mask_Decoder can be trained based on the industrial data set, and then the image feature extraction network Pro_Net (whose network parameters are obtained by the aforementioned training based on the industrial training set) and the mask decoder Mask_Decoder (whose network parameters are obtained by the aforementioned training based on the industrial training set) can be trained based on the industrial data set, and finally the model weight model_Ind of the second target image retrieval model obtained by the training based on the industrial data set can be obtained.

[0125] As an example, the process of training the image feature extraction network and the mask decoder in the pre-built image retrieval network to obtain the target image retrieval model may include:

[0126] S21, performing parameter initialization operation on the image feature extraction network and mask decoder in the pre-built image retrieval network. Specifically, the network parameters of the image feature extraction network Pro_Net can be randomly initialized, and the network parameters of the image encoder Image_Encoder and mask decoder Mask_Decoder modules of the image retrieval network Mat_Net can be initialized using pre-trained weights.

[0127] S22, train the image retrieval network Mat_Net using the public segmentation dataset. Each subset Sub_Train_Set of the public segmentation dataset consists of a prompt image dataset (Pro_Set) and a to-be-searched image dataset (Search_Set). The prompt image dataset Pro_Set consists of a prompt thumbnail Pro_Img and category information Pro_Label, and the to-be-searched image dataset Search_Set consists of a search original image Ori_Img and a corresponding category label mask image GT_Mask of the search original image Pro_Img, and category information Pro_Label.

[0128] The category information in the image dataset to be retrieved corresponds to the category information in the prompt image dataset. The category label mask image in the image dataset to be retrieved corresponds to the mask image of the prompt thumbnail in the prompt image dataset.

[0129] As an example, the number of training rounds of the image retrieval network can be set to 300. For each training batch in each round, the data collection and training method may include the following steps:

[0130] S221, randomly select B prompt thumbnails Pro_Img and their corresponding category information Pro_Label from the prompt image data set (Pro_Set), and randomly perform data enhancement operations on the prompt thumbnails Pro_Img. The data enhancement operations include but are not limited to blurring, color jittering, scaling, and other operations. Finally, merge all prompt thumbnails Pro_Img and category information Pro_Label to form an enhanced prompt thumbnail set B_Pro_Img and its corresponding enhanced category information set B_Pro_Label.

[0131] S222, according to the category information Pro_Label of each prompt thumbnail, select the search original image Ori_Img and the category label mask GT_Mask corresponding to the search original image in the search image data set Search_Set. For example, if the category information of the selected prompt thumbnail is a, then all the search original images with category information a and the category label mask corresponding to the search original image are found.

[0132] For each training batch, each prompt thumbnail corresponds to a retrieval original image, so a total of B retrieval original images and category label masks GT_Mask need to be selected. There need to be K retrieval original images that contain the category information that appears in the prompt thumbnail, so that the retrieval original image and its corresponding prompt thumbnail form a positive sample pair, and another BK images do not contain the category that appears in the prompt thumbnail, so that the retrieval original image and its corresponding prompt thumbnail form a negative sample pair. Finally, all selected retrieval original images Ori_Img and category label masks GT_Mask are merged to form the retrieval original image set B_Ori_Img and category label mask set B_GT_Mask for this training.

[0133] S223, each hint thumbnail B_Pro_Img in the enhanced hint thumbnail set is used as the input of the image feature extraction network Pro_Net to generate the corresponding feature vector Pro_Fs, and Pro_Fs is then used as the hint input of the image segmentation network. The mask decoder of the image segmentation network generates a unique and definite mask Pre_Mask and its confidence score IOU as the OutPut Token of the image segmentation network.

[0134] S224, using the image encoder of the image segmentation network to perform feature encoding on the original image B_Ori_Img, considering that after multiple layers of convolution, the receptive field increases, and some local information will be lost after obtaining a large amount of global information. In order to capture local detail information, the embodiment of the present application introduces a feature fusion module to fuse the deep features and shallow features of the image encoder of the image segmentation network to obtain a feature vector F.

[0135] S225, using the mask decoder of the image segmentation network, decode the feature vector Pro_Fs and the image feature vector F to obtain the prediction result Preds and the score IOU Score.

[0136] S226, calculate the loss value Loss_Seg based on the prediction result Preds and the category mask label B_GT_Mask, and calculate the loss value Loss_Conf based on the confidence score and the score label {0,1}. As mentioned in S222, if the selected retrieval original image and its corresponding hint small image form a positive sample pair, then its score label is 1, otherwise it is 0. The total loss is calculated by weighted summing the two losses, and the network weights of the image retrieval network Mat_Net are updated by gradient backpropagation.

[0137] S227, different training methods are adopted based on different training rounds.

[0138] As an example, S227 may include:

[0139] Step 1, 0 to 150 rounds, use the public dataset to train the image feature extraction network Pro_Net module of the image retrieval network Mat_Net, while fixing the network parameters of other modules, and only update the Pro_Net network weights in the gradient backpropagation method.

[0140] Step 2, 151 to 240 rounds, use the public dataset to train the mask decoder Mask_Decoder module of the image retrieval network Mat_Net network, while fixing the network parameters of other modules, and only updating the Mask_Decoder network weights in the gradient backpropagation method.

[0141] Step 3, 241 to 300 rounds, use the public data set to train the mask decoder Mask_Decoder of the image retrieval network Mat_Net and the image feature extraction network Pro_Net module, while fixing the network parameters of the Image_Encoder module, and updating the network weights of the mask decoder Mask_Decoder and the image feature extraction network Pro_Net simultaneously in the gradient backpropagation method.

[0142] Step 4: After training, save the model weights. The weights can be used for category-aware image retrieval and detection tasks in natural scenes, biology, medical care, industry, etc., and can also be used as pre-training weights for the image retrieval network Mat_Net to train industrial segmentation datasets.

[0143] Among them, the training parameters of each round are: training steps N_inter, batch size B, optimizer Adam, learning rate Lr=0.001, Cosine Decay learning rate update strategy, and network input size is 1024*1024.

[0144] S23, train the Mat_Net network using the industrial segmentation dataset.

[0145] Use the training weights obtained in S22 to initialize the Pro_Net, Image_Encoder and Mask_Decoder modules of Mat_Net. Set the network training rounds to 200. For each training batch in each round, there are 7 steps in data collection and training. Steps 1-6 replace the data set with the industrial segmentation data set. The rest of the operations are the same as in S52. Step 7 uses different training methods based on different training rounds:

[0146] S231, 0~80 rounds, use the industrial segmentation dataset to train the image feature extraction network Pro_Net module of the image retrieval network Mat_Net, while fixing the network parameters of other modules, and only updating the Pro_Net network weights in the gradient backpropagation method.

[0147] S232, 81-150 rounds, use the industrial segmentation dataset to train the mask decoder Mask_Decoder module of the image retrieval network Mat_Net network, while fixing the network parameters of other modules, and only updating the Mask_Decoder network weights in the gradient backpropagation method.

[0148] S233, 151 to 200 rounds, use the industrial segmentation dataset to train the mask decoder Mask_Decoder and image feature extraction network Pro_Net modules of the image retrieval network Mat_Net, fix the network parameters of the Image_Encoder module, and update the network weights of the mask decoder Mask_Decoder and the image feature extraction network Pro_Net simultaneously in the gradient backpropagation method.

[0149] S234, after training is completed, the model weights are saved, which can be used for industrial scene category-aware image retrieval and detection tasks.

[0150] The training parameters for each round are: the number of training steps is set to N_inter, the batch size is B, the optimizer is Adam, the learning rate Lr=0.001, the Cosine Decay learning rate update strategy is adopted, and the network input size is 1024*1024.

[0151] By adopting the method provided by the embodiment of the present application, the target prompt feature vector of the target prompt thumbnail to be retrieved is extracted through the image feature extraction network in the target image retrieval model; the target retrieval category corresponding to the prompt feature vector matching the target prompt feature vector is determined from the prompt feature vector set in which the prompt feature vectors corresponding to multiple retrieval categories are pre-registered; the target image retrieval model uses the target prompt feature vector as the prompt information to retrieve the target prompt thumbnail in the retrieval original image corresponding to the target retrieval category, and the image retrieval result of the target prompt thumbnail in the retrieval original image corresponding to the target retrieval category can be obtained. On the one hand, the image retrieval efficiency can be effectively improved. On the other hand, since the prompt feature vector set has the prompt feature vectors corresponding to multiple retrieval categories pre-registered, and these prompt feature vectors are also extracted by the image feature extraction network in the target image retrieval model, the addition and deletion operations can be performed according to the needs, and the retrieval category of the target image retrieval model can be changed, and there is no need to retrain the target retrieval model according to the new retrieval requirements, which effectively improves the generalization ability and versatility of the target image retrieval model.

[0152] The present application embodiment provides an image retrieval device. The specific structural diagram of the device is as follows: Fig.11 As shown, it includes a feature extraction module 1110, a category determination module 1120 and an image retrieval module 1130. The functions of each module are as follows:

[0153] A feature extraction module 1110 is used to extract a target prompt feature vector of a target prompt thumbnail to be retrieved through an image feature extraction network in a target image retrieval model;

[0154] A category determination module 1120, configured to determine a target retrieval category corresponding to a prompt feature vector matching the target prompt feature vector from a prompt feature vector set pre-registered with prompt feature vectors corresponding to a plurality of retrieval categories;

[0155] The image retrieval module 1130 is used to retrieve the target hint thumbnail in the retrieval original image corresponding to the target retrieval category through the target image retrieval model using the target hint feature vector as hint information, and obtain the image retrieval result of the target hint thumbnail in the retrieval original image corresponding to the target retrieval category.

[0156] Optionally, the device further comprises a feature registration module, configured to:

[0157] If there is no prompt feature vector matching the target prompt feature vector in the pre-registered prompt feature vector set, assigning a search category to the target prompt feature vector;

[0158] registering the target prompt feature vector in the set of pre-registered prompt feature vectors based on the assigned search category;

[0159] A search category library corresponding to the assigned search category is established, and a search original image corresponding to the search category is assigned to the search category library.

[0160] Optionally, the device further comprises a prompt thumbnail acquisition module, which is used to:

[0161] Acquire the target prompt thumbnail from a local area of ​​a specified image; or,

[0162] A plurality of prompt thumbnails are obtained from the image segmentation result of the specified image as the plurality of target prompt thumbnails.

[0163] Optionally, when obtaining a plurality of prompt thumbnails from the image segmentation result of the specified image as the plurality of target prompt thumbnails, the image retrieval module is further used to:

[0164] Extracting a plurality of target prompt feature vectors corresponding to a plurality of target prompt thumbnails through an image feature extraction network in the target image retrieval model;

[0165] Using the target image retrieval model, taking the target prompt feature vectors as prompts, respectively, a plurality of image retrieval results corresponding to the plurality of target prompt thumbnails are determined in the target retrieval original image;

[0166] The plurality of image retrieval results are fused to obtain image retrieval results of the plurality of target prompt thumbnails in the target retrieval original image.

[0167] Optionally, the training process of the target image retrieval model includes:

[0168] Acquire a segmentation task dataset, the segmentation task dataset comprising a prompt image dataset and a to-be-retrieved image dataset; wherein the prompt image dataset comprises a prompt thumbnail containing multiple categories, and annotation information based on category information of the prompt thumbnails of the multiple categories; the to-be-retrieved image dataset comprises an original image to be retrieved comprising multiple categories, a category label mask image corresponding to the prompt thumbnails of the multiple categories, and annotation information based on category information of the original image to be retrieved of the multiple categories;

[0169] Based on the plurality of categories of prompt thumbnails, and the annotation information based on the category information of the plurality of categories of prompt thumbnails, and the plurality of categories of original images to be retrieved, the category label mask images corresponding to the plurality of categories of prompt thumbnails, and the annotation information based on the category information of the plurality of categories of original images to be retrieved, the image feature extraction network and the mask decoder in the pre-constructed image retrieval network are trained to obtain a target image retrieval model;

[0170] The pre-built image retrieval network is composed of an image feature extraction network, and an image encoder and a mask decoder of an image segmentation network.

[0171] Optionally, network parameters of the image encoder of the image segmentation network do not change during the training process of the pre-built image retrieval network.

[0172] Optionally, the training of the image feature extraction network and the mask decoder in the pre-built image retrieval network to obtain the target image retrieval model includes:

[0173] A positive sample dataset and a negative sample dataset are constructed based on the segmentation task dataset, wherein the positive sample dataset is composed of a plurality of positive sample pairs, and the negative sample dataset is composed of a plurality of negative sample pairs; one of the positive sample pairs is composed of a search original image, a category mask image of the search original image, a hint thumbnail matching the search original image, and category information of the hint thumbnail matching the search original image; one of the negative sample pairs is composed of a search original image, a category mask image of the search original image, a hint thumbnail not matching the search original image, and category information of the hint thumbnail not matching the search original image;

[0174] Based on the positive sample data set and the score labels corresponding to each positive sample pair in the positive sample data set, as well as the negative sample data set and the score labels corresponding to each negative sample pair in the negative sample data set, the image feature extraction network and the mask decoder in the image retrieval network are trained to obtain the target image retrieval model.

[0175] By using the device provided by the embodiment of the present application, the target prompt feature vector of the target prompt thumbnail to be retrieved is extracted through the image feature extraction network in the target image retrieval model; the target retrieval category corresponding to the prompt feature vector matching the target prompt feature vector is determined from the prompt feature vector set in which the prompt feature vectors corresponding to multiple retrieval categories are pre-registered; the target prompt thumbnail is retrieved in the retrieval original image corresponding to the target retrieval category by using the target prompt feature vector as the prompt information through the target image retrieval model, and the image retrieval result of the target prompt thumbnail in the retrieval original image corresponding to the target retrieval category can be obtained. On the one hand, the image retrieval efficiency can be effectively improved. On the other hand, since the prompt feature vector set has the prompt feature vectors corresponding to multiple retrieval categories pre-registered, and these prompt feature vectors are also extracted by the image feature extraction network in the target image retrieval model, the addition and deletion operations can be performed according to the needs, and the retrieval category of the target image retrieval model can be changed, and there is no need to retrain the target retrieval model according to the new retrieval requirements, which effectively improves the generalization ability and versatility of the target image retrieval model.

[0176] Fig.12 The following is a schematic diagram of the structure of an electronic device provided by an exemplary embodiment of the present application. Fig.12 As shown, the device includes: a memory 121 and a processor 22.

[0177] The memory 121 is used to store computer programs and can be configured to store various other data to support operations on the computing device. Examples of such data include instructions for any application or method operating on the computing device, contact data, phone book data, messages, pictures, videos, etc.

[0178] The processor 122 is coupled to the memory 121 and is used to execute the computer program in the memory 121, so as to: extract the target prompt feature vector of the target prompt thumbnail to be retrieved through the image feature extraction network in the target image retrieval model; determine the target retrieval category corresponding to the prompt feature vector matching the target prompt feature vector from a prompt feature vector set that is pre-registered with prompt feature vectors corresponding to multiple retrieval categories; retrieve the target prompt thumbnail in the retrieval original image corresponding to the target retrieval category through the target image retrieval model using the target prompt feature vector as prompt information, and obtain the image retrieval result of the target prompt thumbnail in the retrieval original image corresponding to the target retrieval category.

[0179] The electronic device provided by the embodiment of the present application is used to extract the target prompt feature vector of the target prompt thumbnail to be retrieved through the image feature extraction network in the target image retrieval model; the target retrieval category corresponding to the prompt feature vector matching the target prompt feature vector is determined from the prompt feature vector set in which the prompt feature vectors corresponding to multiple retrieval categories are pre-registered; the target prompt thumbnail is retrieved in the retrieval original image corresponding to the target retrieval category by using the target prompt feature vector as the prompt information through the target image retrieval model, and the image retrieval result of the target prompt thumbnail in the retrieval original image corresponding to the target retrieval category can be obtained. On the one hand, the image retrieval efficiency can be effectively improved. On the other hand, since the prompt feature vector set has the prompt feature vectors corresponding to multiple retrieval categories pre-registered, and these prompt feature vectors are also extracted by the image feature extraction network in the target image retrieval model, the addition and deletion operations can be performed according to the needs, and the retrieval category of the target image retrieval model can be changed, and there is no need to retrain the target retrieval model according to the new retrieval requirements, which effectively improves the generalization ability and versatility of the target image retrieval model.

[0180] Further, if Fig.12 As shown, the electronic device also includes: a communication component 123, a display 124, a power component 125, an audio component 126 and other components. Fig.12 Only some components are shown schematically, which does not mean that the electronic device only includes Figure 2 In addition, depending on the implementation form of the traffic playback device, Fig.12 The components in the dashed box are optional components, not mandatory components. For example, when the electronic device is implemented as a terminal device such as a smartphone, tablet computer or desktop computer, it may include Fig.12 Components in the dashed box; when the electronic device is implemented as a conventional server, cloud server, data center or server array and other server-side devices, it may not include Fig.12 Components within the dashed box.

[0181] Accordingly, an embodiment of the present application further provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, the processor is enabled to implement the steps in the above method embodiment.

[0182] Accordingly, the embodiment of the present application further provides a computer program product, including a computer program / instruction, which can implement each step that can be performed by the electronic device in the above method embodiment when the computer program / instruction is executed. Optionally, the computer program product, in addition to executing each step in the above method embodiment.

[0183] Above Fig.12 The communication component in is configured to facilitate wired or wireless communication between the device where the communication component is located and other devices. The device where the communication component is located can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component may also include a near field communication (NFC) module, a radio frequency identification (RFID) technology, an infrared data association (IrDA) technology, an ultra-wideband (UWB) technology, a Bluetooth (BT) technology, etc.

[0184] Above Fig.12 The memory in can be implemented by any type of volatile or non-volatile storage device or a combination of them, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk or optical disk.

[0185] Above Fig.12 The display in the embodiment includes a screen, which may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation.

[0186] Above Fig.12 The power supply component in the device provides power to various components of the device where the power supply component is located. The power supply component may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the device where the power supply component is located.

[0187] Above Fig.12The audio component in can be configured to output and / or input audio signals. For example, the audio component includes a microphone (MIC), and when the device where the audio component is located is in an operating mode, such as a call mode, a recording mode, and a speech recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in a memory or sent via a communication component. In some embodiments, the audio component also includes a speaker for outputting an audio signal.

[0188] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.

[0189] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0190] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0191] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0192] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0193] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0194] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0195] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0196] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0197] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims

1. An image retrieval method, characterized in that: include: Extracting a target cue feature vector of a target cue thumbnail to be retrieved through an image feature extraction network in a target image retrieval model; Determining a target retrieval category corresponding to a prompt feature vector that matches the target prompt feature vector from a prompt feature vector set that is pre-registered with prompt feature vectors corresponding to a plurality of retrieval categories; The target image retrieval model uses the target prompt feature vector as prompt information to retrieve the target prompt thumbnail in the retrieval original image corresponding to the target retrieval category, and obtains an image retrieval result of the target prompt thumbnail in the retrieval original image corresponding to the target retrieval category.

2. The method according to claim 1, characterized in that The method further comprises: If there is no prompt feature vector matching the target prompt feature vector in the pre-registered prompt feature vector set, assigning a search category to the target prompt feature vector; registering the target prompt feature vector in the set of pre-registered prompt feature vectors based on the assigned search category; A search category library corresponding to the assigned search category is established, and a search original image corresponding to the search category is assigned to the search category library.

3. The method according to claim 1, characterized in that The method further comprises: Acquire the target prompt thumbnail from a local area of ​​a specified image; or, A plurality of prompt thumbnails are obtained from the image segmentation result of the specified image as the plurality of target prompt thumbnails.

4. The method according to claim 3, characterized in that When a plurality of prompt thumbnails are obtained from the image segmentation result of the designated image as the plurality of target prompt thumbnails, the method further comprises: Extracting a plurality of target prompt feature vectors corresponding to a plurality of target prompt thumbnails through an image feature extraction network in the target image retrieval model; Using the target image retrieval model, taking the target prompt feature vectors as prompts, respectively, a plurality of image retrieval results corresponding to the plurality of target prompt thumbnails are determined in the target retrieval original image; The plurality of image retrieval results are fused to obtain image retrieval results of the plurality of target prompt thumbnails in the target retrieval original image.

5. The method according to claim 1, characterized in that The training process of the target image retrieval model includes: Acquire a segmentation task dataset, the segmentation task dataset comprising a prompt image dataset and a to-be-retrieved image dataset; wherein the prompt image dataset comprises a prompt thumbnail containing multiple categories, and annotation information based on category information of the prompt thumbnails of the multiple categories; the to-be-retrieved image dataset comprises an original image to be retrieved comprising multiple categories, a category label mask image corresponding to the prompt thumbnails of the multiple categories, and annotation information based on category information of the original image to be retrieved of the multiple categories; Based on the plurality of categories of prompt thumbnails, and the annotation information based on the category information of the plurality of categories of prompt thumbnails, and the plurality of categories of original images to be retrieved, the category label mask images corresponding to the plurality of categories of prompt thumbnails, and the annotation information based on the category information of the plurality of categories of original images to be retrieved, the image feature extraction network and the mask decoder in the pre-constructed image retrieval network are trained to obtain a target image retrieval model; The pre-built image retrieval network is composed of an image feature extraction network, and an image encoder and a mask decoder of an image segmentation network.

6. The method according to claim 1, characterized in that The network parameters of the image encoder of the image segmentation network do not change during the training process of the pre-built image retrieval network.

7. The method according to claim 1, characterized in that The image feature extraction network and the mask decoder in the pre-built image retrieval network are trained to obtain a target image retrieval model, including: A positive sample dataset and a negative sample dataset are constructed based on the segmentation task dataset, wherein the positive sample dataset is composed of a plurality of positive sample pairs, and the negative sample dataset is composed of a plurality of negative sample pairs; one of the positive sample pairs is composed of a search original image, a category mask image of the search original image, a hint thumbnail matching the search original image, and category information of the hint thumbnail matching the search original image; one of the negative sample pairs is composed of a search original image, a category mask image of the search original image, a hint thumbnail not matching the search original image, and category information of the hint thumbnail not matching the search original image; Based on the positive sample data set and the score labels corresponding to each positive sample pair in the positive sample data set, as well as the negative sample data set and the score labels corresponding to each negative sample pair in the negative sample data set, the image feature extraction network and the mask decoder in the image retrieval network are trained to obtain the target image retrieval model.

8. An image retrieval device, characterized in that: include: A feature extraction module, used to extract a target cue feature vector of a target cue thumbnail to be retrieved through an image feature extraction network in a target image retrieval model; A category determination module, for determining a target retrieval category corresponding to a prompt feature vector matching the target prompt feature vector from a prompt feature vector set pre-registered with prompt feature vectors corresponding to a plurality of retrieval categories; An image retrieval module is used to retrieve the target hint sub-image in the retrieval original image corresponding to the target retrieval category through the target image retrieval model using the target hint feature vector as hint information, and obtain an image retrieval result of the target hint sub-image in the retrieval original image corresponding to the target retrieval category.

9. An electronic device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the steps of the method according to any one of claims 1 to 7 when executed by the processor.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the method according to any one of claims 1 to 7 are implemented.

11. A computer program product, characterized in that The method comprises a computer program, which, when executed by a processor, implements the steps of the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Target retrieval method and device, electronic equipment and storage medium

    CN113743455A

  • Image retrieval method and device, equipment and computer readable storage medium

    CN113821670A

  • Image retrieval method based on artificial intelligence and related equipment

    CN113918753A

  • Image retrieval method and device and storage medium

    CN116069969A

  • Defect detection network construction method, defect detection method, defect detection device and defect detection equipment

    CN116309554A

Cited By

  • Road congestion analysis method and device under view angle of low-altitude unmanned aerial vehicle, and electronic equipment

    CN122090329A