A method, apparatus and device for extracting color features from an image
By training an image feature extraction model and adjusting the model based on the color feature distance between positive and negative sample images, the problem of inaccurate image color similarity under the color histogram method is solved, achieving more accurate color feature extraction and improved search performance.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-29
- Publication Date
- 2026-03-13
AI Technical Summary
In existing technologies, when comparing image colors using color histograms, there are cases where two images have significantly different colors but similar histograms, leading to inaccurate search results in visual search scenarios.
An image feature extraction model is adopted. The trained image feature extraction model is adjusted based on the color feature distance between the first original image and the positive and negative sample images to extract more accurate color features and ensure that the color features reflect the actual color differences.
It improves search performance in visual search scenarios and enhances the qualitative and quantitative ranking capabilities of image color similarity through more accurate color feature representation.
Smart Images

Figure CN115393613B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, specifically to an image color feature extraction method, apparatus, and device. Background Technology
[0002] In a visual search scenario, by uploading a target image, one can search for the main object within that image. The search results will show various related objects, which are the same as or similar to the main object in the target image.
[0003] During the search process, the target image is compared with other images to obtain search results. Image color comparison is crucial for search results during image comparison. Specifically, by obtaining the color representation of the image and then comparing the color representations of different images, the degree of color similarity between them can be determined.
[0004] Currently, color histograms can be used to represent the color of target images or other images. However, there may be situations where the color histograms of two images are similar, while in reality the colors of the two images are quite different. This makes the color similarity between different images inaccurate, resulting in poor search performance in visual search scenarios. Summary of the Invention
[0005] In view of this, embodiments of this application provide an image color feature extraction method, apparatus, and device, which can accurately represent the color of an image by using the color features of the image output by the image color feature extraction model.
[0006] To achieve the above objectives, the technical solutions provided in this application are as follows:
[0007] Firstly, an image color feature extraction method is provided, the method comprising:
[0008] Acquire the target image;
[0009] The target image is input into an image feature extraction model to obtain the color features of the target image;
[0010] The image feature extraction model is trained based on a first distance between the color features of the first original image and the color features of the positive sample image, and a second distance between the color features of the first original image and the color features of the negative sample image; wherein, the positive sample image is the positive sample image corresponding to the first original image, and the negative sample image is the negative sample image corresponding to the first original image; the color similarity between the first original image and the positive sample image is greater than a first threshold, and the color similarity between the first original image and the negative sample image is less than a second threshold.
[0011] Secondly, an image color feature extraction device is provided, the device comprising:
[0012] The first acquisition unit is used to acquire the target image;
[0013] The second acquisition unit is used to input the target image into an image feature extraction model to obtain the color features of the target image;
[0014] The image feature extraction model is trained based on a first distance between the color features of the first original image and the color features of the positive sample image, and a second distance between the color features of the first original image and the color features of the negative sample image; wherein, the positive sample image is the positive sample image corresponding to the first original image, and the negative sample image is the negative sample image corresponding to the first original image; the color similarity between the first original image and the positive sample image is greater than a first threshold, and the color similarity between the first original image and the negative sample image is less than a second threshold.
[0015] Thirdly, an electronic device is provided, comprising:
[0016] One or more processors;
[0017] Storage device, on which one or more programs are stored,
[0018] When the one or more programs are executed by the one or more processors, the one or more processors implement the image color feature extraction method as described above.
[0019] Fourthly, a computer-readable medium is provided having a computer program stored thereon, wherein the program, when executed by a processor, implements the image color feature extraction method as described above.
[0020] Therefore, the embodiments of this application have the following beneficial effects:
[0021] This application provides an image color feature extraction method, apparatus, and device. The method involves acquiring a target image, inputting the target image into an image feature extraction model, and obtaining the color features of the target image. The image feature extraction model is trained based on a first distance between the color features of a first original image and the color features of a positive sample image, and a second distance between the color features of the first original image and the color features of a negative sample image. The positive sample image is the positive sample image corresponding to the first original image, and the negative sample image is the negative sample image corresponding to the first original image. The color similarity between the first original image and the positive sample image is greater than a first threshold, and the color similarity between the first original image and the negative sample image is less than the second threshold. It can be seen that when extracting color features from an image, if the colors of two images are similar in reality, the distance between the extracted color features of the two images is small; if the colors of two images are significantly different in reality, the distance between the extracted color features of the two images is also large. Thus, the color features of the target image extracted by the image feature extraction model provide a better representation of the target image's color. Using the color features output by the image feature extraction model to represent the color of an image can make the distance between the color features of different images match the actual color differences between different images, which is conducive to improving the search effect in visual search scenarios. Attached Figure Description
[0022] Figure 1 A schematic diagram illustrating an exemplary application scenario provided in this application embodiment;
[0023] Figure 2 A flowchart illustrating a training method for an image color feature extraction model provided in an embodiment of this application;
[0024] Figure 3 A schematic diagram illustrating another exemplary application scenario provided by an embodiment of this application;
[0025] Figure 4 A flowchart of a supervised training image color feature extraction model provided in this application embodiment;
[0026] Figure 5 A flowchart illustrating an image color feature extraction method provided in this application embodiment;
[0027] Figure 6 This is a schematic diagram of the structure of an image color feature extraction device provided in an embodiment of this application;
[0028] Figure 7 This is a schematic diagram of the basic structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0029] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, the embodiments of this application will be further described in detail below with reference to the accompanying drawings and specific implementation methods.
[0030] To facilitate understanding and explanation of the technical solutions provided in the embodiments of this application, the background technology of this application will be described first.
[0031] In visual search scenarios, by uploading a target image, one can search for the main object within that image. Search results include various related objects, which are identical or similar to the main object in the target image. One example of a visual search scenario is e-commerce visual search, where the target image is a product image, and the main object within that image is the target product. Search results can include products from various related product links, where the products in those links are identical or similar to the target product. Additionally, visual search can also be used for pedestrian search under cameras; this will not be detailed here and can be configured according to specific needs.
[0032] During the search process, the target image is compared with other images to obtain the comparison results. Search results are then displayed based on these results. For example, search results can be displayed according to the degree of relevance of the comparison results. In the image comparison process, color comparison is crucial for search results. For example, in e-commerce visual search scenarios, when the main object is clothing, comparing the colors of the clothing helps to find similar items. Specifically, the color representation of the image is obtained, and then image color comparison is performed based on the color representations of different images to obtain the degree of color similarity between the different images.
[0033] Currently, color histograms can be used to represent the color of target images or other images. However, there may be situations where the color histograms of two images are similar, while in reality the colors of the two images are quite different. This makes the color similarity between different images inaccurate, resulting in poor search performance in visual search scenarios.
[0034] Based on this, embodiments of this application provide an image color feature extraction method, apparatus, and device. The method involves acquiring a target image, inputting the target image into an image feature extraction model, and obtaining the color features of the target image. The image feature extraction model is trained based on a first distance between the color features of a first original image and the color features of a positive sample image, and a second distance between the color features of the first original image and the color features of a negative sample image. The positive sample image is the positive sample image corresponding to the first original image, and the negative sample image is the negative sample image corresponding to the first original image. The color similarity between the first original image and the positive sample image is greater than a first threshold, and the color similarity between the first original image and the negative sample image is less than a second threshold.
[0035] It can be seen that the image feature extraction model adjusted to target a first distance less than a second distance, when extracting color features from images, shows a smaller distance between the extracted color features if the colors of two images are similar in reality, and a larger distance if the colors of two images differ significantly in reality. Thus, the color features extracted by the image feature extraction model provide a good representation of the target image's color. Using the color features output by the image feature extraction model to represent the color of an image ensures that the distance between the color features of different images matches the actual color differences between them, thus improving search performance in visual search scenarios.
[0036] To facilitate understanding, this application first provides an exemplary description of the training method for the image color feature extraction model.
[0037] To facilitate understanding of the training method for the image color feature extraction model provided in the embodiments of this application, the following is combined with... Figure 1 The example scenario is shown below. See also... Figure 1 As shown in the figure, this figure is a schematic diagram of an exemplary application scenario provided in the embodiments of this application.
[0038] In practical applications, a first original image, a corresponding positive sample image, and a corresponding negative sample image are obtained. The positive and negative sample images are obtained after image data augmentation of the first original image. Specifically, the color similarity between the first original image and the positive sample image is greater than a first threshold, while the color similarity between the first original image and the negative sample image is less than a second threshold. This can be understood, for example, as the colors of the first original image and the positive sample image being relatively similar, while the colors of the first original image and the negative sample image being significantly different.
[0039] Then, the first original image, the positive sample image, and the negative sample image are input into the image feature extraction model to obtain the color features of the first original image, the positive sample image, and the negative sample image. A first distance is calculated between the color features of the first original image and the color features of the positive sample image, and a second distance is calculated between the color features of the first original image and the color features of the negative sample image. When the colors of the first original image and the positive sample image are similar, and the colors of the first original image and the negative sample image differ significantly, the first distance will be smaller than the second distance.
[0040] Based on this, with the objective of the first distance being less than the second distance, a first loss value is calculated, and the image feature extraction model is adjusted according to the first loss value.
[0041] Those skilled in the art will understand that Figure 1The schematic diagram shown is merely one example in which embodiments of this application can be implemented. The scope of application of the embodiments of this application is not limited by any aspect of this framework.
[0042] To facilitate understanding of this application, the following description, in conjunction with the accompanying drawings, illustrates a training method for an image color feature extraction model provided in an embodiment of this application.
[0043] See Figure 2 As shown, this figure is a flowchart of a training method for an image color feature extraction model provided in an embodiment of this application. Figure 2 As shown, the training process of the image feature extraction model may include S201-S205:
[0044] S201: Obtain the first original image, the positive sample image corresponding to the first original image, and the negative sample image corresponding to the first original image; the color similarity between the first original image and the positive sample image is greater than a first threshold, and the color similarity between the first original image and the negative sample image is less than a second threshold.
[0045] A first original image is obtained, and image data augmentation is performed on the first original image to obtain a positive sample image and a negative sample image corresponding to the first original image. The first original image can be understood as a reference image for the positive and negative sample images.
[0046] Specifically, if the color similarity between the first original image and the positive sample image is greater than a first threshold, it can be understood that the overall color of the first original image is relatively similar to the overall color of the positive sample image. If the color similarity between the first original image and the negative sample image is less than a second threshold, it can be understood that the overall color of the first original image is significantly different from the overall color of the negative sample image. The first and second thresholds are determined based on the actual situation and are not limited here.
[0047] The first original image includes a main object, which is an object that occupies a large proportion of the first original image and is of interest to the user. For example, when the image is a product image, the first original image could be an image of a top, in which case the main object is the top. The first original image could also be an image of bottoms, in which case the main object is the bottoms. Both tops and bottoms can be understood as products. It is understood that the embodiments of this application do not limit the original image and the main object in the image. As long as the image needs to be represented by color, the image can be used as the first original image.
[0048] In one possible implementation, embodiments of this application provide a specific implementation method for obtaining a first original image, a positive sample image corresponding to the first original image, and a negative sample image corresponding to the first original image, including:
[0049] A1: Obtain the first original image.
[0050] The first original image is a reference image, and the number of first original images is at least one.
[0051] A2: Perform a first image transformation on the first original image to generate a positive sample image corresponding to the first original image.
[0052] A first image transformation is performed on the first original image to generate a positive sample image corresponding to the first original image.
[0053] In one or more embodiments, the first image transformation includes performing a light and shadow transformation on the first original image and / or a contrast transformation on the first original image to simulate the changes in the first original image under normal lighting and contrast changes.
[0054] Understandably, the first image is transformed with a relatively slight change, making the colors of the first original image and the positive sample image quite similar.
[0055] A3: Perform a second image transformation on the first original image to generate a negative sample image corresponding to the first original image.
[0056] A second image transformation is performed on the first original image to generate a negative sample image corresponding to the first original image.
[0057] In one or more embodiments, the second image transformation includes cropping the first original image and / or color inverting the first original image to simulate a situation where the color of the first original image changes significantly due to external factors. It is understood that the second image transformation involves a large-scale change, resulting in a significant color difference between the first original image and the negative sample image.
[0058] Based on the content of A1-A3, we know that image data augmentation is performed on the first original image to obtain positive sample images and negative sample images. Training the image feature extraction model based on the first original image, positive sample images, and negative sample images enables the model to adapt to various situations where the first original image experiences changes in lighting and contrast, as well as significant color changes due to external factors. This makes the image feature extraction model more robust in extracting image color features.
[0059] S202: Input the first original image, the positive sample image, and the negative sample image into the image feature extraction model to obtain the color features of the first original image, the color features of the positive sample image, and the color features of the negative sample image.
[0060] In this embodiment, the image feature extraction model is used to extract the color features of the input image. After obtaining the first original image, the positive sample image, and the negative sample image, these images are input into the image feature extraction model to obtain the color features of the first original image, the positive sample image, and the negative sample image output by the model. The color features of the first original image can be represented by the feature vector v. o The color features of a positive sample image can be represented using a feature vector v. p The color features of negative sample images can be represented using a feature vector v. n To represent. v o v p and v n It can be a one-dimensional feature vector; no restriction is imposed here.
[0061] In practical applications, the first original image, positive sample image, and negative sample image can be input into the image feature extraction model simultaneously or separately; no limitation is imposed here.
[0062] As an alternative example, the image feature extraction model can be implemented using a deep neural network, such as the ResNet50 convolutional neural network.
[0063] S203: Calculate the first distance between the color features of the first original image and the color features of the positive sample image, and the second distance between the color features of the first original image and the color features of the negative sample image.
[0064] When the color features of the first original image, the color features of the positive sample image, and the color features of the negative sample image are all represented by feature vectors, the first distance is the distance between the feature vector corresponding to the color features of the first original image and the feature vector corresponding to the color features of the positive sample image. The first distance can be represented by dist(v o ,v p The second distance is represented as dist(v). The second distance is the distance between the feature vector corresponding to the color features of the first original image and the feature vector corresponding to the color features of the negative sample image. The second distance can be represented by dist(v). o ,v n ) is used to represent.
[0065] The first distance represents the similarity between the color features of the first original image and the color features of the positive sample image; the greater the similarity, the smaller the first distance. The second distance represents the similarity between the color features of the first original image and the color features of the negative sample image; the smaller the similarity, the larger the second distance. Optionally, the first distance dist(v) o ,v p) and the second distance dist(v o ,v n The distance can be calculated using the vector distance formula.
[0066] S204: Calculate the first loss value with the objective that the first distance is less than the second distance.
[0067] The first distance is the distance between the color features of the first original image and the color features of the positive sample image, and the second distance is the distance between the color features of the first original image and the color features of the negative sample image. Since in this embodiment, the overall color of the first original image is set to be relatively similar to the overall color of the positive sample image, and the overall color of the first original image is set to be significantly different from the overall color of the negative sample image, the first distance should be less than the second distance to satisfy the actual color situation of the first original image, the positive sample image, and the negative sample image.
[0068] Based on this, with the objective of the first distance being less than the second distance, the first loss value is calculated.
[0069] In one possible implementation, this application provides a specific method for calculating a first loss value with the objective of a first distance being less than a second distance, including:
[0070] B1: Calculate the difference between the first distance and the second distance, and then add it to the third threshold to obtain the target value; the third threshold is greater than zero.
[0071] The difference between the first and second distances can be expressed as dist(v) o ,v p )-dist(v o ,v n The third threshold can be represented by m, which is a positive hyperparameter, i.e., a hyperparameter greater than zero. Therefore, the target value is dist(v). o ,v p )-dist(v o ,v n )+m.
[0072] B2: The larger value between the target value and zero is determined as the first loss value.
[0073] In one possible implementation, the larger value between the target value and zero is determined as the first loss value. When the number of positive and negative sample images is one each, the formula for calculating the first loss value, loss1, is as follows:
[0074] loss1 = max(dist(v) o ,v p )-dist(v o ,v n)+m,0)
[0075] It is understandable that when the first distance is less than the second distance, the difference between the first distance and the second distance, dist(v), is... o ,v p )-dist(v o ,v n If the difference between the second distance and the first distance is less than the third threshold m, then the first loss value loss1 is set to dist(v). o ,v p )-dist(v o ,v n If the difference between the second distance and the first distance is greater than or equal to the third threshold m, then the first loss value loss1 is set to 0. Based on this, by training the image feature extraction model, the first loss value is adjusted to approach zero to control the first distance to be less than the second distance and to control the difference between the second distance and the first distance to be greater than or equal to the third threshold.
[0076] This ensures that the distance difference between the first distance and the second distance is sufficiently large, so that the distance between the color features of the first original image and the color features of the positive sample image is sufficiently small, and the distance between the color features of the first original image and the color features of the negative sample image is sufficiently large. Since the color difference between the first original image and the positive sample image is small in reality, and the color difference between the first original image and the negative sample image is large in reality, this makes the distance between the color features of the two images output by the image feature extraction model approximately the same as the actual color difference between the two images, satisfying the actual situation, and resulting in good color representation of the color features output by the image feature extraction model.
[0077] In one possible implementation, when the number of positive and negative sample images is k and k = 1,...,n, the formula for calculating the first loss value loss1 can also be expressed as follows:
[0078]
[0079] in, For the k-th positive sample image, Let k be the k-th negative sample image.
[0080] Based on the content of B1-B3, it can be seen that by setting the first loss value, the image feature extraction model can better represent the color features of the image during the training process, achieve good image color distinguishability, and meet practical needs.
[0081] S205: Adjust the image feature extraction model based on the first loss value.
[0082] After obtaining the first loss value, the model parameters of the image feature extraction model are adjusted based on the first loss value to achieve training of the image feature extraction model. After the adjustment is completed, the model parameters of the image feature extraction model are saved.
[0083] It is understandable that the process of training the image feature extraction model in S201-S205 is an unsupervised learning method, or what can be understood as a self-supervised learning method. That is, no manual annotation is performed on the first original image, the corresponding positive sample image, or the corresponding negative sample image; the first original image, the corresponding positive sample image, and the corresponding negative sample image themselves serve as the labels required for self-supervised learning. In this way, the cost of manual annotation can be reduced, and the model training efficiency can be improved.
[0084] It should be noted that, as an optional example, when the image is a product image, the first original image in this embodiment is preferably an image with complex textures and numerous patterns on the main object. For example, the first original image is an image where the texture complexity of the main object is greater than a complexity threshold and the number of patterns is greater than a quantity threshold. Training the image feature extraction model using a self-supervised learning method can result in better color feature extraction of the first original image that meets the above conditions. Alternatively, the first original image can also be an image where the texture of the main object is not complex, the patterns are not numerous, and the color of the main object is simple and clear. For example, when the main object of the first original image is a shirt, the shirt is pure black and has no patterns. It is understood that this embodiment does not limit the first original image.
[0085] Based on the above content of S201-S205, it is known that when the image feature extraction model adjusted with the objective of the first distance being less than the second distance is used to extract color features from an image, if the colors of two images are similar in reality, the distance between the extracted color features of the two images will be small; conversely, if the colors of two images are significantly different in reality, the distance between the extracted color features of the two images will be large. Thus, using the color features output by the image feature extraction model provided in this application embodiment to represent the color of an image allows the distance between the color features of different images to reflect the color differences between different images in reality. Furthermore, it can reflect the qualitative ranking relationship of the similarity between the colors of different images, that is, the ranking of the differences between the colors of different images. This facilitates improved search performance in visual search scenarios.
[0086] After obtaining the image color feature extraction model of the above embodiments, the distance between color features of different images output by the model can be used to qualitatively reflect the difference between colors in different images. However, using the distance between different color features as a quantitative result of the difference between colors in different images is not very effective. Therefore, it is necessary to further optimize the training of the image color feature extraction model by combining supervised learning with manual labeling, so that the distance between different color features output by the trained image color feature extraction model is more accurate.
[0087] To facilitate understanding of the training method for the image color feature extraction model provided in the embodiments of this application, the following is combined with... Figure 3 The example scenario is shown below. See also... Figure 3 As shown in the figure, this figure is a schematic diagram of another exemplary application scenario provided by the embodiments of this application.
[0088] In practical applications, a second original image is obtained. When there are two second original images, they are denoted as the first second original image and the second second original image. The color values of the main object in the first second original image and the color values of the main object in the second second original image are obtained. The second original image is also used to train the image color feature extraction model.
[0089] Calculate the color difference between the main object in the first and second original images to obtain the color difference value. Input the first and second original images into the image feature extraction model to obtain the color features of the first and second original images. Calculate the third distance between the color features of the first and second original images.
[0090] The second loss value is calculated based on the difference between the third distance and the color difference. The image feature extraction model is then adjusted based on the second loss value.
[0091] Those skilled in the art will understand that Figure 3 The schematic diagram shown is merely one example in which embodiments of this application can be implemented. The scope of application of the embodiments of this application is not limited by any aspect of this framework.
[0092] See Figure 4 , Figure 4 This is a flowchart illustrating a supervised training model for image color feature extraction, provided as an embodiment of this application. Figure 4 As shown, in addition to S201-S205, the training process of the image color feature extraction model can also include S401-S406:
[0093] S401: Obtain the second original image and the color value of the main object in the second original image.
[0094] The second original image is similar to the first original image, and it also contains a main object. For example, if the second original image is a top image in a product image, the main object is the top. In this embodiment, the second original image is preferably an image where the texture of the main object is not complex, the patterns are not numerous, and the color of the main object is simple and clear. For example, the color of the top is pure black without any patterns, or the color of the top is pure red without any patterns. A person can clearly distinguish the color of the main object in different second original images. Images with complex textures and numerous patterns are preferred as the first original image in the above embodiment.
[0095] The second set of original images consists of at least two images. The color values of the main subject objects in these images are then extracted. These color values represent the color of the subject object; for example, the color values can be RGB values, Lab values, etc.
[0096] In one possible implementation, this application provides a specific method for obtaining a second original image and obtaining the color values of the main object in the second original image, including:
[0097] C1: Obtain the second original image.
[0098] C2: Extract the RGB color values of the main object in the second original image.
[0099] For each second original image, extract the RGB color values of the main object in the second original image. As an optional example, a color picker tool can be used to extract the RGB color values of the main object in the second original image.
[0100] C3: Converts RGB color values to Lab color space values as the color values of the main object in the second original image.
[0101] After obtaining the RGB color values of the main object, the RGB color values of the main object are converted into Lab color space values, and the Lab color space values of the main object are used as the color values of the main object in the second original image.
[0102] In practice, the RGB color values of multiple pixels of the main object in the second original image can be obtained, and then the average value of the RGB color values of the multiple pixels can be taken. The RGB color values in step C3 are the average values. Then, the average value is converted into a Lab color space value, and the Lab color space value is used as the color value of the main object in the second original image.
[0103] It is understandable that the Lab color space describes all the colors that a person with normal vision can see. Therefore, using Lab color space values as the color representation of the main object can conform to the differences in human visual perception and meet practical needs.
[0104] S402: Calculate the difference in color values of the main object in the two second original images to obtain the color difference value.
[0105] As an alternative example, when there are two second original images, the first second original image can be represented by x, and the second second original image can be represented by y.
[0106] The color values of the main object in the first and second original images can be labeled. x To represent this, the color values of the main object in the second original image can be represented using labels. y The color difference can be represented by ΔE, i.e., ΔE = label. x -label y .
[0107] It is understandable that if the color values of the main object in the second original image are the true values, then the color difference obtained by the difference in color values can be used as the label value for manual annotation used to train the image feature extraction model.
[0108] S403: Input the two second original images into the image feature extraction model to obtain the color features of the two second original images.
[0109] The two second original images are input into the image feature extraction model simultaneously or separately to obtain the color features of the two second original images.
[0110] The color features of the first and second original images can be obtained using v x The color features of the second original image can be represented using v. y This is represented. It can be understood that the color features of the second original image are the output of the image feature extraction model, and are the predicted values.
[0111] S404: Calculate the third distance between the color features of the two second original images.
[0112] After acquiring the color features of two second original images, a third distance is calculated between the color features of the two second original images. This third distance can be represented by d. x,y =dist(v x ,v y This is represented as follows. It is understandable that, compared to the color difference obtained from S402, the third distance is a predicted value of the color difference.
[0113] S405: Calculate the second loss value based on the difference between the third distance and the color difference.
[0114] After obtaining the difference between the third distance and the color, a second loss value is calculated based on this difference. As an optional example, the second loss value, loss2, is the absolute value of the difference between the third distance and the color, and can be expressed as...
[0115] When the image feature extraction model is trained using multiple sets of second original images, with each set including two second original images, the second loss value loss2 can also be expressed as: Where k1 is the number of groups and k1 = 1,...,n.
[0116] S406: Adjust the image feature extraction model based on the second loss value.
[0117] The model parameters of the image feature extraction model are adjusted based on the second loss value to train the image feature extraction model. After adjustment, the model parameters of the image feature extraction model are saved.
[0118] Adjusting the image feature extraction model using the second loss value ensures that the distance between color features in different images output by the model is sufficiently similar to the color difference in manually labeled images, thereby improving the accuracy of color representation in the output color features. As an alternative example, the model can be adjusted several times using the first loss value over a period of time, followed by adjustment using the second loss value. Alternatively, the model can be adjusted several times using the second loss value over a period of time, followed by adjustment using the first loss value. Or, the model can be adjusted simultaneously using both the first and second loss values.
[0119] Understandably, since the image feature extraction model is trained using the second loss value in steps S401-S406, adjusting the model based on this second loss value ensures that the distances between the color features of different images output by the model are sufficiently similar to the manually labeled color differences. Therefore, the distances between the color features of different images output by the adjusted image feature extraction model (S401-S406) can be used to quantitatively represent the differences in color between different images with high accuracy.
[0120] It is also understandable that the process of training the image feature extraction model in S401-S406 is a supervised learning method. When the image feature extraction model is trained by combining the unsupervised learning method in S201-S205 and the supervised method in S401-S406, the training process can be understood as a semi-supervised learning method. It is evident that manually annotating some original images and not manually annotating others can reduce the difficulty and cost of manual annotation.
[0121] Based on the training method of the image color feature extraction model provided in the above-described embodiments, this application provides an image color feature extraction method. The image color feature extraction method provided in this application is described below with reference to the accompanying drawings.
[0122] See Figure 5 As shown, this figure is a flowchart of an image color feature extraction method provided in an embodiment of this application. Figure 5 As shown, the method may include S501-S502:
[0123] S501: Acquire the target image.
[0124] The target image is the image from which color features are to be extracted, and there can be multiple target images. As an optional example, in an e-commerce visual search scenario, the target images can be images provided to the user.
[0125] S502: Input the target image into the image feature extraction model to obtain the color features of the target image.
[0126] The image feature extraction model is trained based on a first distance between the color features of the first original image and the color features of the positive sample image, and a second distance between the color features of the first original image and the color features of the negative sample image. The positive sample image is the positive sample image corresponding to the first original image, and the negative sample image is the negative sample image corresponding to the first original image. The color similarity between the first original image and the positive sample image is greater than a first threshold, and the color similarity between the first original image and the negative sample image is less than a second threshold. In other words, the image feature extraction model is trained according to the training method of the image color feature extraction model in any of the above embodiments.
[0127] The target image is input into the image feature extraction model to obtain the color features of the target image output by the image feature extraction model.
[0128] The image feature extraction model trained using the unsupervised learning methods in S201-S205, or the image feature extraction model trained using the unsupervised learning methods in S201-S205 combined with the supervised learning methods in S401-S406, can extract color features from a target image, and the extracted color features can be used as the color representation of the target image with good representation effect.
[0129] In one possible implementation, when the target image is available to the user, the user initiates a search request for the target image in order to obtain objects that are the same as or similar to the main object in the target image. Based on this, the method further includes:
[0130] D1: In response to an image retrieval request for a target image, retrieve retrieval results including the recalled image.
[0131] As an optional example, after a user uploads a target image, an image retrieval request for the target image can be initiated by triggering a retrieval control. In response to the image retrieval request for the target image, retrieval results, including recalled images, are obtained. The relevant objects in the recalled images and the main object in the target image are the same or similar.
[0132] D2: Input the recalled image into the image feature extraction model to obtain the color features of the recalled image.
[0133] The recalled image is input into the image feature extraction model to extract color features from the recalled image and obtain the color features of the recalled image.
[0134] D3: Calculate the fourth distance between the color features of the target image and the color features of the recalled image, and sort the recalled images according to the fourth distance.
[0135] After obtaining the color features of the target image and the recall image, a fourth distance is calculated between their color features. The fourth distance represents the similarity between the color features of the target image and the color features of the recall image; the greater the similarity, the smaller the fourth distance.
[0136] It is understandable that, since the main object occupies a large proportion of the target image, the color features of the target image can be understood as the color features of the main object, and the recall image is similar. The similarity between the color features of the target image and the color features of the recall image can be understood as the color similarity between the main object in the target image and the relevant objects in the recall image.
[0137] The recalled images can then be sorted based on the fourth distance. For example, if the recalled images are sorted in ascending order of the fourth distance, the user can prioritize viewing recalled images with a high degree of color similarity to the target image. The related objects in the recalled images with a high degree of similarity to the target image have a high degree of color similarity to the main object in the target image.
[0138] In one possible implementation, when the image feature extraction model is trained using the unsupervised learning methods of S201-S205 combined with the supervised learning methods of S401-S406, the recalled images corresponding to the fourth distance being greater than the fourth threshold can also be filtered.
[0139] Understandably, when the image feature extraction model is trained using a combination of unsupervised learning methods (S201-S205) and supervised learning methods (S401-S406), the fourth distance is a quantitative result of the color difference between the target image and the recalled image. This quantitative result is relatively accurate, and the recalled images can be filtered based on the fourth distance and the fourth threshold. Specifically, since the recalled images with a fourth distance greater than the fourth threshold have a lower similarity to the target image, these recalled images are filtered out, i.e., removed.
[0140] Based on the image color feature extraction method provided in the above-described embodiments, this application also provides an image color feature extraction device, which will be described below with reference to the accompanying drawings. Since the principle by which the device in this disclosure solves the problem is similar to the image color feature extraction method described above in this application, the implementation of the device can refer to the implementation of the method, and repeated details will not be elaborated further.
[0141] See Figure 6 As shown, this figure is a schematic diagram of the structure of an image color feature extraction device provided in an embodiment of this application. Figure 6 As shown, the image color feature extraction device includes:
[0142] The first acquisition unit 601 is used to acquire the target image;
[0143] The second acquisition unit 602 is used to input the target image into an image feature extraction model to obtain the color features of the target image; the image feature extraction model is trained based on a first distance between the color features of the first original image and the color features of the positive sample image, and a second distance between the color features of the first original image and the color features of the negative sample image; wherein, the positive sample image is the positive sample image corresponding to the first original image, and the negative sample image is the negative sample image corresponding to the first original image; the color similarity between the first original image and the positive sample image is greater than a first threshold, and the color similarity between the first original image and the negative sample image is less than a second threshold.
[0144] In one possible implementation, the apparatus further includes a training unit, the training unit comprising:
[0145] The first acquisition subunit is used to acquire a first original image, a positive sample image corresponding to the first original image, and a negative sample image corresponding to the first original image; the second acquisition subunit is used to input the first original image, the positive sample image, and the negative sample image into an image feature extraction model to obtain the color features of the first original image, the color features of the positive sample image, and the color features of the negative sample image.
[0146] The first calculation subunit is used to calculate a first distance between the color features of the first original image and the color features of the positive sample image, and a second distance between the color features of the first original image and the color features of the negative sample image;
[0147] The second calculation subunit is used to calculate the first loss value with the objective that the first distance is less than the second distance;
[0148] The first adjustment subunit is used to adjust the image feature extraction model according to the first loss value.
[0149] In one possible implementation, the first acquisition subunit includes:
[0150] The third acquisition subunit is used to acquire the first original image;
[0151] The first transformation subunit is used to perform a first image transformation on the first original image to generate a positive sample image corresponding to the first original image;
[0152] The second transformation subunit is used to perform a second image transformation on the first original image to generate a negative sample image corresponding to the first original image.
[0153] In one possible implementation, the second computational subunit includes:
[0154] The third calculation subunit is used to calculate the difference between the first distance and the second distance, and then add it to the third threshold to obtain the target value; the third threshold is greater than zero.
[0155] A sub-unit is defined to determine the larger value between the target value and zero as the first loss value.
[0156] In one possible implementation, the training unit further includes:
[0157] The fourth acquisition subunit is used to acquire the second original image and acquire the color values of the main object in the second original image;
[0158] The fourth calculation subunit is used to calculate the difference in color values of the main object in the two second original images to obtain the color difference value;
[0159] The fifth acquisition subunit is used to input the two second original images into the image feature extraction model to obtain the color features of the two second original images;
[0160] The fifth calculation subunit is used to calculate the third distance between the color features of the two second original images;
[0161] The sixth calculation subunit is used to calculate the second loss value based on the difference between the third distance and the color difference;
[0162] The second adjustment subunit is used to adjust the image feature extraction model according to the second loss value.
[0163] In one possible implementation, the fourth acquisition subunit includes:
[0164] The sixth acquisition subunit is used to acquire the second original image;
[0165] An extraction subunit is used to extract the RGB color values of the main object in the second original image;
[0166] The conversion subunit is used to convert the RGB color values into Lab color space values as the color values of the main object in the second original image.
[0167] In one possible implementation, the device further includes:
[0168] The third acquisition unit is used to acquire retrieval results, including the recalled image, in response to an image retrieval request for the target image.
[0169] The fourth acquisition unit is used to input the recalled image into the image feature extraction model to obtain the color features of the recalled image;
[0170] The calculation unit is used to calculate a fourth distance between the color features of the target image and the color features of the recalled image, and to sort the recalled images according to the fourth distance.
[0171] In one possible implementation, when the image feature extraction model is based on the above... Figure 4 The apparatus, trained using the method corresponding to the embodiment, further includes:
[0172] The filtering unit is used to filter the recall images corresponding to the fourth distance being greater than the fourth threshold.
[0173] Based on the image color feature extraction method provided in the above method embodiments, this application also provides an electronic device, including: one or more processors; a storage device storing one or more programs thereon, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the image color feature extraction method described in any of the above embodiments.
[0174] The following is for reference. Figure 7 The diagram illustrates a structural schematic of an electronic device 1300 suitable for implementing embodiments of this application. The terminal devices in these embodiments may include, but are not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Android Devices), PMPs (Portable Media Players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs (televisions), desktop computers, etc. Figure 7 The electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.
[0175] like Figure 7 As shown, electronic device 1300 may include a processing device (e.g., a central processing unit, a graphics processor, etc.) 1301, which can perform various appropriate actions and processes according to a program stored in read-only memory (ROM) 1302 or a program loaded from storage device 1306 into random access memory (RAM) 1303. RAM 1303 also stores various programs and data required for the operation of electronic device 1300. Processing device 1301, ROM 1302, and RAM 1303 are interconnected via bus 1304. Input / output (I / O) interface 1305 is also connected to bus 1304.
[0176] Typically, the following devices can be connected to I / O interface 1305: input devices 1306 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 1307 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 1306 including, for example, magnetic tapes, hard disks, etc.; and communication devices 1309. Communication device 1309 allows electronic device 1300 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 7 An electronic device 1300 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively.
[0177] Specifically, according to embodiments of this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this application include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication device 1309, or installed from storage device 1306, or installed from ROM 1302. When the computer program is executed by processing device 1301, it performs the functions defined in the methods of embodiments of this application.
[0178] The electronic device provided in this application embodiment and the image color feature extraction method provided in the above embodiment belong to the same inventive concept. Technical details not described in detail in this embodiment can be found in the above embodiment, and this embodiment has the same beneficial effects as the above embodiment.
[0179] Based on the image color feature extraction method provided in the above embodiments, this application provides a computer-readable medium storing a computer program thereon, wherein the program, when executed by a processor, implements the image color feature extraction method as described in any of the above embodiments.
[0180] It should be noted that the computer-readable medium described above in this application can be a computer-readable signal medium, a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this application, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this application, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.
[0181] In some implementations, clients and servers can communicate using any currently known or future-developed network protocol such as HTTP (Hypertext Transfer Protocol) and can interconnect with digital data communication (e.g., communication networks) of any form or medium. Examples of communication networks include local area networks (“LANs”), wide area networks (“WANs”), the Internet (e.g., the Internet of Things), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future-developed networks.
[0182] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device.
[0183] The aforementioned computer-readable medium carries one or more programs, which, when executed by the electronic device, cause the electronic device to perform the aforementioned image color feature extraction method.
[0184] Computer program code for performing the operations of this application can be written in one or more programming languages or a combination thereof. These programming languages include, but are not limited to, object-oriented programming languages such as Java, Smalltalk, and C++, as well as conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0185] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0186] The units described in the embodiments of this application can be implemented in software or in hardware. The name of the unit / module does not necessarily limit the unit itself; for example, a voice data acquisition module can also be described as a "data acquisition module".
[0187] The functions described above in this document can be performed, at least in part, by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: Field Programmable Gate Arrays (FPGAs), Application-Specific Integrated Circuits (ASICs), Application Standard Products (ASSPs), System-on-Chip (SoCs), Complex Programmable Logic Devices (CPLDs), and so on.
[0188] In the context of this application, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. Machine-readable media can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0189] According to one or more embodiments of this application, [Example 1] provides an image color feature extraction method, the method comprising:
[0190] Acquire the target image;
[0191] The target image is input into an image feature extraction model to obtain the color features of the target image. The image feature extraction model is trained based on a first distance between the color features of the first original image and the color features of the positive sample image, and a second distance between the color features of the first original image and the color features of the negative sample image. The positive sample image is the positive sample image corresponding to the first original image, and the negative sample image is the negative sample image corresponding to the first original image. The color similarity between the first original image and the positive sample image is greater than a first threshold, and the color similarity between the first original image and the negative sample image is less than a second threshold.
[0192] According to one or more embodiments of this application, [Example 2] provides an image color feature extraction method, wherein the training process of the image feature extraction model includes:
[0193] Obtain the first original image, the positive sample image corresponding to the first original image, and the negative sample image corresponding to the first original image;
[0194] The first original image, the positive sample image, and the negative sample image are input into the image feature extraction model to obtain the color features of the first original image, the color features of the positive sample image, and the color features of the negative sample image.
[0195] Calculate a first distance between the color features of the first original image and the color features of the positive sample image, and a second distance between the color features of the first original image and the color features of the negative sample image;
[0196] Calculate the first loss value with the objective that the first distance is less than the second distance;
[0197] The image feature extraction model is adjusted based on the first loss value.
[0198] According to one or more embodiments of this application, [Example 3] provides an image color feature extraction method, wherein obtaining a first original image, a positive sample image corresponding to the first original image, and a negative sample image corresponding to the first original image includes:
[0199] Obtain the first original image;
[0200] A first image transformation is performed on the first original image to generate a positive sample image corresponding to the first original image;
[0201] A second image transformation is performed on the first original image to generate a negative sample image corresponding to the first original image.
[0202] According to one or more embodiments of this application, [Example 4] provides an image color feature extraction method, wherein calculating a first loss value with the objective that the first distance is less than the second distance includes:
[0203] Calculate the difference between the first distance and the second distance, and then add it to the third threshold to obtain the target value; the third threshold is greater than zero.
[0204] The larger value between the target value and zero is determined as the first loss value.
[0205] According to one or more embodiments of this application, [Example 5] provides an image color feature extraction method, wherein the training process of the image feature extraction model further includes:
[0206] Obtain the second original image, and then obtain the color values of the main object in the second original image;
[0207] Calculate the difference in color values of the main object in the two second original images to obtain the color difference value;
[0208] The two second original images are input into the image feature extraction model to obtain the color features of the two second original images;
[0209] Calculate the third distance between the color features of the two second original images;
[0210] Calculate the second loss value based on the difference between the third distance and the color difference;
[0211] The image feature extraction model is adjusted based on the second loss value.
[0212] According to one or more embodiments of this application, [Example Six] provides an image color feature extraction method, wherein obtaining a second original image and obtaining the color values of the main object in the second original image includes:
[0213] Obtain the second original image;
[0214] Extract the RGB color values of the main object from the second original image;
[0215] The RGB color values are converted to Lab color space values and used as the color values of the main object in the second original image.
[0216] According to one or more embodiments of this application, [Example Seven] provides an image color feature extraction method, the method further comprising:
[0217] In response to an image retrieval request for the target image, retrieve retrieval results including the recalled image;
[0218] The recalled image is input into the image feature extraction model to obtain the color features of the recalled image;
[0219] Calculate a fourth distance between the color features of the target image and the color features of the recalled image, and sort the recalled images according to the fourth distance.
[0220] According to one or more embodiments of this application, [Example Eight] provides an image color feature extraction method, wherein when the image feature extraction model is trained according to the method described in Example Five or Example Six above, the method further includes:
[0221] The recalled images corresponding to the fourth distance being greater than the fourth threshold are filtered.
[0222] According to one or more embodiments of this application, [Example Nine] provides an image color feature extraction apparatus, the apparatus comprising:
[0223] The first acquisition unit is used to acquire the target image;
[0224] The second acquisition unit is used to input the target image into an image feature extraction model to obtain the color features of the target image; the image feature extraction model is trained based on a first distance between the color features of the first original image and the color features of the positive sample image, and a second distance between the color features of the first original image and the color features of the negative sample image; wherein, the positive sample image is the positive sample image corresponding to the first original image, and the negative sample image is the negative sample image corresponding to the first original image; the color similarity between the first original image and the positive sample image is greater than a first threshold, and the color similarity between the first original image and the negative sample image is less than a second threshold.
[0225] According to one or more embodiments of this application, [Example 10] provides an image color feature extraction apparatus, the apparatus further comprising a training unit, the training unit including:
[0226] The first acquisition subunit is used to acquire a first original image, a positive sample image corresponding to the first original image, and a negative sample image corresponding to the first original image; the color similarity between the first original image and the positive sample image is greater than a first threshold, and the color similarity between the first original image and the negative sample image is less than a second threshold.
[0227] The second acquisition subunit is used to input the first original image, the positive sample image, and the negative sample image into the image feature extraction model to obtain the color features of the first original image, the color features of the positive sample image, and the color features of the negative sample image;
[0228] The first calculation subunit is used to calculate a first distance between the color features of the first original image and the color features of the positive sample image, and a second distance between the color features of the first original image and the color features of the negative sample image;
[0229] The second calculation subunit is used to calculate the first loss value with the objective that the first distance is less than the second distance;
[0230] The first adjustment subunit is used to adjust the image feature extraction model according to the first loss value.
[0231] According to one or more embodiments of this application, [Example 11] provides an image color feature extraction apparatus, wherein the first acquisition subunit includes:
[0232] The third acquisition subunit is used to acquire the first original image;
[0233] The first transformation subunit is used to perform a first image transformation on the first original image to generate a positive sample image corresponding to the first original image;
[0234] The second transformation subunit is used to perform a second image transformation on the first original image to generate a negative sample image corresponding to the first original image.
[0235] According to one or more embodiments of this application, [Example Twelve] provides an image color feature extraction apparatus, wherein the second calculation subunit includes:
[0236] The third calculation subunit is used to calculate the difference between the first distance and the second distance, and then add it to the third threshold to obtain the target value; the third threshold is greater than zero.
[0237] A sub-unit is defined to determine the larger value between the target value and zero as the first loss value.
[0238] According to one or more embodiments of this application, [Example Thirteen] provides an image color feature extraction device, wherein the training unit further includes:
[0239] The fourth acquisition subunit is used to acquire the second original image and acquire the color values of the main object in the second original image;
[0240] The fourth calculation subunit is used to calculate the difference in color values of the main object in the two second original images to obtain the color difference value;
[0241] The fifth acquisition subunit is used to input the two second original images into the image feature extraction model to obtain the color features of the two second original images;
[0242] The fifth calculation subunit is used to calculate the third distance between the color features of the two second original images;
[0243] The sixth calculation subunit is used to calculate the second loss value based on the difference between the third distance and the color difference;
[0244] The second adjustment subunit is used to adjust the image feature extraction model according to the second loss value.
[0245] According to one or more embodiments of this application, [Example Fourteen] provides an image color feature extraction apparatus, wherein the fourth acquisition subunit includes:
[0246] The sixth acquisition subunit is used to acquire the second original image;
[0247] An extraction subunit is used to extract the RGB color values of the main object in the second original image;
[0248] The conversion subunit is used to convert the RGB color values into Lab color space values as the color values of the main object in the second original image.
[0249] According to one or more embodiments of this application, [Example Fifteen] provides an image color feature extraction apparatus, the apparatus further comprising:
[0250] The third acquisition unit is used to acquire retrieval results, including the recalled image, in response to an image retrieval request for the target image.
[0251] The fourth acquisition unit is used to input the recalled image into the image feature extraction model to obtain the color features of the recalled image;
[0252] The calculation unit is used to calculate a fourth distance between the color features of the target image and the color features of the recalled image, and to sort the recalled images according to the fourth distance.
[0253] According to one or more embodiments of this application, [Example Sixteen] provides an image color feature extraction apparatus, wherein when the image feature extraction model is trained according to the method described in Example Five or Example Six, the apparatus further includes:
[0254] The filtering unit is used to filter the recall images corresponding to the fourth distance being greater than the fourth threshold.
[0255] According to one or more embodiments of this application, [Example Seventeen] provides an electronic device, including:
[0256] One or more processors;
[0257] Storage device, on which one or more programs are stored,
[0258] When the one or more programs are executed by the one or more processors, the one or more processors implement the image color feature extraction method as described above.
[0259] According to one or more embodiments of this application, [Example 18] provides a computer-readable medium having a computer program stored thereon, wherein the program, when executed by a processor, implements the image color feature extraction method as described above.
[0260] It should be noted that the various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the systems or apparatus disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple, and relevant parts can be referred to the method section.
[0261] It should be understood that in this application, "at least one (item)" means one or more, and "more than" means two or more. "And / or" is used to describe the relationship between related objects, indicating that three relationships can exist. For example, "A and / or B" can represent three cases: only A exists, only B exists, and both A and B exist simultaneously, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one (item) of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one (item) of a, b, or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.
[0262] It should also be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0263] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.
[0264] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. An image color feature extraction method, characterized by, The method comprises: acquiring a target image; inputting the target image into an image feature extraction model to obtain color features of the target image; The image feature extraction model is trained through the following training process: According to the first distance between the color features of the first original image and the color features of the positive sample image, and the second distance between the color features of the first original image and the color features of the negative sample image, the first loss value is calculated, with the first distance being less than the second distance as the target; Calculate the color difference value between the color values of the main objects in the two second original images and the third distance between the color features of the two second original images, and calculate the second loss value according to the difference between the third distance and the color difference value; Adjust the image feature extraction model according to the first loss value and the second loss value; Wherein, the positive sample image is the positive sample image corresponding to the first original image, and the negative sample image is the negative sample image corresponding to the first original image; The color similarity of the first original image and the positive sample image is greater than the first threshold, and the color similarity of the first original image and the negative sample image is less than the second threshold.
2. The method of claim 1, wherein, The image feature extraction model is trained through the following training process: Obtain a first original image, a positive sample image corresponding to the first original image, and a negative sample image corresponding to the first original image; Input the first original image, the positive sample image and the negative sample image into the image feature extraction model to obtain the color features of the first original image, the color features of the positive sample image and the color features of the negative sample image; Calculate the first distance between the color features of the first original image and the color features of the positive sample image, and the second distance between the color features of the first original image and the color features of the negative sample image; Calculate the first loss value with the first distance being less than the second distance as the target; Obtain a second original image, and obtain the color values of the main objects in the second original image; Calculate the difference between the color values of the main objects in the two second original images to obtain the color difference value; Input the two second original images into the image feature extraction model to obtain the color features of the two second original images; Calculate the third distance between the color features of the two second original images; According to the difference between the third distance and the color difference value, calculate the second loss value; Adjust the image feature extraction model according to the first loss value and the second loss value.
3. The method of claim 2, wherein, The acquisition of the first original image, the positive sample image corresponding to the first original image and the negative sample image corresponding to the first original image comprises: acquiring a first original image; performing first image transformation on the first original image to generate a positive sample image corresponding to the first original image; performing second image transformation on the first original image to generate a negative sample image corresponding to the first original image.
4. The method of claim 2, wherein, The first loss value is calculated with the first distance being less than the second distance as the target, comprising: A difference between the first distance and the second distance is calculated, and a third threshold value is added to obtain a target value; the third threshold value is greater than zero; A larger value between the target value and zero is determined as a first loss value.
5. The method of claim 2, wherein, The method further includes: Obtaining a second original image; Extracting an RGB color value of the subject object in the second original image; Converting the RGB color value into an Lab color space value as the color value of the subject object in the second original image.
6. The method of claim 1, wherein, The method further includes: In response to an image retrieval request for the target image, obtaining a retrieval result including a recall image; Inputting the recall image into the image feature extraction model to obtain a color feature of the recall image; Calculating a fourth distance between the color feature of the target image and the color feature of the recall image, and sorting the recall image according to the fourth distance.
7. The method of claim 6, wherein, When the image feature extraction model is trained according to any one of the methods of claims 1-5, the method further includes: Filtering the recall image corresponding to the fourth distance greater than a fourth threshold value.
8. An image color feature extraction apparatus characterized by comprising: The device includes: A first obtaining unit configured to obtain a target image; A second obtaining unit configured to input the target image into an image feature extraction model to obtain a color feature of the target image; The image feature extraction model is trained through the following training process: According to a first distance between a color feature of a first original image and a color feature of a positive sample image, and a second distance between the color feature of the first original image and a color feature of a negative sample image, a first loss value is calculated with the first distance being less than the second distance as a target; A color difference between color values of subject objects in two second original images and a third distance between color features of the two second original images are calculated, and a second loss value is calculated according to a difference between the third distance and the color difference; The image feature extraction model is adjusted according to the first loss value and the second loss value. The positive sample image is a positive sample image corresponding to the first original image, and the negative sample image is a negative sample image corresponding to the first original image; a color similarity between the first original image and the positive sample image is greater than a first threshold value, and a color similarity between the first original image and the negative sample image is less than a second threshold value.
9. An electronic device, comprising: One or more processors; A storage device having one or more programs stored thereon, When the one or more programs are executed by the one or more processors, the one or more processors implement the image color feature extraction method of any one of claims 1-7. A computer program is stored thereon, and when the program is executed by a processor, the image color feature extraction method of any one of claims 1-7 is implemented.
10. A computer readable medium characterized by
Citation Information
Patent Citations
Methods for determining image-subject significance and training image-subject significance determining classifier and systems for same
CN103793717A
Image searching method and device, storage medium and electronic device
CN109815355A
Model training method, image feature extraction method and target detection method and device
CN112232384A