Image feature processing method, image comparison method, model training method and device
By extracting features that match the preset imaging conditions from the image to be processed and modifying them, the error problem caused by differences in imaging conditions in image retrieval is solved, and the accuracy of image feature comparison and the effect of image analysis are improved.
Patent Information
- Application Number
- CN202410418358.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-08
- Publication Date
- 2024-09-13
- Estimated Expiration
- 2044-04-08
AI Technical Summary
In image retrieval applications, the difference in imaging conditions between the image to be processed and the reference image leads to image contrast errors, which affects the accuracy of image recognition.
By extracting features that match the preset imaging conditions from the image to be processed, and using modification instructions described in natural language to modify the target features into features corresponding to the preset imaging conditions, the same imaging conditions are ensured when comparing image features. .
It improves the accuracy of image feature comparison, reduces image retrieval errors, and enhances the accuracy of image analysis.
Smart Images

Figure CN118015290B
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to an image feature processing method, an image comparison method, a model training method, a device, an electronic device and a computer-readable storage medium. Background Art
[0002] With the development of artificial intelligence (AI) technology, image retrieval is increasingly widely used in all walks of life. Image retrieval usually identifies the required features from the image to be processed and compares the identified features with the features of the reference image for subsequent related analysis. For example, you can identify the face in the image and compare it with the face in the reference image to track a person's whereabouts, identify the vehicle in the image and compare it with the vehicle in the reference image to count the traffic volume of a certain type of vehicle, identify the pedestrian in the image and compare it with the pedestrian in the reference image to count the distribution of customer groups and analyze the distribution of product attention, etc.
[0003] However, in actual applications, the imaging conditions of the image to be processed may not be the same as those of the reference image. For example, the reference image is a night photo and the image to be processed is a day photo, the reference image is an image taken by a mobile phone and the image to be processed is an image taken by a surveillance camera, there are differences in the body posture and movements of the human body between the image to be processed and the reference image, etc. These differences in imaging conditions may lead to errors in the comparison, resulting in errors in image comparison retrieval, and affecting the accuracy of image analysis using image recognition. Summary of the invention
[0004] The present application provides an image feature processing method, an image comparison method, an apparatus, an electronic device, and a computer-readable storage medium. The image features that match the required imaging conditions can be identified from the image to be processed. In this way, when the imaging conditions of the reference image are used as the required imaging conditions, the identified image features can be made consistent with the imaging conditions of the reference image, thereby better avoiding the phenomenon of errors when performing image feature comparison and improving the accuracy of image analysis using image feature extraction. The specific scheme is as follows:
[0005] In a first aspect, the present application provides an image feature processing method, the method comprising:
[0006] Get the image to be processed;
[0007] Extracting target features of a preset feature type from the image to be processed;
[0008] Acquire a modification instruction described in natural language, wherein the modification instruction is used to instruct to modify the target feature to a feature corresponding to a preset imaging condition;
[0009] Based on the modification instruction, the target feature is modified to a modified feature corresponding to the preset imaging condition indicated by the modification instruction.
[0010] In a second aspect, an embodiment of the present application provides an image comparison method, the method comprising:
[0011] Acquire a feature to be compared corresponding to a preset feature type of the image to be compared, wherein the feature to be compared is a modified feature obtained by processing the image feature processing method described in any one of the first aspects;
[0012] The feature to be compared is compared with a reference feature of a reference image, and whether the image to be processed matches the reference image is determined according to the comparison result, wherein the reference feature is a feature of the preset feature type corresponding to the reference image.
[0013] In a third aspect, the present application also provides a model training method, comprising:
[0014] Acquire a training sample, the training sample comprising a first sample image, a second sample image, and a sample modification instruction, the second sample image and the first sample image corresponding to a preset feature type have the same feature identity, and the second sample image and the first sample image have different imaging conditions of the preset type, the sample modification instruction is used to instruct to modify the feature of the first sample image to a feature corresponding to the imaging condition of the preset type of the second sample image;
[0015] Extracting target features of the preset feature type from the first sample image;
[0016] Modifying the target feature of the first sample image into an output modified feature corresponding to the imaging condition of the second sample image indicated by the sample modification instruction through the feature modification model to be trained;
[0017] Extracting target features of the preset feature type from the second sample image;
[0018] Based on the difference between the target feature of the second sample image and the output modified feature, the model parameters of the feature modification model to be trained are adjusted to obtain the trained feature modification model.
[0019] In a fourth aspect, the present application further provides an image feature processing device, the device comprising:
[0020] A first acquisition unit, used for acquiring an image to be processed;
[0021] An extraction unit, used for extracting target features of a preset feature type from the image to be processed;
[0022] The first acquisition unit is further used to acquire a modification instruction described in natural language, wherein the modification instruction is used to instruct to modify the target feature to a feature corresponding to a preset imaging condition;
[0023] A modification unit is used to modify the target feature into a modified feature corresponding to the preset imaging condition indicated by the modification instruction based on the modification instruction.
[0024] In a fifth aspect, the present application further provides an image comparison device, the device further comprising:
[0025] A second acquisition unit, used to acquire a to-be-compared feature corresponding to a preset feature type of the to-be-compared image, wherein the to-be-compared feature is a modified feature obtained by processing the image feature processing method according to any one of the first aspects;
[0026] A comparison unit is used to compare the feature to be compared with a reference feature of a reference image, and determine whether the image to be processed matches the reference image according to the comparison result, wherein the reference feature is a feature of the preset feature type corresponding to the reference image.
[0027] In a sixth aspect, the present application also provides an electronic device comprising: a processor, a memory, and computer program instructions stored in the memory and executable on the processor; when the processor executes the computer program instructions, the method described in any one of the first aspects is implemented.
[0028] In a seventh aspect, the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement the method as described in any one of the first aspects.
[0029] Compared with the prior art, this application has the following advantages:
[0030] The image feature processing method provided in the present application extracts target features that match preset feature types from the image to be processed, and obtains modification instructions described in natural language. Since the above-mentioned modification instructions are used to instruct to modify the target features to features corresponding to preset imaging conditions, based on the modification instructions, the target features can be modified to modified features corresponding to the preset imaging conditions indicated by the above-mentioned modification instructions.
[0031] Since the solution provided by the present application can modify the target features of the image to be processed into modified features corresponding to the preset imaging conditions, when the solution provided by the present application is used for image feature comparison and retrieval, the imaging conditions of the reference image can be used as the preset imaging conditions. In this way, using the solution provided by the present application, the target features of the image to be processed can be modified into modified features corresponding to the imaging conditions of the reference image. In this way, when comparing the target features of the image to be processed with the features of the reference image, two features of the same imaging conditions are compared, thereby improving the comparison accuracy of image features, better avoiding the phenomenon of image comparison and retrieval errors, and improving the accuracy of image analysis using image feature recognition. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 This is a schematic diagram of the application scenario provided by this application.
[0033] Figure 2 It is a flowchart of an example of an image feature processing method provided in an embodiment of the present application.
[0034] Figure 3 It is a flowchart of another example of the image feature processing method provided in an embodiment of the present application.
[0035] Figure 4 This is a flowchart of an example of a model training method provided in an embodiment of the present application.
[0036] Figure 5 This is a flowchart of another example of the model training method provided in an embodiment of the present application.
[0037] Figure 6 It is a unit block diagram of the image feature processing device provided in an embodiment of the present application.
[0038] Figure 7 It is a structural block diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0039] In order to enable those skilled in the art to better understand the technical solution of the present application, the present application is described clearly and completely below in conjunction with the drawings in the embodiments of the present application. However, the present application can be implemented in many other ways different from the following description. Therefore, based on the embodiments provided by the present application, all other embodiments obtained by those of ordinary skill in the art without creative work should fall within the scope of protection of the present application.
[0040] It should be noted that the terms "first", "source domain", "third", etc. in the claims, description and drawings of the present application are used to distinguish similar objects and are not used to describe a specific order or sequence. The data used in this way are interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "including", "having" and their variants are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0041] In order to facilitate understanding of the various embodiments of the present application, the application background of the embodiments is described.
[0042] With the development of artificial intelligence (AI) technology, image retrieval is increasingly widely used in all walks of life. For example, human body comparison and retrieval technology based on pedestrian re-identification or face recognition models is an important technology in the field of intelligent video analysis. It can realize efficient human-to-human applications across time and space in a multi-camera network, greatly expanding the ability to track and confirm individuals in complex scenarios. For example, in the field of public safety and intelligent security, human body retrieval technology plays a key role. In large public places, commercial buildings and urban monitoring systems, pedestrian re-identification technology can identify the whereabouts of the same person across cameras, while face recognition can accurately identify the identity when the face appears. In smart city management, human body retrieval technology is used for traffic management, crowd flow statistics analysis and behavior prediction. In the field of commercial retail, through pedestrian re-identification technology, without obtaining sensitive information about the user's identity, relying only on clothing appearance features, it can also achieve customer counting, peer relationship analysis, brand and format heat analysis, correlation analysis, commodity attention analysis, etc., providing a basis for business decision-making and improving service quality. In community management, smart parks, and smart campuses, this technology can be applied to contactless access, visitor management, attendance, and dormitory management, significantly improving the level of intelligence in security management.
[0043] Both pedestrian re-identification and face recognition rely on feature similarity calculation. Specifically, image retrieval usually identifies the required features from the image to be processed, and compares the identified features with the features of a reference image or a large number of reference images in the base database, calculates the comparison similarity, and performs subsequent related analysis based on the similarity, for example, judging whether the image to be processed and the reference image are the same person, or which reference image is the same person as the image to be processed. Exemplarily, image retrieval technology can be used to identify faces in images and compare them with faces in reference images to track the whereabouts of a person, identify vehicles in images and compare them with vehicles in reference images to count the traffic volume of a certain type of vehicle, identify pedestrians in images and compare them with pedestrians in reference images to count the distribution of customer groups, analyze the distribution of product attention, etc.
[0044] However, in actual applications, the imaging conditions of the image to be processed may not be the same as those of the reference image. For example, the reference image is a night photo and the image to be processed is a daytime photo, the reference image is an image taken by a mobile phone and the image to be processed is an image taken by a surveillance camera, there are differences in the body posture and movement of the human body in the image to be processed and the reference image, the image to be processed is a visible light photo, and the reference image is a photo taken under near-infrared light after the surveillance camera is switched to night mode, the image to be processed is an incomplete photo after being blocked and truncated, and the base image is a complete photo, there are local changes such as backpacks, hats, and glasses between the image to be processed and the reference image, there is a large difference in perspective between the image to be processed and the reference image, there are large differences in imaging conditions such as resolution, clarity, and white balance between the image to be processed and the reference image, etc. These differences in imaging conditions may result in a low similarity between two images of the same person obtained under different imaging conditions, or may result in a high similarity between different people, which may lead to errors in comparison, image comparison retrieval errors, and affect the accuracy of image analysis using image recognition.
[0045] In order to solve the above problems, the embodiments of the present application provide an image feature processing method, an image comparison method, a model training method, a device, an electronic device and a computer-readable storage medium. It is intended to be able to identify image features that match the required imaging conditions from the image to be processed, so that when the imaging conditions of the reference image are used as the required imaging conditions, the identified image features can be consistent with the imaging conditions of the reference image, better avoiding the phenomenon of errors when performing image feature comparison, and improving the accuracy of image analysis using image feature extraction. The image feature processing method provided by the present application can be used to track the whereabouts of specific people through human body or face recognition; or to count the flow of people in shopping malls or other places through human body recognition; or to count customers, analyze peer relationships, analyze brand and business popularity, correlation analysis, commodity attention analysis, etc. by identifying the clothing appearance characteristics of pedestrians in the commercial retail field, providing a basis for business decision-making and improving service quality; or to identify vehicle features to count vehicle flow; or to identify other features for data analysis. This application does not limit the specific application field. It is only for the convenience of description. The following mainly takes facial feature recognition as a typical application scenario, and explains the above method provided by this application around this scenario. Of course, the embodiments of this application can also be applied to image feature recognition in vehicle recognition scenarios, human clothing and appearance recognition scenarios, animal recognition scenarios, license plate recognition scenarios, etc.
[0046] In order to facilitate understanding of the method embodiments of the present application, the application scenarios are introduced. Figure 1 , Figure 1 The following is a schematic diagram of an application scenario of the method embodiment of the present application. It can be applied to an image processing end. This application scenario is a schematic illustration and is not intended to be a specific description of its application scenario. The image processing end can be a server end or other electronic device end. The server end can be a cloud server end or can be replaced by other servers. Figure 1 As shown, in this application scenario, an image acquisition terminal 101 and an image processing terminal 102 are provided. In this embodiment, the image acquisition terminal 101 and the image processing terminal 102 are directly connected through network communication.
[0047] The image acquisition end 101 can be a device capable of capturing images, such as a camera, a monitoring device, a mobile phone, a tablet computer (pad), a smart watch, etc. In this case, the image acquisition device can use the captured image as the image to be processed. The image acquisition device can also be a device capable of storing and transmitting images, such as a desktop computer, a vehicle-mounted device, a wearable device, etc. In this case, the image to be processed can be manually stored in the image acquisition device, so that the image acquisition device can send the image to be processed to the image processing device.
[0048] A specific communication connection needs to be established between the image acquisition end 101 and the image processing end 102 to perform image transmission.
[0049] The image processing end 102 has high computing power. The image processing end 102 can be a server, and the image processing end 102 has high-speed processor (central processing unit, CPU) computing power, long-term reliable operation, strong input / output (input / output, I / O) external data throughput capacity and better scalability. The image processing end 102 can be a single server or a server cluster. The image processing end 102 is the end that performs image feature processing or image comparison.
[0050] The image acquisition end 101 can communicate with the image processing end 102. The image acquisition end 101 and the image processing end 102 can communicate using various communication systems, for example, a wired communication system or a wireless communication system. The wireless communication system can be, for example, a global system for mobile communications (GSM) system, a code division multiple access (CDMA) system, a wideband code division multiple access (WCDMA) system, a general packet radio service (GPRS), a long term evolution (LTE) system, a LTE frequency division duplex (FDD) system, a LTE time division duplex (TDD) system, a universal mobile telecommunication system (UMTS), a worldwide interoperability for microwave access (WiMAX) communication system, a future fifth generation (5G) system or a new radio (NR), a satellite communication system, etc.
[0051] In this embodiment, the image acquisition end 101 is mainly used to shoot or obtain the image to be processed by other means, and transmit it to the image processing end 102 through a network communication connection; after receiving the image to be processed sent by the image acquisition end 101, the image processing end 102 performs image feature processing.
[0052] The application scenario of the method embodiment provided in the embodiment of the present application may also only include one electronic device, which can not only obtain the image to be processed, but also perform image feature processing. For example, the user can input the image to be processed into the electronic device, and the electronic device performs feature processing on the image to be processed after obtaining the image to be processed input by the user.
[0053] Embodiment 1
[0054] The first embodiment of the present application provides an image feature processing method, the execution subject of the method may be an electronic device, and the electronic device may be a server, a desktop computer, a laptop computer, a smart mobile terminal, an image acquisition device, a smart TV, a monitoring device, etc., or other electronic devices with data processing capabilities.
[0055] like Figure 2 , Figure 3 As shown, the image feature processing method provided in the first embodiment of the present application includes the following steps S110 to S140.
[0056] Step S110: Acquire the image to be processed.
[0057] The above-mentioned image to be processed may be an image manually input into the electronic device. When the electronic device is a device with an image acquisition function, the image to be processed may also be an image acquired by the electronic device, or the image to be processed may also be an image received by the electronic device from an image acquisition device. The image to be processed may be an image acquired in real time or an offline image. This application does not specifically limit the way to obtain the image to be processed.
[0058] The image to be processed may be an image containing a human face, an image containing a human body, an image containing a vehicle, an image containing an animal, etc., or may be an image whose features are not determined. This application does not specifically limit the content of the image to be processed.
[0059] In the embodiments of the present application, the specific scenarios in which the image feature processing is applied are different, and the images to be processed are usually different. For example, when the image feature processing is used to track the trajectory of a specific person, the images to be processed may be images taken by surveillance cameras installed at various surveillance locations; when the image feature processing is used to count the flow of people in a shopping mall, the images to be processed may be images taken by surveillance cameras installed at the shopping mall; when the image feature processing is used to count the flow of vehicles on the road, the images to be processed may be surveillance cameras installed on the highway.
[0060] Step S120: extracting target features of a preset feature type from the above-mentioned image to be processed.
[0061] The above-mentioned preset feature types match the application scenarios of the embodiments of the present application. For example, when the application scenario is to perform face recognition for trajectory tracking, the preset feature type is face feature; when the application scenario is to perform human body recognition for crowd statistics analysis, the preset feature type is human body feature; when the application scenario is traffic statistics, the preset feature type is vehicle feature; when the application scenario is specific vehicle trajectory tracking, the preset feature type is license plate feature.
[0062] In the embodiment of the present application, the preset feature type can be manually pre-set and input into the electronic device, so that the electronic device acquires the manually input preset feature type. Alternatively, the electronic device can also acquire the preset feature type from other devices.
[0063] In this step, exemplarily, when the preset feature type is a face feature, the face feature can be extracted from the image to be processed as the target feature, and when the preset feature type is a license plate feature, the license plate feature can be extracted from the image to be processed as the target feature.
[0064] In a specific embodiment, a target feature matching a preset feature type can be extracted from an image to be processed by a pre-trained feature extraction model. Specifically, the image to be processed can be input into a pre-trained feature extraction model, and the target feature matching the preset feature type corresponding to the image to be processed can be output. The pre-trained feature extraction model is used to extract target features matching the preset feature type from an image.
[0065] The feature extraction model can be obtained through pre-training. The training method of the feature extraction model is not the focus of the invention of this application. The feature extraction model can be trained through a supervised learning algorithm or a semi-supervised learning algorithm in the related technology. Therefore, the training process of the feature extraction model will not be introduced in detail.
[0066] In an embodiment of the present application, the extracted target features may be target feature vectors represented in vector form. The vectors may represent the target features more comprehensively and accurately, and may also facilitate subsequent feature modification and other calculations more accurately through the target feature vectors, thereby improving the accuracy of feature modification.
[0067] Step S130: Acquire a modification instruction described in natural language, wherein the modification instruction is used to instruct to modify the target feature to a feature corresponding to a preset imaging condition.
[0068] The preset imaging condition may be the same as the imaging condition of the reference image in the base library. For example, if the imaging condition of the reference image is daytime shooting, the preset imaging condition may include daytime shooting, and if the imaging condition of the reference image is backside shooting, the preset imaging condition may include backside shooting.
[0069] The preset imaging conditions may include one imaging condition or multiple imaging conditions. The specific number of imaging conditions included may be determined according to the difference in imaging conditions between the image to be processed and the reference image. For example, the reference image and the image to be processed are one shot during the day and the other shot at night, one shot by a mobile phone and the other shot by a surveillance camera, one shot from a top angle and the other shot from a horizontal angle. Then the preset imaging conditions may include three preset imaging conditions of "shooting during the day", "shooting by a mobile phone" and "shooting from a top angle". Accordingly, the modification instruction is used to modify the target features to features corresponding to the three preset imaging conditions of "shooting during the day", "shooting by a mobile phone" and "shooting from a top angle". Exemplarily, the modification instruction may be "change to daytime and shoot from a top angle with a mobile phone". When the preset imaging condition includes one, the modification instruction may be "change to daytime shooting" or "change to shooting with a mobile phone", etc. This application is not specifically limited.
[0070] In the embodiment of the present application, the modification instruction can be manually set based on actual needs, and the electronic device can obtain the manually set modification instruction. Alternatively, when the solution provided by the present application is used for image feature comparison, the electronic device can also compare the imaging difference between the image to be processed and the reference image, and determine the preset imaging condition based on the imaging difference, and generate the modification instruction described in natural language based on the preset imaging condition.
[0071] Step S140: Based on the modification instruction, the target feature is modified into a modified feature corresponding to the preset imaging condition indicated by the modification instruction.
[0072] Exemplarily, if the image to be processed is an image taken at night, when the modification instruction is used to instruct to modify the target features to the features of the image taken during the day, step S140 can modify the target features to the features corresponding to the image taken during the day. After the modification, the target features of the image to be processed have the attribute characteristics of the image taken during the day.
[0073] In a specific embodiment, in order to conveniently, quickly and accurately modify the target features of the image to be processed into the modified features, step S140 can modify the target features into the modified features corresponding to the preset imaging conditions indicated by the modification instructions through a pre-trained feature modification model. Among them, the feature modification model can modify the target features into features corresponding to one or more preset imaging conditions. For example, the target features of the image to be processed and the modification instructions can be input into the feature modification model, and the modified features corresponding to the preset imaging conditions corresponding to the target features can be output; or, the target features of the image to be processed and the modification instructions can be subjected to various data processing, or other auxiliary data can be added to generate a data type that is convenient for model calculation, and then input into the feature modification model to output the modified features corresponding to the preset imaging conditions corresponding to the target features. The specific processing method will be described in detail later.
[0074] The pre-trained feature modification model can be trained based on a supervised learning algorithm in the relevant technology. Specifically, Figure 4 , Figure 5 As shown, an embodiment of the present application also provides a model training method, which trains a feature modification model through the following steps S210~250.
[0075] Step S210: Obtain training samples.
[0076] The training samples include a first sample image, a second sample image and a sample modification instruction. The training samples in the embodiment of the present application can be understood as including a sample triplet, and the sample triplet includes the above-mentioned first sample image, the above-mentioned second sample image and the above-mentioned sample modification instruction.
[0077] The second sample image has the same feature identity as the first sample image in the preset feature type. For example, when the preset feature type is a face, the second sample image and the first sample image correspond to the face of the same person, when the preset feature type is a body, the second sample image and the first sample image correspond to the body of the same person, and when the preset feature type is a license plate, the second sample image and the first sample image correspond to the license plate of the same vehicle.
[0078] The second sample image has different preset type imaging conditions from the first sample image. The preset type may include at least one of a shooting time period, a shooting device, a shooting light source, and a shooting angle, but is not limited thereto. Specifically, it may be determined according to the type of imaging condition that needs to be modified for the image to be processed in actual application. For example, when using a feature modification model, if it is necessary to modify the target feature of the image to be processed to a feature corresponding to an image shot with infrared light, then the imaging light source of the first sample image and the second sample image may be different, that is, the first sample image is a visible light image, and the second sample image is an infrared light image. If it is necessary to modify the target feature of the image to be processed to a feature corresponding to an image shot during the day, then the first sample image is an image shot at night, and the second sample image is an image shot during the day. The imaging condition of the shooting time of the first sample image and the second sample image may also be different, that is, the second sample image and the first sample image have different imaging conditions of the shooting time and the shooting light source.
[0079] When collecting training samples, the embodiment of the present application can obtain the above-mentioned sample triples from sample images for conventional feature recognition, so that training samples can be obtained quickly and efficiently. In order to enrich the training samples, two images of the same identity features with obvious differences in imaging conditions can also be combined into sample triples. During the training process, the model can be first trained using the sample triples obtained from the sample images of conventional feature recognition to obtain a feature modification model that basically meets the requirements, and then the feature modification model can be optimized and trained using the sample triples composed of two images of the same identity features with obvious differences in imaging conditions to improve the reasoning accuracy of the model.
[0080] The sample modification instruction is used to instruct that the features of the first sample image be modified to features corresponding to the imaging conditions of the preset type of the second sample image. For example, if the preset type is shooting time period, the shooting time period of the second sample image is daytime, and the shooting time period of the first sample image is nighttime, then the sample modification instruction may be used to instruct that the features of the first sample image be modified to features corresponding to an image shot during the daytime.
[0081] Step S220: extracting target features of a preset feature type from the first sample image.
[0082] Step S230: using the feature modification model to be trained, modifying the target feature of the first sample image into an output modified feature corresponding to the imaging condition of the preset type of the second sample image indicated by the sample modification instruction.
[0083] Step S240: extracting target features of a preset feature type from the second sample image.
[0084] Step S230 is similar to step S140 in that the target feature is modified into a modified feature corresponding to the preset imaging condition by using a pre-trained feature modification model, and will not be described in detail here. In this embodiment, steps S220 and S240 can extract respective target features by using an existing feature extraction model that has been trained.
[0085] The feature modification model to be trained can use the structure and parameters of the large language model in the related art, that is, the feature modification model is obtained by training on the basis of the large language model in the related art to improve the training efficiency. The large language model can be the open source Meta AI large language model (Large Language Model Meta AI, referred to as LLaMA) or Qianwen Large Language Model (Qwen), etc., but is not limited thereto.
[0086] Since the modification instructions are described in natural language and the large language model has very high accuracy and efficiency in natural language processing, the feature modification model is trained on the basis of the large language model, so that the feature modification model can better modify the target features based on the modification instructions.
[0087] Step S250: Based on the difference between the target feature of the second sample image and the above-mentioned output modified feature, adjust the model parameters of the feature modification model to be trained to obtain the trained feature modification model.
[0088] Specifically, the model parameters of the feature modification model to be trained can be adjusted based on the convergence condition that the difference between the target feature of the second sample image and the output modified feature is less than the preset difference, so as to obtain the trained feature modification model. For example, the following formula (1) can be used to minimize the output modified feature corresponding to the first sample image: The target features of the second sample image The mean square error (MSE) is used as the principle to adjust the model parameters of the model to be trained. .
[0089] (1)
[0090] in, The model parameters of the feature output model to be trained in the following text, They are respectively the model parameters of the first dimension conversion model to be trained and the second dimension conversion model to be trained in the following text.
[0091] In one implementation, before step S140, the following step S130a may also be included.
[0092] Step S130a: Determine the visual language features corresponding to the image to be processed, where the visual language features are used to represent the image to be processed through a vector.
[0093] The visual language features can be specifically used to represent the image content, image size, image pixel information, etc. of the image to be processed through vectors, but are not limited thereto. The visual language features are used to fully describe the image to be processed through vectors. Since data operations are usually performed based on vectors during model reasoning, this can improve the comprehensiveness and accuracy of information, thereby improving the accuracy of model reasoning. Therefore, by determining the visual language features corresponding to the image to be processed, the accuracy of image feature conversion can be improved.
[0094] Specifically, step S130a may determine the visual language features of the image to be processed based on a pre-trained visual language extraction model.
[0095] The visual language extraction model is used to determine the visual language features corresponding to the image. The visual language extraction model can be obtained by training the visual language extraction model to be trained in advance. The specific training method can refer to the relevant technology, and the training method is not the focus of this application. This embodiment can quickly and accurately obtain the visual language features of the image to be processed through the visual language model.
[0096] Correspondingly, step S140 can be implemented according to the following step S141.
[0097] Step S141: using a pre-trained feature modification model and based on the above-mentioned visual language features, modifying the target feature into a modified feature corresponding to the preset imaging condition indicated by the modification instruction.
[0098] Specifically, the target features of the image to be processed, the above-mentioned modification instructions and the visual language features can be input into the feature modification model to output the modified features of the target features corresponding to the preset imaging conditions; or, the target features of the image to be processed, the above-mentioned modification instructions and the above-mentioned visual language features can be processed to generate a data type that is convenient for model calculation and then input into the feature modification model to output the modified features of the target features corresponding to the preset imaging conditions.
[0099] The above-mentioned visual language feature extraction model can adopt the visual encoder in the contrastive language-image pre-training (CLIP) model, for example, it can be a contrastive language-image pre-training-vision transformer (i.e., contrastive language-image pre-training-vision transformer, CLIP-ViT) model, or it can be an efficient visual attention-contrastive language-image pre-training-vision transformer (EVA-CLIP-ViT) model.
[0100] The CLIP-ViT model can be used to obtain multiple vectors for describing the image to be processed. For example, the CLIP-ViT model can be used to divide the image to be processed into a series of area patches of the same size, such as 16×16 patches. All pixel values in each patch are linearly transformed, added to the position code, and calculated through a series of transformer layers to form an embedding representation, that is, the feature vector of the image patch, such as a 768-dimensional vector. Therefore, the visual language features corresponding to the image to be processed include 256 768-dimensional vectors.
[0101] Since visual language models such as CLIP-ViT are trained on large-scale image-text pairs to learn image and language representations, the visual language features extracted by CLIP-ViT can be better aligned with natural language.
[0102] In one implementation, during the process of training the feature modification model using the above-mentioned model training method, the above-mentioned step S230 can be implemented according to the following steps S231 to S232.
[0103] Step S231: input the first sample image into the visual language extraction model, and output the visual language features corresponding to the first sample image.
[0104] Step S232: through the feature modification model to be trained and based on the above-mentioned visual language features, the target features of the first sample image are modified into output modified features corresponding to the imaging conditions of the second sample image indicated by the sample modification instruction.
[0105] The execution process of step S232 is similar to the execution process of the above-mentioned step S141, and will not be described in detail here.
[0106] Since the present embodiment extracts visual language features aligned with the text language, the feature modification model can better understand the image information of the image to be processed, so that the feature modification model can perform more accurate feature modification based on accurately obtaining the image information of the image to be processed. When the feature modification model is a model trained on the basis of the large language model in the related technology, since the large language model has a stronger ability to understand text language, the visual language features aligned with the text language can further improve the feature modification model's understanding of the image to be processed, thereby improving the accuracy of feature modification.
[0107] In one embodiment, when the feature modification model is obtained by training based on a large language model in the related art, since the large language model inputs text in the form of a vector, it is necessary to convert the modification instruction into a modification instruction vector represented in the form of a vector. At the same time, the target feature of the image to be processed is a target feature vector represented in the form of a vector. Therefore, step S141 can be implemented according to the following steps S141a to S141b.
[0108] Step S141a: Convert the above modification instruction into a modification instruction vector represented in vector form.
[0109] Specifically, in order to improve the efficiency and accuracy of vector conversion, the above modification instruction can be input into a pre-trained embedding vector conversion model to obtain a modification instruction vector corresponding to the above modification instruction. The embedding vector conversion model is used to convert natural language text into a vector. Alternatively, the modification instruction can be converted into a modification instruction vector represented in vector form by other methods.
[0110] Step S141b: Using a pre-trained feature modification model and based on the visual language features and the modification instruction vector, the target feature vector is modified into a modified feature corresponding to the preset imaging condition indicated by the modification instruction.
[0111] Specifically, the target feature vector of the image to be processed, the modification instruction vector and the visual language feature vector can be input into the feature modification model, and the modified features of the target feature vector corresponding to the preset imaging conditions can be output. Alternatively, the target feature vector of the image to be processed, the modification instruction vector and the visual language feature vector can be processed by specific data to generate a data type that is convenient for model calculation, and then input into the feature modification model to output the modified features corresponding to the preset imaging conditions corresponding to the target features.
[0112] This embodiment vectorizes the input data of each feature modification model, so that the feature modification model can perform model reasoning more accurately and efficiently, thereby improving the accuracy of feature modification.
[0113] Optionally, in the process of training the feature modification model through the above-mentioned model training method, the target feature of the first sample image is a sample target feature vector represented in vector form, and the above-mentioned step S232 can be implemented according to the following steps S232a~step S232b.
[0114] Step S232a: input the sample modification instruction into the embedded vector conversion model to be trained to obtain a sample modification instruction vector corresponding to the sample modification instruction.
[0115] Step S232b: through the feature modification model to be trained, and based on the output visual language feature and the sample modification instruction vector, the sample target feature vector is modified into an output modified feature corresponding to the imaging condition of the second sample image indicated by the sample modification instruction.
[0116] The execution process of step S232b is similar to that of step S141b and will not be described in detail here.
[0117] The above model training method may further include the following step S270.
[0118] Step S270: Based on the difference between the target feature of the second sample image and the output modified feature, the model parameters of the embedded vector conversion model to be trained are adjusted to obtain the trained embedded vector conversion model.
[0119] The embedding vector conversion model can adopt a model with the same structure as the model used by the large language model to vectorize natural language. Specifically, in the process of converting the modification instruction into the modification instruction vector, the embedding vector conversion model can first use the Byte Pair Encoding (BPE) or SentencePiece method to convert the modification instruction into a series of vocabulary units (tokens), and then use the text embedding matrix of the large language model to represent each vocabulary unit in the form of an embedding vector to obtain the modification instruction vector.
[0120] In one implementation, the above step S141b can be implemented according to the following steps A to C.
[0121] Step A: Convert the above visual language features, target feature vectors, and modification instruction vectors into converted visual language features, converted target feature vectors, and converted modification instruction vectors of the same dimensions.
[0122] Since the vector dimensions of the three vectors, namely, the visual language feature, the target feature vector and the modification instruction vector, may not be the same, in order to facilitate calculation, the three vectors may be converted into vectors of the same dimension.
[0123] Specifically, in order to efficiently and quickly perform vector dimension conversion, the visual language features can be converted into converted visual language features with the same dimension as the modification instruction vector through a pre-trained first dimension conversion model, and the target feature vector can be converted into a converted target feature vector with the same dimension as the modification instruction vector through a pre-trained second dimension conversion model, and the modification instruction vector can be determined as the converted modification instruction vector. That is, based on the modification instruction vector, the visual language features and the target feature vector are converted into vectors with the same dimension as the modification instruction vector.
[0124] The above-mentioned first dimensional conversion model and second dimensional conversion model can also be understood as a first mapping function and a second mapping function.
[0125] Step B: Input the above-mentioned converted visual language features, the above-mentioned converted modification instruction vector and the above-mentioned converted target feature vector into a pre-trained feature modification model, and output a modified output feature vector of the above-mentioned converted target feature vector corresponding to the imaging conditions indicated by the above-mentioned modification instruction.
[0126] In step B, the converted visual language features, the converted modified instruction vector and the converted target feature vector can be respectively input into a pre-trained feature modification model. Optionally, in order to facilitate model calculation, Figure 3 As shown, the converted visual language features, the converted target feature vector and the converted modification instruction vector can also be spliced to obtain a spliced vector, which is then input into a pre-trained feature modification model to output a modified output feature vector of the converted target feature vector corresponding to the preset imaging conditions.
[0127] Step C: determining the modified feature corresponding to the preset imaging condition indicated by the modification instruction according to the modified output feature vector.
[0128] In step C, the modified output feature vector may be determined as the modified feature corresponding to the preset imaging condition, or the modified feature may be obtained by processing the modified output feature vector.
[0129] Exemplarily, the modified output feature vector can be converted into a vector with the same dimension as the vector output by the feature extraction model as the modified feature corresponding to the above-mentioned preset imaging condition. The feature extraction model is a model for extracting the target feature of the image to be processed in step S120. In this way, the output modified feature has the same dimension as the extracted target feature, which is more convenient for subsequent feature comparison or other image data analysis.
[0130] Specifically, the modified output feature vector can be converted into a vector of the same dimension as the vector output by the feature extraction model through a pre-trained feature output model. The feature output model is used to convert a vector into a vector of the same dimension as the vector output by the feature extraction model.
[0131] In one implementation, step S232b of the above-mentioned model training method can be implemented according to the following steps a to d.
[0132] Step a: Input the above output visual language features into the first dimension conversion model to be trained to obtain the converted output visual language features corresponding to the above output visual language features and having the same dimension as the above sample modification instruction vector.
[0133] Step b: Input the sample target feature vector into the second dimension conversion model to be trained to obtain a converted sample target feature vector corresponding to the sample target feature vector and having the same dimension as the sample modification instruction vector.
[0134] Step c: input the above-mentioned converted output visual language features, the above-mentioned sample modification instruction vector and the above-mentioned converted sample target feature vector into the feature modification model to be trained, and output the output modified feature vector of the above-mentioned converted sample target feature vector corresponding to the imaging condition of the above-mentioned second sample image indicated by the above-mentioned sample modification instruction.
[0135] Step d: determining the output modified feature corresponding to the imaging condition of the second sample image indicated by the sample modification instruction according to the output modified feature vector.
[0136] The execution process of step a to step d can refer to the process of steps A to C above, which will not be described in detail here.
[0137] Correspondingly, the above model training method may further include the following step S280.
[0138] Step S280: Based on the difference between the target features of the second sample image and the output modified features, adjust the model parameters of the first dimension conversion model to be trained and the second dimension conversion model to be trained to obtain the trained first dimension conversion model and the trained second dimension conversion model.
[0139] In a specific embodiment, the above step d can be implemented by the following steps: inputting the above output modified feature vector into the feature output model to be trained to obtain the output modified feature corresponding to the imaging condition of the second sample image indicated by the sample modification instruction. Accordingly, the above model training method can also include the following step S290.
[0140] Step S290: Based on the difference between the target feature of the second sample image and the output modified feature, the model parameters of the feature output model to be trained are adjusted to obtain the trained feature output model.
[0141] The parameter adjustment method of step S270 to step S290 can also refer to the process of adjusting the parameters of the feature modification model to be trained in step S250, which will not be described in detail here. This embodiment trains the embedding vector conversion model, the first dimension conversion model, the second dimension conversion model and the feature output model while training the feature modification model, which can improve the training efficiency and the coordination between different models, thereby making the overall feature modification accuracy higher.
[0142] Since the solution provided by the present application can modify the target features of the image to be processed into modified features corresponding to the preset imaging conditions, when the solution provided by the present application is used for image feature comparison and retrieval, the imaging conditions of the reference image can be used as the preset imaging conditions. In this way, using the solution provided by the present application, the target features of the image to be processed can be modified into modified features corresponding to the imaging conditions of the reference image. In this way, when comparing the target features of the image to be processed with the features of the reference image, two features of the same imaging conditions are compared, thereby improving the comparison accuracy of image features, better avoiding the phenomenon of image comparison and retrieval errors, and improving the accuracy of image analysis using image feature recognition.
[0143] In addition, when training the feature modification model, the solution provided by the present application can train the feature modification model into a model with multiple different preset imaging condition modification functions through multiple training samples according to the needs of feature modification, that is, the feature modification model can modify the target features of the image to be processed into modified features corresponding to multiple preset imaging conditions, thereby improving the modification efficiency and being more convenient for users to use. The solution provided by the embodiment of the present application uses natural language as a modification instruction to modify the target features of the image to be processed, and has the versatility in terms of modification types, that is, multiple types of modifications can be implemented through one model, reducing the R&D and deployment costs of the comparison and retrieval system, and supporting composite modification when modifying the target features of the image to be processed, that is, supporting the modification of multiple types of imaging conditions through one model, as long as the corresponding samples are added to the training samples, thereby improving the efficiency of feature modification.
[0144] Embodiment 2
[0145] The second embodiment of the present application provides an image feature processing method. The method provided in this embodiment is a specific example of the method provided in the first embodiment. Figure 3 As shown, the image feature processing method provided in this embodiment includes the following steps S1 to S10.
[0146] Step S1: Obtain an image I to be processed.
[0147] Step S2: Obtain modification instruction X described in natural language INST .
[0148] Step S3: Extract features of a preset feature type from the image to be processed I to obtain a target feature vector of the preset feature type of the image to be processed I f .
[0149] Step S4: Extract visual language features from the image to be processed I to obtain the visual language features corresponding to the image to be processed .
[0150] Step S5: Modify instruction X INST Convert to modify instruction vector F INST .
[0151] Step S6: Transform the target feature vector f、 Visual language features and modify the instruction vector F INST After changing to vectors of the same dimension, concatenate them to get the concatenated vector .
[0152] Step S7: Splice the vector Input features to modify the model , and get the modified output feature vector .
[0153] For example, the concatenation vector could be: .
[0154] in <fea1> and< / fea1> are two special vocabulary units used to indicate the beginning and end of the target feature vector. <fea2> and< / fea2> are two special vocabulary units used to indicate the beginning and end of visual language features. <eos>It is used to indicate the end of the entire input sequence (i.e., the concatenated vector). After the feature modification model inference, <eos>The output corresponding to the position is .
[0155] Step S8: Output the modified feature vector Input features Output model , and obtain the modified features .
[0156] in, It can be a Multilayer Perceptron (MLP) model, a Transformer model, etc.
[0157] The specific implementation process of the second embodiment has been described in detail in the first embodiment and will not be described in detail here.
[0158] Embodiment 3
[0159] The third embodiment of the present application provides an image comparison method, the execution subject of the method can be an electronic device, the electronic device can be a server, a desktop computer, a laptop computer, an intelligent mobile terminal, an image acquisition device, etc., or other electronic devices with data processing capabilities. The method can be used for face image comparison and recognition in the process of pedestrian trajectory tracking, vehicle image comparison and recognition in the process of vehicle trajectory tracking, human body recognition in images, etc., but is not limited to this.
[0160] The image comparison method provided in the second embodiment of the present application includes the following steps S310 to S320.
[0161] Step S310: Acquire a feature to be compared corresponding to a preset feature type of the image to be compared, wherein the feature to be compared is a modified feature obtained by processing the image feature processing method described in any one of the first embodiments.
[0162] The modification instruction used in this step in the process of obtaining the modified feature (ie, the feature to be compared) by the image feature processing method is used to instruct to modify the target feature to a feature corresponding to the imaging condition (ie, the preset imaging condition) of the reference image.
[0163] Step S320: Compare the feature to be compared with a reference feature of a reference image, and determine whether the image to be processed matches the reference image according to the comparison result, wherein the reference feature is a feature of the preset feature type corresponding to the reference image.
[0164] The reference features of the reference image can be extracted based on the feature extraction model in the first embodiment, which will not be described in detail here. Step S320 can calculate the similarity between the feature to be compared and the reference feature of the reference image, and determine whether the image to be processed matches the reference image based on the calculated similarity.
[0165] This embodiment is an application example of the image feature processing method described in the first embodiment. The specific process has been described in detail in the first embodiment and will not be repeated here.
[0166] Embodiment 4
[0167] The fourth embodiment of the present application provides a model training method, which is a specific example of the model training method provided in the first embodiment. Figure 5 As shown, the model training method provided in this embodiment includes the following steps S41 to S49.
[0168] Step S41: Obtain training samples.
[0169] The training sample includes a first sample image, a second sample image and a sample modification instruction.
[0170] Step S42: inputting the first sample image into a pre-trained feature extraction model to perform feature extraction of a preset feature type, and obtaining a first sample target feature vector of the preset feature type of the first sample image.
[0171] Step S43: inputting the first sample image into the visual language extraction model to extract visual language features, and obtaining output visual language features corresponding to the first sample image.
[0172] Step S44: input the sample modification instruction into the embedding vector conversion model to be trained to obtain a sample modification instruction vector.
[0173] Step S45: Input the sample target feature vector into the second dimension conversion model to be trained to obtain the converted sample target feature vector, input the output visual language feature into the first dimension conversion model to be trained to obtain the converted output visual language feature, and splice the converted sample target feature vector, the converted output visual language feature and the sample modification instruction vector to obtain a sample splicing vector.
[0174] Step S46: input the sample concatenated vector into the feature modification model to be trained to obtain an output modified feature vector.
[0175] Step S47: input the modified output feature vector into the feature output model to be trained to obtain the modified output feature.
[0176] Step S48: input the second sample image into the above-mentioned trained feature extraction model to perform feature extraction of a preset feature type, and obtain a second sample target feature of the preset feature type of the second sample image.
[0177] Step S49: Based on the difference between the second sample target feature and the above-mentioned output modified feature, adjust the model parameters of each model to be trained in step S41 to step S48 to obtain each trained model.
[0178] The specific implementation process of Example 4 has been described in detail in the model training method in Example 1 and will not be described in detail here.
[0179] Embodiment 5
[0180] The fifth embodiment of the present application also provides an image feature processing device corresponding to the above-mentioned image feature processing method embodiment. Since the device embodiment is basically similar to the method embodiment, the description is relatively simple. For the details of the relevant technical features and the effects achieved, please refer to the corresponding description of the above-mentioned image feature processing method embodiment. Figure 6 As shown, the image feature processing device provided by the present application includes:
[0181] A first acquisition unit 501 is used to acquire an image to be processed;
[0182] An extraction unit 502 is used to extract target features of a preset feature type from the image to be processed;
[0183] The first acquisition unit is further used to acquire a modification instruction described in natural language, wherein the modification instruction is used to instruct to modify the target feature to a feature corresponding to a preset imaging condition;
[0184] The modification unit 503 is configured to modify the target feature into a modified feature corresponding to the preset imaging condition indicated by the modification instruction based on the modification instruction.
[0185] Embodiment 6
[0186] The sixth embodiment of the present application also provides an image comparison device corresponding to the above-mentioned image comparison method embodiment. The image comparison device provided by the present application includes:
[0187] A second acquisition unit is used to acquire a to-be-compared feature corresponding to a preset feature type of the to-be-compared image, wherein the to-be-compared feature is a modified feature obtained by processing the image feature processing method described in any one of the first embodiments;
[0188] A comparison unit is used to compare the feature to be compared with a reference feature of a reference image, and determine whether the image to be processed matches the reference image according to the comparison result, wherein the reference feature is a feature of the preset feature type corresponding to the reference image.
[0189] Embodiment 7
[0190] The seventh embodiment of the present application also provides a model training device corresponding to the above-mentioned model training method embodiment. The model training device provided by the present application includes:
[0191] a sample acquisition unit, configured to acquire a training sample, wherein the training sample includes a first sample image, a second sample image, and a sample modification instruction, wherein the second sample image has the same feature identity as the first sample image corresponding to a preset feature type, and the second sample image has different imaging conditions of the preset type from the first sample image, and the sample modification instruction is used to instruct to modify the feature of the first sample image to a feature corresponding to the imaging condition of the preset type of the second sample image;
[0192] A sample extraction unit, used to extract target features of the preset feature type from the first sample image;
[0193] a sample modification unit, configured to modify the target feature of the first sample image into an output modified feature corresponding to the imaging condition of the second sample image indicated by the sample modification instruction, through a feature modification model to be trained;
[0194] The sample extraction unit is further used to extract the target feature of the preset feature type from the second sample image;
[0195] A parameter adjustment unit is used to adjust the model parameters of the feature modification model to be trained based on the difference between the target feature of the second sample image and the output modified feature to obtain the trained feature modification model.
[0196] Embodiment 8
[0197] The eighth embodiment of the present application also provides an electronic device embodiment corresponding to the above-mentioned image feature processing method embodiment and image feature processing device embodiment. The following description of the electronic device embodiment is only illustrative. The electronic device embodiment is as follows:
[0198] Please refer to Figure 7 Understand the above electronic devices, Figure 7 The electronic device provided in this embodiment includes: a processor 1001, a memory 1002, a communication bus 1003, and a communication interface 1004;
[0199] The memory 1002 is used to store computer instructions for data processing. When the computer instructions are read and executed by the processor 1001, the following steps are performed:
[0200] Get the image to be processed;
[0201] Extracting target features of a preset feature type from the image to be processed;
[0202] Acquire a modification instruction described in natural language, wherein the modification instruction is used to instruct to modify the target feature to a feature corresponding to a preset imaging condition;
[0203] Based on the modification instruction, the target feature is modified to a modified feature corresponding to the preset imaging condition indicated by the modification instruction.
[0204] Embodiment 9
[0205] The ninth embodiment of the present application also provides an electronic device embodiment corresponding to the above-mentioned image comparison method embodiment and image comparison device embodiment. The following description of the electronic device embodiment is only illustrative. The electronic device embodiment is as follows:
[0206] The electronic device provided in this embodiment includes: a processor, a memory, a communication bus, and a communication interface;
[0207] The memory is used to store computer instructions for data processing, and when the computer instructions are read and executed by the processor, the following steps are performed:
[0208] Acquire a feature to be compared corresponding to a preset feature type of the image to be compared, wherein the feature to be compared is a modified feature obtained by processing the image feature processing method described in any one of the first embodiments;
[0209] The feature to be compared is compared with a reference feature of a reference image, and whether the image to be processed matches the reference image is determined according to the comparison result, wherein the reference feature is a feature of the preset feature type corresponding to the reference image.
[0210] The tenth embodiment of the present application also provides a computer-readable storage medium for implementing the above-mentioned image feature processing method. The computer-readable storage medium embodiment provided in this application is described relatively simply. For the relevant parts, please refer to the corresponding description of the above-mentioned method embodiment. The embodiment described below is only exemplary.
[0211] The computer readable storage medium provided in this embodiment stores computer instructions, and when the instructions are executed by a processor, the following steps are implemented:
[0212] Get the image to be processed;
[0213] Extracting target features of a preset feature type from the image to be processed;
[0214] Acquire a modification instruction described in natural language, wherein the modification instruction is used to instruct to modify the target feature to a feature corresponding to a preset imaging condition;
[0215] Based on the modification instruction, the target feature is modified to a modified feature corresponding to the preset imaging condition indicated by the modification instruction.
[0216] The eleventh embodiment of the present application also provides a computer-readable storage medium for implementing the above-mentioned image comparison method. The computer-readable storage medium embodiment provided in this application is described relatively simply. For the relevant parts, please refer to the corresponding description of the above-mentioned method embodiment. The following described embodiment is merely illustrative.
[0217] The computer readable storage medium provided in this embodiment stores computer instructions, and when the instructions are executed by a processor, the following steps are implemented:
[0218] Acquire a feature to be compared corresponding to a preset feature type of the image to be compared, wherein the feature to be compared is a modified feature obtained by processing the image feature processing method described in any one of the first embodiments;
[0219] The feature to be compared is compared with a reference feature of a reference image, and whether the image to be processed matches the reference image is determined according to the comparison result, wherein the reference feature is a feature of the preset feature type corresponding to the reference image.
[0220] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0221] 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.
[0222] 1. Computer-readable media includes permanent and non-permanent, removable and non-removable media that can be used to store information by any method or technology. 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 disc read-only memory (CD-ROM), digital versatile disc (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 non-transitory media such as modulated data signals and carrier waves.
[0223] 2. Those skilled in the art should understand that the embodiments of the present application can be provided as methods, systems or computer program products. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0224] Although the present application is disclosed as above in the form of a preferred embodiment, it is not intended to limit the present application. Any technical personnel in this field may make possible changes and modifications without departing from the spirit and scope of the present application. Therefore, the scope of protection of the present application shall be based on the scope defined by the claims of the present application.< / eos> < / eos>
Claims
1. A method for processing image features, characterized in that: The method comprises: Get the image to be processed; Extracting target features of a preset feature type from the image to be processed; Acquire a modification instruction described in natural language, wherein the modification instruction is used to instruct to modify the target feature to a feature corresponding to a preset imaging condition; Determining visual language features corresponding to the image to be processed based on a pre-trained visual language extraction model, wherein the visual language features are used to represent the image to be processed through a vector; Based on the modification instruction, the target feature is modified into a modified feature corresponding to the preset imaging condition indicated by the modification instruction, including: through a pre-trained feature modification model and based on the visual language feature, the target feature and the modification instruction, the target feature is modified into a modified feature corresponding to the preset imaging condition indicated by the modification instruction.
2. The image feature processing method according to claim 1, characterized in that: The target feature is a target feature vector represented in vector form; The modifying of the target feature into a modified feature corresponding to the preset imaging condition indicated by the modification instruction by a pre-trained feature modification model based on the visual language feature includes: Converting the modification instruction into a modification instruction vector represented in vector form; Through a pre-trained feature modification model and based on the visual language feature and the modification instruction vector, the target feature vector is modified into a modified feature corresponding to the preset imaging condition indicated by the modification instruction.
3. The image feature processing method according to claim 2, characterized in that: The method of modifying the target feature vector into a modified feature corresponding to the preset imaging condition indicated by the modification instruction by using a pre-trained feature modification model and based on the visual language feature and the modification instruction vector comprises: Convert the visual language features, the target feature vector, and the modification instruction vector into converted visual language features, converted target feature vector, and converted modification instruction vector having the same dimensions; Inputting the converted visual language features, the converted modification instruction vector and the converted target feature vector into a pre-trained feature modification model, and outputting a modified output feature vector of the converted target feature vector corresponding to the imaging condition indicated by the modification instruction; A modified feature corresponding to the preset imaging condition indicated by the modification instruction is determined according to the modified output feature vector.
4. The image feature processing method according to claim 3, characterized in that: The step of converting the visual language features, the target feature vector, and the modification instruction vector into converted visual language features, converted target feature vector, and converted modification instruction vector having the same dimensions comprises: The visual language feature is converted into a converted visual language feature having the same dimension as the modification instruction vector by a pre-trained first dimension conversion model; Converting the target feature vector into a converted target feature vector having the same dimension as the modification instruction vector through a pre-trained second dimension conversion model; The modified instruction vector is determined as a converted modified instruction vector.
5. The image feature processing method according to claim 4, characterized in that: The step of inputting the converted visual language feature, the converted target feature vector and the converted modification instruction vector into a pre-trained feature modification model, and outputting a modified output feature vector of the converted target feature vector corresponding to the imaging condition indicated by the modification instruction, comprises: splicing the converted visual language feature, the converted target feature vector and the converted modification instruction vector to obtain a spliced vector; The spliced vector is input into a pre-trained feature modification model, and a modified output feature vector of the converted target feature vector corresponding to the imaging condition indicated by the modification instruction is output.
6. The image feature processing method according to claim 5, characterized in that: The step of extracting target features matching a preset feature type from the image to be processed includes: Extracting target features matching a preset feature type from the image to be processed by a pre-trained feature extraction model; The determining, according to the modified output feature vector, a modified feature corresponding to the preset imaging condition indicated by the modification instruction comprises: The modified output feature vector is converted into a vector having the same dimension as the vector output by the feature extraction model as a modified feature corresponding to the preset imaging condition.
7. An image comparison method, characterized in that: The method comprises: Acquire a feature to be compared corresponding to a preset feature type of the image to be compared, wherein the feature to be compared is a modified feature obtained by processing the image feature processing method according to any one of claims 1 to 6; The feature to be compared is compared with a reference feature of a reference image, and whether the image to be processed matches the reference image is determined according to the comparison result, wherein the reference feature is a feature of the preset feature type corresponding to the reference image.
8. A model training method, characterized in that: include: Acquire a training sample, the training sample comprising a first sample image, a second sample image, and a sample modification instruction, the second sample image and the first sample image corresponding to a preset feature type have the same feature identity, and the second sample image and the first sample image have different imaging conditions of the preset type, the sample modification instruction is used to instruct to modify the feature of the first sample image to a feature corresponding to the imaging condition of the preset type of the second sample image; Extracting target features of the preset feature type from the first sample image; The method comprises: inputting the first sample image into a visual language extraction model to output an output visual language feature corresponding to the imaging condition of the second sample image indicated by the sample modification instruction; and modifying the target feature of the first sample image into an output modified feature corresponding to the imaging condition of the second sample image indicated by the sample modification instruction through the feature modification model to be trained and based on the output visual language feature, the target feature of the first sample image and the sample modification instruction. Extracting target features of the preset feature type from the second sample image; Based on the difference between the target feature of the second sample image and the output modified feature, the model parameters of the feature modification model to be trained are adjusted to obtain the trained feature modification model.
9. The model training method according to claim 8, characterized in that: The target feature of the first sample image is a sample target feature vector represented in vector form; The modifying the target feature of the first sample image into an output modified feature corresponding to the imaging condition of the second sample image indicated by the sample modification instruction by using the feature modification model to be trained and based on the output visual language feature, comprises: Inputting the sample modification instruction into the embedding vector conversion model to be trained to obtain a sample modification instruction vector corresponding to the sample modification instruction; By means of a feature modification model to be trained and based on the output visual language feature and the sample modification instruction vector, the sample target feature vector is modified into an output modified feature corresponding to the imaging condition of the second sample image indicated by the sample modification instruction; The method further comprises: Based on the difference between the target feature of the second sample image and the output modified feature, the model parameters of the embedded vector conversion model to be trained are adjusted to obtain the trained embedded vector conversion model, and the embedded vector conversion model is used to convert the modification instruction into a modification instruction vector represented in vector form.
10. The model training method according to claim 9, characterized in that: The modifying the sample target feature vector into an output modified feature corresponding to the imaging condition of the second sample image indicated by the sample modification instruction by using the feature modification model to be trained and based on the output visual language feature and the sample modification instruction vector comprises: Inputting the output visual language feature into a first dimension conversion model to be trained to obtain a converted output visual language feature corresponding to the output visual language feature and having the same dimension as the sample modification instruction vector; Inputting the sample target feature vector into the second dimension conversion model to be trained, obtaining a converted sample target feature vector corresponding to the sample target feature vector and having the same dimension as the sample modification instruction vector; Inputting the converted output visual language feature, the sample modification instruction vector and the converted sample target feature vector into a feature modification model to be trained, and outputting an output modified feature vector of the converted sample target feature vector corresponding to the imaging condition of the second sample image indicated by the sample modification instruction; determining, according to the output modified feature vector, an output modified feature corresponding to the imaging condition of the second sample image indicated by the sample modification instruction; The method further comprises: Based on the difference between the target feature of the second sample image and the output modified feature, the model parameters of the first dimension conversion model to be trained and the second dimension conversion model to be trained are adjusted to obtain the trained first dimension conversion model and the trained second dimension conversion model.
11. An image feature processing device, characterized in that: The device comprises: A first acquisition unit, used for acquiring an image to be processed; An extraction unit, used for extracting target features of a preset feature type from the image to be processed; The first acquisition unit is further used to acquire a modification instruction described in natural language, the modification instruction is used to instruct to modify the target feature to a feature corresponding to a preset imaging condition, and to determine a visual language feature corresponding to the image to be processed based on a pre-trained visual language extraction model, and the visual language feature is used to represent the image to be processed through a vector; A modification unit is used to modify the target feature into a modified feature corresponding to the preset imaging condition indicated by the modification instruction based on the modification instruction, including: using a pre-trained feature modification model and based on the visual language feature, the target feature and the modification instruction, modifying the target feature into a modified feature corresponding to the preset imaging condition indicated by the modification instruction.
12. An image contrast device, characterized in that: The device also includes: A second acquisition unit, configured to acquire a feature to be compared corresponding to a preset feature type of the image to be compared, wherein the feature to be compared is a modified feature obtained by processing the image feature processing method according to any one of claims 1 to 6; A comparison unit is used to compare the feature to be compared with a reference feature of a reference image, and determine whether the image to be processed matches the reference image according to the comparison result, wherein the reference feature is a feature of the preset feature type corresponding to the reference image.
13. An electronic device, characterized in that: include: A processor, a memory, and computer program instructions stored on the memory and executable on the processor; When the processor executes the computer program instructions, the method according to any one of claims 1 to 10 is implemented.
14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement the method according to any one of claims 1 to 10.
