Image processing method, electronic device, storage medium and computer program product
By dividing the image into multiple areas and using a scoring model to calculate local scores, and adjusting the image processing method in combination with the overall score, the problem of image disharmony caused by fixed parameters in the existing technology is solved, and the beautification effect and coordination of the image are improved.
Patent Information
- Application Number
- CN202410638431.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-22
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2044-05-22
AI Technical Summary
Existing image processing methods use fixed adjustment parameters, resulting in inconsistent beautified images, especially when processing different areas, and cannot take into account both local and overall image quality.
By dividing the image to be processed into multiple areas, using area description text pairs and scoring models to calculate local scores, combined with the overall score to determine the processing method, adjust the beautification parameters of the image to improve the coordination of the image.
It realizes the connection between the part and the whole of the beautified image, improves the coordination and beautification effect of the image, and reduces the separation between the part and the whole of the image.
Smart Images

Figure CN118212169B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to an image processing method, electronic equipment, storage medium and computer program product. Background Art
[0002] At present, image processing applications (APP) can be used to beautify input images. For example, the image to be processed can be input into the image processing application, and then the image processing application can respond to the user's operation of selecting any one of the beautification processing templates from multiple beautification processing templates, and use the beautification processing template selected by the user to beautify the image to be processed to obtain a beautified image.
[0003] However, since the adjustment parameters of each beautification template are fixed and the image is adjusted as a whole, it is impossible to make different adjustments to different areas of the image to be processed. For example, adjusting the dark background and bright subject based on fixed parameters may cause the dark background to be too dark, and at the same time cause the bright subject to change color and cause color difference. This will cause the beautified image to be separated from the whole, resulting in an unharmonious beautified image. Summary of the invention
[0004] In order to solve the problem that beautifying an image using a template with fixed adjustment parameters results in an inharmonious beautified image, an embodiment of the present application provides an image processing method, an electronic device, a storage medium, and a computer program product, including:
[0005] In a first aspect, an embodiment of the present application provides an image processing method, which is applied to an electronic device, comprising: obtaining a first image to be processed; dividing the first image into multiple regions, and determining a region description text pair for each region; inputting the region and the region description text pair into a scoring model to obtain a local score of the region; and determining a processing method for the first image based on the local score of each region.
[0006] Based on the above solution, by considering the local part of the first image, the beautification effect of the beautified image can be improved.
[0007] In some optional implementations, the first image can be scored by region and as a whole at the same time to obtain a local score and an overall score, and a total score is obtained based on the local score and the overall score, and a processing method for the first image is determined based on the total score. In this way, by comprehensively considering the local and overall aspects of the first image, the local and overall aspects of the beautified image can be connected, so that the beautified image is coordinated.
[0008] In some other optional implementations, the first image may be scored by region to obtain a local score, and then the overall score of the first image may be determined based on the local score, thereby determining the processing method of the first image based on the overall score of the first image. In this way, by considering the local part of the first image, the beautification effect of the beautified image may be improved.
[0009] It can be understood that the first image can be an image that needs to be beautified, or it can be an image that has been initially beautified, and they are collectively referred to as the image to be processed hereinafter. The regional description text pair can include a pair of description texts that are antonyms to each other, for example, a pair of Chinese sentences or Chinese words that are antonyms to each other, English sentences or English words that are antonyms to each other, and sentences or words in other languages that are antonyms to each other, without limitation. In some optional implementations, each regional description text pair can include a positive description text and a negative description text (hereinafter collectively referred to as description text), wherein the positive description text and the negative description text can be distinguished by a first positive description text, a second positive description text, a first negative description text, a second negative description text, etc.
[0010] In some optional implementations of the first aspect, the scoring model includes a large language model.
[0011] In some specific implementations, the scoring model may be a contrastive language image pre-training (CLIP) model.
[0012] In some optional implementations of the first aspect, the processing method includes: a first processing method, the first processing method includes using the first image as a processed target image, and a second processing method, the second processing method includes processing the first image to obtain a second image.
[0013] In some optional instances, the processing method of the image to be processed can be determined based on the local score of the region and the overall score of the image to be processed; the processing method of the image to be processed can also be determined based on the sum of the local scores of multiple regions, which is not specifically limited in the embodiments of the present application.
[0014] In some optional implementations, the first image may be processed based on image adjustment parameters to obtain the second image, wherein the image adjustment parameters may include a color correction matrix, a three-dimensional display lookup table, a blur degree parameter, a sharpness degree parameter, a contrast degree parameter, a clarity degree parameter, and an exposure degree parameter.
[0015] In some optional implementations of the first aspect, the region description text pair includes a first positive description text and a first negative description text that are antonyms to each other, wherein the first positive description text and the first negative description text are used to describe the image quality of the region, and the first positive description text corresponds to a first processing method, and the first negative description text corresponds to a second processing method.
[0016] For example, region description text pairs may include ["a good picture", "a bad picture"], ["a high-quality picture", "a low-quality picture"], ["an excellent picture", "a bad picture"], ["good picture", "bad picture"], etc.
[0017] In some optional implementations, each description text pair may also be a pair of English sentences or English words that are antonyms to each other, such as ["good photo", "bad photo"], ["a good photo", "a bad photo"], etc.
[0018] In some optional implementations of the first aspect, the text meaning represented by the first positive description text is high image quality, and the text meaning represented by the first negative description text is low image quality.
[0019] In some optional implementations of the first aspect, the scoring model determines the local score of the region in the following manner: determining a first accuracy of the first positive description text describing the region, and a second accuracy of the first negative description text describing the region; determining the local score of the region based on the proportion of the first accuracy to the total accuracy of the first positive description text and the first negative description text describing the region, wherein the greater the proportion, the higher the local score of the region.
[0020] It can be understood that the accuracy of the first positive description text in describing the first image is the similarity between the text feature representation vector of the first positive description text and the overall image feature representation vector of the first image, and the accuracy of the first negative description text in describing the first image is the similarity between the text feature representation vector of the first negative description text and the overall image feature representation vector of the first image.
[0021] In some specific implementations, the similarity between two feature representation vectors may be determined using the following formula:
[0022]
[0023] in, x It can represent the image feature representation vector, t It can represent the text feature representation vector, i =1,2 respectively represent the description text pair, for example, t 1A text feature representation vector that can represent "a good picture", t 2 The text feature representation vector that can represent “a bad picture”, ⊙ can represent the vector dot product, ‖·‖ can represent L 2 specification, s i It can represent the cosine similarity between the i-th text feature representation vector and the image feature representation vector.
[0024] In some optional implementations of the first aspect, the region description text pair also includes a second positive description text and a second negative description text that are antonyms to each other, wherein the second positive description text and the second negative description text are used to describe the quality of the region in the i-th dimension, and the second positive description text corresponds to the first processing method, and the second negative description text corresponds to the second processing method.
[0025] For example, region description text pairs may include ["a clean image", "a noisy image"], ["a clear image", "a blurry image"], ["a high-definition image", "a low-definition image"], ["cleanphoto", "noisy photo"], etc.
[0026] In some optional implementations of the first aspect, the i-th dimension includes at least one of noise, clarity, exposure, sharpness, and contrast.
[0027] In some optional implementations of the first aspect, corresponding to the i-th dimension of noise, the text meaning represented by the second positive description text is small noise, and the text meaning represented by the second negative description text is large noise; corresponding to the i-th dimension of clarity, the text meaning represented by the second positive description text is clear, and the text meaning represented by the second negative description text is blurred; corresponding to the i-th dimension of exposure, the text meaning represented by the second positive description text is strong exposure, and the text meaning represented by the second negative description text is weak exposure; corresponding to the i-th dimension of sharpness, the text meaning represented by the second positive description text is small sharpness, and the text meaning represented by the second negative description text is large sharpness; corresponding to the i-th dimension of contrast, the text meaning represented by the second positive description text is small contrast, and the text meaning represented by the second negative description text is large contrast.
[0028] In some optional implementations of the first aspect, the scoring model determines the local score of the region in the following manner: determining a first accuracy of the first positive description text description region, and a second accuracy of the first negative description text description region; and determining a third accuracy of the second positive description text description region in the i-th dimension, and a fourth accuracy of the second negative description text description region in the i-th dimension; determine the local score of the region based on a first proportion of the first accuracy to the total accuracy of the first positive description text and the first negative description text description region, and a second proportion of the third accuracy to the total accuracy of the second positive description text and the second negative description text description region in the i-th dimension.
[0029] In some optional implementations of the first aspect, the local score of the region is determined based on the following formula:
[0030]
[0031] in, score j Indicates j The local score of the region, B j Indicates the first specific gravity, A ij Indicates the second specific gravity.
[0032] In some optional implementations of the first aspect, the first accuracy is the first similarity between the first text feature representation vector of the first positive description text and the regional image feature representation vector of the region; the second accuracy is the second similarity between the second text feature representation vector of the first negative description text and the regional image feature representation vector of the region; the third accuracy is the third similarity between the third text feature representation vector of the second positive description text and the image feature representation vector of the region in the i-th dimension; the fourth accuracy is the fourth similarity between the fourth text feature representation vector of the second negative description text and the image feature representation vector of the region in the i-th dimension.
[0033] In some optional implementations of the first aspect, determining a processing method for the first image based on a local score of each region includes: determining a processing method for the first image based on a local score of the region and an overall score of the first image.
[0034] In some optional implementations of the first aspect, the overall score of the first image is obtained by: obtaining an image description text pair of the first image; inputting the first image and the image description text pair of the first image into a scoring model to obtain the overall score of the first image.
[0035] In some optional implementations of the first aspect, a processing method for the first image is determined based on a local score of the region and an overall score of the first image, including: determining the sum of the local score of the region and the overall score of the first image as the total score of the first image; corresponding to the total score of the first image being greater than a preset score threshold, determining the processing method for the first image to be the first processing method; corresponding to the total score of the first image being less than or equal to the preset score threshold, determining the processing method for the first image to be the second processing method.
[0036] In some optional implementations of the first aspect, the local score of the region includes the local score of the region and the dimensional score of the region in the i-th dimension; the first proportion of the first accuracy to the total accuracy of the first positive description text and the first negative description text describing the region in the i-th dimension is: the local score of the region; the second proportion of the third accuracy to the total accuracy of the second positive description text and the second negative description text describing the region in the i-th dimension is: the dimensional score of the region in the i-th dimension.
[0037] In some optional implementations of the first aspect, the sum of the local score of the region and the overall score of the first image is determined as the total score of the first image, including: determining the total score of the first image based on the weights of the regional score of the region, the dimensional score of the region in the i-th dimension, and the overall score of the first image in the total score, and the local score of the region, the dimensional score of the region in the i-th dimension, and the overall score of the first image.
[0038] In some optional implementations of the first aspect, the total score of the first image is determined by the following formula:
[0039]
[0040] in, score all represents the total score of the first image, w 1 Indicates the weight of the overall score in the total score, C Represents the overall score, w 2 Indicates the weight of the regional score in the total score, w j Indicates j The weight of each region in the total score is B j Indicates j The regional score of each region, w i Indicates i The weight of each dimension in the total score is A ij Indicates j Region iThe dimension score of each dimension, M represents the total number of regions, and N represents the j The total number of dimensions of regions, and w 1 + w 2 =1, , .
[0041] In some optional implementations of the first aspect, the smaller the depth value of the region is, the greater the weight of the region score in the total score is.
[0042] In some optional implementations of the first aspect, the proportion of the dimension score of the region in the i-th dimension to the total score is related to the category label corresponding to the region.
[0043] In some optional implementations of the first aspect, corresponding to the i-th dimension including saturation and clarity, the category label corresponding to the region is person, and the dimension score corresponding to saturation accounts for a greater proportion of the total score than the dimension score corresponding to clarity accounts for a greater proportion of the total score.
[0044] In some optional implementations of the first aspect, the method also includes: normalizing the overall score of the first image, the regional score of the region, and the dimensional score of the region in the i-th dimension, so that the overall score of the first image, the regional score of the region, and the dimensional score of the region in the i-th dimension are in the same range.
[0045] In some optional implementations of the first aspect, the second processing method includes processing the first image based on image adjustment parameters to obtain a second image, wherein the image adjustment parameters include at least one of the following: a color correction matrix, a three-dimensional display lookup table, a blur degree parameter, a sharpness degree parameter, a contrast degree parameter, a clarity degree parameter, and an exposure degree parameter.
[0046] In a second aspect, the present application provides an electronic device, comprising: a memory for storing instructions executed by one or more processors of the electronic device, and a processor, which is one of the one or more processors of the electronic device, for executing the image processing method mentioned in the first aspect of the present application or any item of the first aspect.
[0047] In a third aspect, the present application provides a readable storage medium having instructions stored thereon. When the instructions are executed on an electronic device, the electronic device executes the image processing method mentioned in the first aspect of the present application or any item of the first aspect.
[0048] In a fourth aspect, an embodiment of the present application provides a computer program product, which includes computer instructions. When executed by an electronic device, the electronic device executes the computer program code of the image processing method mentioned in the first aspect of the present application or any item of the first aspect.
[0049] The beneficial effects of the second to fourth aspects mentioned above can be referred to the relevant descriptions in the first aspect mentioned above and various possible implementations of the first aspect, and will not be elaborated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] Figure 1 A schematic diagram of an image beautification scene is shown;
[0051] Figure 2 According to some embodiments of the present application, a schematic diagram of determining an overall score and a local score for an image to be processed is shown;
[0052] Figure 3 According to some embodiments of the present application, a flow chart of an image processing method is shown;
[0053] Figure 4 According to some embodiments of the present application, a flow chart of a training method of a CLIP model is shown;
[0054] Figure 5 According to some embodiments of the present application, a schematic diagram of a sigmoid mapping function is shown;
[0055] Figure 6 According to some embodiments of the present application, a schematic diagram of a tanh function is shown;
[0056] Figure 7 According to some embodiments of the present application, a flowchart of another image processing method is shown;
[0057] Figure 8 According to some embodiments of the present application, a schematic diagram of the hardware structure of an electronic device is shown;
[0058] Fig. 9 According to some embodiments of the present application, a schematic diagram of the software structure of an electronic device is shown. DETAILED DESCRIPTION
[0059] The illustrative embodiments of the present application include, but are not limited to, an image processing method, an electronic device, a storage medium, and a computer program product.
[0060] It can be understood that the image method mentioned in the embodiment of the present application can be used for electronic devices, where the electronic device can also be called a terminal, user equipment (UE), mobile station (MS), mobile terminal (MT), etc. The electronic device can be a mobile phone, a wearable device, a tablet computer (Pad), etc.
[0061] It can be understood that the image processing method mentioned in the embodiments of the present application can be applied to scenarios such as image beautification, taking pictures, recording videos, and video calls.
[0062] Figure 1 A schematic diagram of an image beautification scene is shown. Figure 1 As shown, image A can be beautified based on default parameters (a general parameter) or filters. It can be understood that HSL (a color mode) can include three dimensions: hue (H), saturation (S), and lightness (L). Among them, the value range of H can be 0~360°, and the value range of S and L can both be 0%~100%. In order to facilitate data processing, the values of the three dimensions of HSL can be normalized to 0-1, or to -100 to 100. For example, the values of the three dimensions of HSL can be normalized to between -100 and 100.
[0063] In this way, the hue of image A can be adjusted from a value of 60 to a value of 63, the saturation can be adjusted from a value of -30 to a value of -36, and the brightness can be adjusted from a value of 0 to a value of -5, to obtain the beautified image B. Comparing images A and B, it can be seen that beautifying the entire image based on the default parameters or filters will uniformly modify the entire image, which may improve some areas, but the image quality of other areas will be reduced, such as color cast, low brightness, high saturation and other problems. Therefore, when beautifying the entire image based on the default parameters or filters, all local areas cannot be taken into account. Moreover, when the default parameters also include parameters such as sharpness, color contrast, and blur (blur) degree, uniformly adjusting the entire image will cause the entire image to change, resulting in reduced image quality.
[0064] In order to solve the above problems, an embodiment of the present application provides an image processing method. In this method, when beautifying an image, the image can be beautified by region, and the beautified image can be scored by region, and then the beautification parameters of the image can be adjusted based on the scores of multiple regions until a beautified image that meets preset conditions is obtained. For example, the image can be scored by region and as a whole at the same time to obtain a local score and an overall score, and a total score can be obtained based on the local score and the overall score to adjust the beautification parameters of the image; the image can also be scored by region to obtain a local score, and the overall score can be determined based on the local score, and then the beautification parameters of the image can be adjusted based on the overall score. In this way, by comprehensively considering the local and overall aspects of the image, the local and overall aspects of the beautified image can be connected, so that the beautified image is coordinated.
[0065] It is understandable that some current artificial intelligence (AI) models have image scoring functions, such as the contrastive language image pre-training (CLIP) model, which can score images based on the image's description text pairs.
[0066] It can be understood that the overall score of the image to be processed can be determined in the following manner;
[0067] Determine the accuracy of the positive description text in describing the image to be processed and the accuracy of the negative description text in describing the image to be processed, and determine the overall score of the image to be processed according to the proportion of the accuracy of the positive description text in describing the image to be processed to the total accuracy of the positive description text in describing the image to be processed and the negative description text in describing the image to be processed. The greater the proportion, the higher the overall score of the image to be processed.
[0068] Among them, the accuracy of the positive description text in describing the image to be processed is the similarity between the text feature representation vector of the positive description text and the overall image feature representation vector of the image to be processed, and the accuracy of the negative description text in describing the image to be processed is the similarity between the text feature representation vector of the negative description text and the overall image feature representation vector of the image to be processed.
[0069] For example, the description text pair may include a pair of description texts, "a good picture" (i.e., a positive description text) and "a bad picture" (i.e., a negative description text). The image to be processed is subjected to feature extraction processing to obtain a first feature representation vector, the description text "a good picture" is subjected to feature extraction processing to obtain a second feature representation vector, and the description text "a bad picture" is subjected to feature extraction processing to obtain a third feature representation vector. If it is determined that the similarity between the first feature representation vector and the second feature representation vector is a, and the similarity between the first feature representation vector and the third feature representation vector is b, then the overall score of the image to be processed can be determined based on the similarity a and the similarity b.
[0070] It can be understood that the smaller the cosine value of the angle between the text feature representation vector of the positive description text and the overall image feature representation vector of the image to be processed, the greater the first similarity between the text feature representation vector of the positive description text and the overall image feature representation vector of the image to be processed; the smaller the cosine value of the angle between the text feature representation vector of the negative description text and the overall image feature representation vector of the image to be processed, the greater the second similarity between the text feature representation vector of the negative description text and the overall image feature representation vector of the image to be processed. Therefore, specifically, the cosine similarity formula shown in the following formula (1) can be used to calculate the similarity between two feature representation vectors:
[0071] Formula (1)
[0072] in, x It can represent the image feature representation vector, t It can represent the text feature representation vector, i =1,2 respectively represent the description text pair, for example, t 1 A text feature representation vector that can represent "a good picture", t 2 The text feature representation vector that can represent “a bad picture”, ⊙ can represent the vector dot product, ‖·‖ can represent L 2 specification, s i It can represent the cosine similarity between the i-th text feature representation vector and the image feature representation vector.
[0073] Furthermore, the overall score of the image to be processed can be determined based on the two similarities using the following formula (2):
[0074] Formula (2)
[0075] in, It can represent the overall score of the image to be processed, and its value is between 0 and 1.
[0076] Therefore, in some embodiments of the present application, an image to be processed and at least one description text pair corresponding to the image to be processed (i.e., an image description text pair describing the image quality of the image to be processed, hereinafter referred to as a description text pair) can be obtained, the image to be processed can be divided into multiple regions, and at least one description text pair corresponding to each region can be obtained (i.e., a regional description text pair describing the image quality of the region in the image to be processed, hereinafter referred to as a description text pair). The overall score of the image to be processed is determined based on the similarity between the overall image feature representation vector of the image to be processed and the text feature representation vector of the description text in each corresponding description text pair. The local score of each region is determined based on the regional image feature representation vector of each region and the text feature representation vector of the description text in each corresponding description text pair. The total score of the image to be processed is determined based on the overall score and the local score. If the total score of the image to be processed meets the preset conditions, the image to be processed is used as the target image (i.e., the beautified image). In this way, the problem of the local and overall separation of the image can be reduced, making the image harmonious.
[0077] It is understandable that the description text pair may include a pair of description texts that are antonyms to each other, for example, a pair of Chinese sentences or Chinese words that are antonyms to each other, English sentences or English words that are antonyms to each other, sentences or words in other languages that are antonyms to each other, without limitation. In some optional implementations, each description text pair may include a positive description text and a negative description text (hereinafter collectively referred to as description texts), wherein the positive description text and the negative description text may be distinguished by a first positive description text, a second positive description text, a first negative description text, a second negative description text, etc.
[0078] It can be understood that the overall image feature representation vector may include color, noise, clarity, exposure, sharpness, contrast, etc., and the text feature representation vector may include semantic features, etc., which are not limited here.
[0079] In some specific implementations, the overall score of the image to be processed can be determined in the following manner. For example, feature extraction processing can be performed on the image to be processed to obtain an overall image feature representation vector. And feature extraction processing can be performed on the description text in each description text pair corresponding to the image to be processed to obtain multiple text feature representation vectors. Then, the similarity between the overall image feature representation vector and each text feature representation vector can be determined, and the overall score of the image to be processed can be determined based on the similarity between the overall image feature representation vector and each text feature representation vector.
[0080] In some specific implementations, the local score of each region may be determined in the following manner:
[0081] The regional score of each region is determined according to the similarity between the regional image feature representation vector of each region and the text feature representation vector in each corresponding description text pair; and the dimension score of each region in at least one dimension is determined according to the similarity between the image feature representation vector of at least one dimension of each region and the text feature representation vector in each corresponding description text pair. Based on this, the local score of each region can be determined according to the regional score of each region and the dimension score of each region in at least one dimension.
[0082] For example, Figure 2 As shown, a schematic diagram of determining the overall score and the local score of the image to be processed is shown.
[0083] In some specific implementations, the overall score of the image to be processed can be determined based on the above formula (1) and formula (2). In addition, the image to be processed can be divided into four regions, which are marked as region 1, region 2, region 3, and region 4 in sequence. The regional score of region 1 and the dimension score of the noise dimension of region 1 can be determined based on the above formula (1) and formula (2). In this way, the regional scores of region 2, region 3, and region 4 can be determined based on the same method, and the dimension scores of each dimension of region 1, region 2, region 3, and region 4 can be determined, without limitation here.
[0084] The image processing method mentioned in the embodiment of the present application is described in detail below. Figure 3 As shown, a schematic flow chart of an image processing method is shown, and the method can be executed by an electronic device. Specifically, the method may include:
[0085] 301: Obtain an image to be processed and at least one corresponding description text pair.
[0086] Exemplarily, the image to be processed may be the first image to be processed mentioned above.
[0087] In some specific implementations, when beautifying an image, the image to be processed may be imported into an image processing application to perform subsequent image processing operations.
[0088] As mentioned above, the description text pair may include a pair of description texts that are antonyms to each other, for example, a pair of Chinese sentences or Chinese words that are antonyms to each other, English sentences or English words that are antonyms to each other, sentences or words in other languages that are antonyms to each other, without limitation. In some optional implementations, each description text pair may include a positive description text and a negative description text, wherein the positive description text and the negative description text may be distinguished by a first positive description text, a second positive description text, a first negative description text, a second negative description text, etc.
[0089] 302: Divide the image to be processed into multiple regions.
[0090] For example, a segmentation model (such as a SAM model) can be used to identify the bounding box of each object from the image to be processed, and the bounding box of each object can select an area. In a portrait shooting scene, the object can be part or all of the subject such as the face of a person, the arm of a person, the skirt of a person, a brick on a wall, a doorbell on a wall, a door handle, etc. The bounding box of the object can indicate the position of the object. The regions in the multiple regions can be described as the first region, the second region, etc. in sequence for distinction.
[0091] For example, in some specific implementations, the image to be processed is input into the SAM model, the image features (such as color, texture, depth, etc.) of each pixel in the image to be processed are extracted, and the bounding box of each object in the image to be processed is predicted based on the image features of each pixel in the image to be processed. In this way, the SAM model can output the image to be processed divided into multiple regions.
[0092] It is understood that at least one description text pair may include an image description text pair describing the image quality of the image to be processed, a region description text pair describing the image quality of a region in the image to be processed, and a region description text pair describing the quality of the region in the image to be processed in the i-th dimension. In some optional implementations, the region description text pairs of each region in the multiple regions may be the same or different. The region description text pairs of the quality of each region in the i-th dimension may be the same or different.
[0093] It is understandable that, in practical applications, other segmentation models may be used to segment the image to be processed, and the SAM model listed above is only one of the segmentation models listed in the embodiment of the present application. Instance segmentation may also be used to identify the bounding box of each object in the image to be processed from the image to be processed, so as to segment the image to be processed into multiple regions, which is not specifically limited in the embodiment of the present application.
[0094] In practical applications, the image to be processed, which is divided into multiple regions, can be input into a recognition module (such as a recognize anything model, RAM) to extract image features (such as color, texture, shape, etc.) of objects in each region of the image to be processed, which is divided into multiple regions. Based on the image features in each region, the category label of the object in each region is predicted.
[0095] 303: Input the region and at least one descriptive text pair into a scoring model to obtain a local score of the region.
[0096] It can be understood that the scoring model can be a large language model that scores images based on description text pairs, such as the CLIP model mentioned above.
[0097] In some specific implementations, in the scoring model, the accuracy of the positive description text description area and the accuracy of the negative description text description area can be determined, and the local score of the area can be determined according to the proportion of the accuracy of the positive description text description area to the total accuracy of the positive description text description area and the negative description text description area. The greater the proportion, the higher the local score of the area.
[0098] Furthermore, the accuracy of the positive description text describing the region is the similarity between the text feature representation vector of the positive description text and the regional image feature representation vector of the region, and the accuracy of the negative description text describing the region is the similarity between the text feature representation vector of the negative description text and the regional image feature representation vector of the region.
[0099] Therefore, the region and at least one description text pair can be input into the CLIP model. In the CLIP model, feature extraction processing can be performed on each region, feature extraction processing can be performed on the description texts in each description text pair, similarity can be calculated, and the local score of each region can be determined. The specific method can be referred to above, and in order to avoid repetition, it will not be repeated here.
[0100] In some other specific implementations, the image to be processed divided into a plurality of regions and at least one description text pair may be input into the CLIP model. In the CLIP model, feature extraction may be performed on the image to be processed, feature extraction may be performed on the description texts in each description text pair, similarity may be calculated, and the overall score of the image to be processed may be determined. The specific method may refer to the above, and will not be described here in order to avoid repetition.
[0101] In some other specific implementations, a region and at least one description text pair may be input into a CLIP model. In the CLIP model, feature extraction processing may be performed on each region, feature extraction processing may be performed on the description texts in each description text pair, similarity may be calculated, a local score of each region may be determined, and then an overall score of the image to be processed may be determined based on the local score of each region, for example, the overall score of the image to be processed may be obtained by adding up the local scores of each region.
[0102] 304: Determine a processing method for the image to be processed based on the local score of each region.
[0103] It can be understood that in some specific implementations, the processing method may include a first processing method of using the image to be processed as the processed target image and a second processing method of processing the image to be processed to obtain a beautified image (i.e., the second image mentioned above).
[0104] In some optional instances, the processing method of the image to be processed can be determined based on the local score of the region and the overall score of the image to be processed; the processing method of the image to be processed can also be determined based on the sum of the local scores of multiple regions, which is not specifically limited in the embodiments of the present application.
[0105] The following is an example of determining a processing method for an image to be processed based on a local score of a region and an overall score of the image to be processed.
[0106] In some specific implementations, the sum of the local scores of each region and the overall score of the image to be processed can be determined as the total score of the image to be processed. When the total score of the image to be processed is greater than a preset score threshold, the processing method of the image to be processed can be determined to be the first processing method; when the total score of the image to be processed is less than or equal to the preset score threshold, the processing method of the image to be processed can be determined to be the second processing method.
[0107] In some specific implementations, a contrastive language image pre-training (CLIP) model may be used to determine the overall score, region score, and dimension score of the image to be processed.
[0108] The following first introduces the training process of the CLIP model in detail.
[0109] As an example, Figure 4 A flow chart of a training method for a CLIP model is shown. It is understood that the execution device of the training method can be an electronic device, and the CLIP model can be deployed to the operating system of the electronic device that needs to perform image processing after training, such as deployed to the image processing application of the operating system of a mobile phone or other device.
[0110] like Figure 4 As shown, the training method may include:
[0111] 401: Obtain a first sample image and at least one description text pair corresponding to the first sample image.
[0112] It can be understood that in at least one description text pair corresponding to the first sample image, each description text pair can be a pair of Chinese sentences or Chinese words that are antonyms to each other. For example, the description text pair can include ["a good picture", "a bad picture"], ["a high-quality picture", "a low-quality picture"], ["an excellent picture", "a bad picture"], ["good picture", "bad picture"], ["a clean picture", "a noisy picture"], ["a clear picture", "a blurred picture"], ["a picture with high definition", "a picture with low definition"], etc.
[0113] In some optional implementations, each description text pair may also be a pair of English sentences or English words that are antonyms to each other. For example, the description text pair may be ["good photo", "bad photo"], ["a good photo", "a bad photo"], ["clean photo", "noisy photo"], etc.
[0114] It is understandable that each description text may also be a pair of sentences or words in other languages that are antonyms to each other, and the embodiments of the present application do not specifically limit this.
[0115] 402: Adjust the first sample image based on the first adjustment parameter to obtain a second sample image.
[0116] It can be understood that the first adjustment parameter may include a color correction matrix (CCM), a three dimensions look up table (3DLUT), a blur degree parameter (or a blur degree parameter), a sharpness degree parameter, a contrast degree parameter, a clarity degree parameter, an exposure degree parameter, etc.
[0117] In some specific implementations, during the first training of the CLIP model, the adjustment parameters may be initialized, for example, the adjustment parameters are initialized to 0. In the first adjustment parameters, the color correction matrix and the three-dimensional display lookup table are both pixel-level adjustments for the first sample image, for example, the color correction matrix adjusts the RGB data of each pixel in the first sample image, and the three-dimensional lookup table adjusts the HSL data of each pixel in the first sample image. The specific adjustment method will be described below, and in order to avoid repetition, it will not be described here.
[0118] 403: Determine a total score of the second sample image according to the similarity between the entire second sample image, each region, and each dimension of each region and each corresponding description text.
[0119] It can be understood that the overall score of the second sample image is determined based on the similarity between the second sample image as a whole and each corresponding description text pair. The regional score of each region is determined based on the similarity between each region in the second sample image and each corresponding description text pair. And the dimension score of each dimension of each region is determined based on the similarity between each dimension of each region in the second sample image and each corresponding description text pair. Thus, the total score of the second sample image can be determined based on the overall score, the regional score and the dimension score.
[0120] In some specific implementations, the second sample image may be subjected to feature extraction processing to obtain an overall image feature representation vector, and the description texts in the multiple description text pairs may be subjected to feature extraction processing to obtain multiple text feature representation vector pairs. The overall image feature representation vector may include color, noise, clarity, exposure, sharpness, contrast, etc., and the text feature representation vector pair may include semantic features with opposite semantics. Then, the overall image feature representation vector and the text feature representation vector in the text feature representation vector pair may be subjected to feature conversion processing so that the overall image feature representation vector and the text feature representation vector have the same representation form, structure and dimension. Based on the similarity of the overall image feature representation vector and the text feature representation vector after feature conversion, the similarity between the overall image feature representation vector and each text feature representation vector pair is determined. Then, the overall score of the second sample image may be determined based on the similarity between the overall image feature representation vector and the multiple text feature representation vector pairs. The specific method of calculating the similarity and the method of determining the overall score may refer to the formula (1) and formula (2) mentioned above. In order to avoid repetition, they will not be described here.
[0121] It can be understood that the second sample image can be segmented into multiple regions. For example, a segmentation model (e.g., segment anything model, SAM) can be used to identify the bounding box of each object from the image to be processed, and the bounding box of each object can select a region. For example, in a portrait shooting scene, the object can be part or all of a subject such as a person's face, a person's arm, a person's skirt, a brick on a wall, a doorbell on a wall, a door handle, etc. Similarly, the regional score of each region can be determined by using the method of determining the overall score of the second sample image above. In order to avoid repetition, it will not be repeated here.
[0122] It can be understood that for the training of the SAM model, a trained SAM pre-trained model can be obtained and fine-tuned, which can improve the beautification efficiency.
[0123] Slightly different from determining the overall score of the second sample image and the regional scores of each region, when determining the dimension score of each dimension of each region, a separate feature extraction process is performed on each dimension of each region, such as extracting features of any one of color, noise, clarity, exposure, sharpness, contrast, etc., to obtain a feature representation vector corresponding to each dimension. Then, the dimension score of each dimension of each region can be determined by using the method of calculating similarity mentioned above. To avoid repetition, it will not be repeated here.
[0124] In some optional implementations, the sum of the overall score of the second sample image, the regional scores of each region, and the dimension scores of each dimension of each region may be used as the total score of the second sample image.
[0125] In some other optional implementations, the overall score of the second sample image, the regional score of each region, and the product of the dimension score of each dimension of each region and the corresponding weight may be taken as the total score of the second sample image.
[0126] 404: Determine whether the total score of the second sample image meets a preset condition.
[0127] It can be understood that the preset condition can be the convergence of the total score, the difference between the total score and the preset total score threshold being within the preset difference range, the total score being greater than the preset total score threshold, or the number of iterations being greater than the iteration number threshold, and the embodiments of the present application do not make specific limitations.
[0128] It can be understood that the convergence of the total score can mean that when the first sample image is adjusted based on different adjustment parameters (for example, the first adjustment parameter and the second adjustment parameter mentioned above) to obtain multiple second sample images, the change amplitude of the total score of the second sample image determined based on the method mentioned above is less than the amplitude threshold, for example, the total score of the second sample image tends to be stable.
[0129] In some specific implementations, if the total score of the second sample image does not meet the preset condition, step 405 may be performed to optimize the first adjustment parameter to obtain the second adjustment parameter. Otherwise, the training of the CLIP model may be completed, and the first adjustment parameter may be used as the target adjustment parameter of the trained CLIP model.
[0130] 405: Optimize the first adjustment parameter to obtain a second adjustment parameter.
[0131] In some optional implementations, a genetic evolutionary algorithm (EA) or a Bayesian optimization (BO) algorithm may be used to optimize the first adjustment parameter to obtain the second adjustment parameter. For example, the parameters in the color correction matrix and the HSL data in the three-dimensional display lookup table are adjusted, that is, the value corresponding to each anchor point in the HSL color space, and the adjusted color correction matrix and the adjusted HSL data in the three-dimensional display lookup table are used as the second adjustment parameter.
[0132] Exemplarily, there are constraints when adjusting the parameters in the color correction matrix and the HSL data in the three-dimensional display lookup table, and they cannot take arbitrary values.
[0133] For example, for the parameters in the color correction matrix, the constraints are that the sum of each row is equal to 1, and the perturbation term of each parameter is in the interval [-5,5]. For the value corresponding to each anchor point in the three-dimensional display lookup table, the perturbation term of the value corresponding to each anchor point cannot exceed a certain proportion of the total length, such as 1 / 20. Exemplarily, the values corresponding to the anchor points in the three-dimensional display lookup table are all in the interval [-1,1], that is, the total length is 2, then the perturbation term of the value corresponding to each anchor point cannot exceed 0.1.
[0134] The following takes the case where the first adjustment parameter includes a color correction matrix (CCM) and a three-dimensional display lookup table (3DLUT) as an example to describe in detail the manner of adjusting the first sample image based on the first adjustment parameter in step 402 .
[0135] For the RGB data of each pixel in the first sample image, the following formula (3) can be used to multiply the RGB data of each pixel by the color correction matrix to obtain the transformed RGB data of each pixel.
[0136] Formula (3)
[0137] in, I output It can represent the RGB data of each pixel after transformation. I input It can represent the RGB data of each pixel before transformation. T can represent transpose operations, for example, I input T Can be expressed I input Transpose, M A color correction matrix can be represented.
[0138] Color Correction Matrix MThis can be represented as a 3×3 matrix, where each row of the matrix sums to 1.
[0139]
[0140] In this way, the RGB data of each pixel can be transformed to correct the white under different color temperatures to a uniform white, that is, to achieve white balance.
[0141] Then, the RGB data of each pixel in the first sample image adjusted by the color correction matrix can be converted into HSL data. For the convenience of conversion, the values of the three dimensions of HSL can be normalized to 0-1, or uniformly planned to -100 to 100. In the 3DLUT optimization, it is first necessary to fix some anchor points on the 3DLUT, such as fixing 256×256×256 anchor points, and each anchor point corresponds to a set of HSL values. When beautifying the image to be processed, the HSL value corresponding to the anchor point can be optimized. If the HSL data of a pixel does not fall on the 256×256×256 anchor points of the HSL color space, the HSL data of the pixel can be determined by interpolation.
[0142] After converting the RGB data of each pixel into HSL data, the value corresponding to each anchor point in the three-dimensional display lookup table can be determined. For example, the following formula (4) can be used to adjust the HSL data of each pixel to the value corresponding to each anchor point in the HSL color space. In this way, the hue, saturation, and brightness can be adjusted.
[0143] Formula (4)
[0144] in, H out It can represent the adjusted hue of each pixel. H in It can represent the hue of each pixel before adjustment. ΔH Can be expressed H in The corresponding disturbance term is, S out It can represent the adjusted saturation of each pixel. S in It can represent the saturation of each pixel before adjustment. ΔS Can be expressed S in The corresponding disturbance term is, L out It can represent the adjusted brightness of each pixel. L in It can represent the brightness of each pixel before adjustment. ΔL Can be expressed Lin The corresponding disturbance term.
[0145] In some specific implementations, when the pixel level adjustment is performed on the region based on the color correction matrix and the three-dimensional display lookup table, since the color correction matrix has 6 independent variables and the three-dimensional display lookup table has 3×256 independent variables, 3 Anchor points, that is, a total of 6+3×256 3 In order to improve the image beautification speed, the 3D display lookup table can be reduced to, for example, 3×100 3 Anchor points, such as 128×128×128 anchor points. In this way, the amount of data processing can be reduced while improving the image quality.
[0146] In some specific implementations, the overall score of the second sample image, the regional scores of each region, and the dimension scores of each dimension of each region may be determined in substantially the same manner. The following describes step 403 by taking determining the overall score of the second sample image as an example.
[0147] For example, the description text pair may include ["a good picture", "a bad picture"] and ["a clean picture", "a noisy picture"]. The color, noise, clarity, exposure, sharpness, and contrast of the second sample image may be subjected to feature extraction processing to obtain a first feature representation vector. The description text "a good picture" in the description text pair ["a good picture", "a bad picture"] is subjected to feature extraction processing to obtain a second feature representation vector. The description text "a bad picture" in the description text pair ["a good picture", "a bad picture"] is subjected to feature extraction processing to obtain a third feature representation vector. The description text "a clean picture" in the description text pair ["a clean picture", "a noisy picture"] is subjected to feature extraction processing to obtain a fourth feature representation vector. The description text "a noisy picture" in the description text pair ["a clean picture", "a noisy picture"] is subjected to feature extraction processing to obtain a fifth feature representation vector.
[0148] Assuming that the representation form, structure and dimension of the first feature representation vector, the second feature representation vector, the third feature representation vector, the fourth feature representation vector and the fifth feature representation vector are the same, the similarity between the first feature representation vector and the second feature representation vector, the third feature representation vector, the fourth feature representation vector and the fifth feature representation vector can be calculated respectively, and the overall score of the second sample image can be determined based on multiple similarities.
[0149] In some specific implementations, the overall score of the second sample image, the regional scores of each region, and the dimension scores of each dimension of each region may be in the interval [0,1]. The higher the score, the more accurate the description of the image or region by the corresponding description text. For example, for the description text pair ["a good picture", "a bad picture"], the overall score of the second sample image is 0.95. For the description text pair ["a very good picture", "a very bad picture"], the overall score of the second sample image is 0.99. It can be seen that the second sample image is a picture with a very good effect, and the description text "a very good picture" is a more accurate description of the second sample image.
[0150] The following continues to describe step 403 by taking the example of determining the dimension scores of each dimension of each area of the second sample image.
[0151] It can be understood that after obtaining the second sample image, the second sample image can be divided into multiple regions. Then, slightly different from determining the overall score of the second sample image, instead of performing feature extraction processing on the color, noise, clarity, exposure, sharpness, and contrast of each region, a separate feature extraction process is performed on each dimension of each region, such as performing feature extraction on any one of noise, clarity, exposure, sharpness, contrast, etc., to obtain a feature representation vector corresponding to each dimension. Then, the dimensional scores of each dimension of each dimension can be determined by using the method of calculating similarity mentioned above. In order to avoid repetition, it will not be repeated here.
[0152] In some specific implementations, a segmentation model (such as a SAM model) can be used to identify the bounding box of each object from the second sample image, and the bounding box of each object can select an area. For example, in a portrait shooting scene, the object can be part or all of a subject such as a person's face, a person's arm, a person's skirt, a brick on a wall, a doorbell on a wall, a door handle, etc. Similarly, the regional score of each area can be determined by using the method of determining the overall score of the second sample image above. In order to avoid repetition, it will not be repeated here.
[0153] Thus, for an image containing a person's face, a person's arm, a person's skirt, bricks on the wall, a doorbell on the wall, and a door handle, for the area containing the person's face, the dimension scores of each dimension can be determined as follows: Area1 (face): (noise: 0.9, clarity: 0.8, exposure: 0.4, saturation: 0.2, sharpness: 0.5, contrast: 0.3). For the area containing the bricks on the wall, the dimension scores of each dimension can be determined as follows: Area1 (wall): (noise: 0.3, clarity: 0.4, exposure: 0.9, saturation: 0.3, sharpness: 0.6, contrast: 0.7).
[0154] The following describes in detail the method of determining the total score of the second sample image using two specific examples.
[0155] Example 1:
[0156] It can be understood that in some optional implementations, the overall score of the second sample image, the regional scores of each region, and the sum of the dimension scores of each dimension of each region can be used as the total equal score of the second sample image. The specific method is as follows:
[0157] Assume that, based on the method for determining the overall score of the second sample image described above, the overall score of the second sample image is determined to be C , No. j The regional score for the region is B j , No. j Region i The dimension scores of the dimensions are A ij .
[0158] In this way, the overall score of the second sample image, the regional score of each region, and the dimension score of each dimension of each region can be added together using the following formula (5) to obtain the total score of the second sample image.
[0159] Formula (5)
[0160] in, score all can represent the total score of the second sample image, C The overall score of the second sample image can be expressed as, B j The second sample image can be represented by j The regional score of each region, A ij The second sample image can be represented by j Region iThe dimension score of the dimension, N can represent the j The total number of dimensions for each region.
[0161] Example 2:
[0162] Different from the above example 1, the electronic device may use the overall score of the second sample image, the regional scores of each region, and the product of the dimension scores of each dimension of each region and the corresponding weights as the total score of the second sample image.
[0163] In some specific implementations, the depth value of each area in the second sample image can be obtained, wherein the depth value can represent the distance between the area and the image acquisition device (e.g., camera). It can be understood that the depth value can reflect the distance between the area selected by the bounding box of the object and the image acquisition device (e.g., camera). For example, the closer the area selected by the bounding box of the object is to the image acquisition device, the smaller the depth value of the area selected by the bounding box of the object. And the depth value of each area can be the average depth value of multiple pixels in the area. Then, based on the depth value of each area, the weight corresponding to each area can be determined. It can be understood that the sum of the weights corresponding to multiple areas is 1.
[0164] It can be understood that the weight corresponding to each dimension in each region can be set arbitrarily, and the weight corresponding to each dimension in each region can also be determined according to the category label of the object in the region, and the sum of the weights corresponding to multiple dimensions in each region is 1. As mentioned above, after the second sample image is segmented into multiple regions using the segmentation model, the image to be processed divided into multiple regions can be input into the recognize anything model (RAM), and the regional image feature representation vector (such as color, texture, shape, etc.) of each region is extracted. According to the regional image feature representation vector of each region, the category label of the object in each region is predicted. In this way, the weights of each dimension of each region can be determined based on the category label of the object in each region.
[0165] For example, j The region includes two dimensions: saturation and clarity. When the object category label in the region is the category label corresponding to a person, the weight corresponding to saturation can be determined as 0.8, and the weight corresponding to clarity can be determined as 0.2.
[0166] It can be understood that the weight corresponding to the regional score can be preset, and the weight corresponding to the regional score can also be determined according to the depth value of the region, and the sum of the weight corresponding to the overall score and the weight corresponding to the regional score is 1. For example, the weight corresponding to the overall score can be preset to 0.6, and the weight corresponding to the regional score can be preset to 0.4.
[0167] As previously assumed, based on the method for determining the overall score of the second sample image described above, the overall score of the second sample image is determined as C , No. j The regional score for the region is B j , No. j Region i The dimension scores of the dimensions are A ij .
[0168] In this way, the overall score of the second sample image, the regional score of each region, and the dimension score of each dimension of each region multiplied by the corresponding weight can be used to obtain the total score of the second sample image using the following formula (6).
[0169] Formula (6)
[0170] in, score all can represent the total score of the second sample image, w 1 It can represent the weight corresponding to the overall score, C The overall score of the second sample image can be expressed as, w 2 It can represent the weight corresponding to the regional score, w j Can indicate the j The weight corresponding to each region is B j The second sample image can be represented by j The regional score of each region, w i Can indicate the i The weights corresponding to the dimensions are A ij The second sample image can be represented by j Region i The dimension score of the dimension, M can represent the total number of regions, and N can represent the j The total number of dimensions for each region.
[0171] and, w 1 + w 2 =1, , .
[0172] It is understandable that the CLIP model mentioned above is a model with strong comprehensive capabilities and can cope with various problems. However, strong comprehensive capabilities also mean that unilateral capabilities may be weak. Therefore, after completing the training of the CLIP model and migrating it to downstream tasks, such as migrating to beautify images, it is usually necessary to fine-tune it based on the dataset corresponding to the downstream task.
[0173] For example, fine-tuning can be performed based on corresponding datasets such as landscape photos, indoor photos, artistic photos, portrait photos, car photos, moon photos, beach photos, and desert photos. This can reduce the sensitivity of the CLIP model to descriptive text pairs on the one hand, and improve the accuracy of the CLIP model on the other hand, making the output of the CLIP model more in line with expectations.
[0174] In some specific implementations, the fine-tuning methods for the CLIP model include but are not limited to prompt learning, prompt fine-tuning, prompt engineering, and prompt ensembling.
[0175] In order to reduce the difference in dimension scores between different dimensions, after determining the dimension score of each dimension, a mapping function can be used to map the dimension score of each dimension to between 0 and 1. For example, when the dimension score has positive and negative values, the following can be used: Figure 5 The sigmoid mapping function shown in the figure maps each dimension score to between 0 and 1. When the dimension score has only positive values, the following can be used: Figure 6 The tanh function shown in the figure maps each dimension score to between 0 and 1. The sigmoid mapping function can be in the form shown in formula (7), and the tanh function can be in the form shown in formula (8):
[0176] Formula (7)
[0177] Formula (8)
[0178] Among them, α can represent the adjustment factor, x can represent the score before mapping, and y can represent the score after mapping. It can be understood that the adjustment factor can be fixed first, and then the dimension scores between different dimensions are mapped.
[0179] It is worth noting that the overall score of the image to be processed and the regional scores of each region also need to be normalized to between 0 and 1, so as to reduce the gap between the overall score, the regional scores of different regions and the dimension scores between different dimensions.
[0180] The following is a detailed introduction to the image processing method using a specific example. Figure 7 FIG. 1 is a flow chart of another image processing method. The method may be executed by an electronic device. Specifically, the method may include:
[0181] 701: The first application inputs an image to the second application.
[0182] It can be understood that the first application can be an application such as a gallery or a camera, and the second application can be an image processing application. The first application can input an image (i.e., the image to be processed mentioned above) into the CLIP model in the second application. In addition, at least one description text pair corresponding to the image can be input into the CLIP model. Among them, each description text pair can be a pair of Chinese sentences or Chinese words that are antonyms to each other, or a pair of English sentences or English words that are antonyms to each other, which is not specifically limited in the embodiments of the present application. The specific form of the description text pair can be referred to above, and in order to avoid repetition, it will not be repeated here.
[0183] 702: The second application performs depth estimation on the image.
[0184] It can be understood that when performing depth estimation on the image to be processed, the depth value can reflect the distance between the area selected by the bounding box of the object and the image acquisition device (such as a camera). For example, the closer the area selected by the bounding box of the object is to the image acquisition device, the smaller the depth value of the area selected by the bounding box of the object.
[0185] 703: The second application detects, segments, and recognizes the image.
[0186] In some specific implementations, the SAM model can be used to identify the bounding box of each object from the image (i.e., the image to be processed mentioned above), and the bounding box of each object can select an area. For example, in a portrait shooting scene, the object can be part or all of the subject such as the face of the person, the arm of the person, the skirt of the person, the bricks on the wall, the doorbell on the wall, the door handle, etc. In this way, the image segmentation can be achieved.
[0187] After the image is segmented into multiple regions using the segmentation model, the input RAM model divided into multiple regions can be used to extract the regional image feature representation vector (such as color, texture, shape, etc.) of the object in each region, and the category label of the object in each region can be predicted based on the regional image feature representation vector of each region. In this way, the weight of each dimension of each region can be determined based on the category label of the object in each region.
[0188] It is understandable that in order to reduce the amount of data processing, for the SAM model and the RAM model, the model is not required to be able to identify the categories of all objects in the image to be processed, but only needs to identify the categories of the objects of focus.
[0189] For example, in a portrait shooting scene, the model is required to be able to identify the categories of the focus objects such as the face and arms of the person in the image to be processed, so that when beautifying the image to be processed, the focus can be placed on beautifying the color (i.e., skin color) of the person's face and arms. For another example, in a landscape shooting scene, the model is required to be able to identify the categories of objects such as the sunset and the car in a prominent position in the foreground image in the image to be processed, so that when beautifying the image to be processed, the focus can be placed on beautifying the sunset and the car in a prominent position in the foreground image.
[0190] In some specific implementations, the RAM model can output the category name of the object identified in the image to be processed, and can also output the confidence of the category of the identified object. For example, the RAM model can identify that the category of the object is a car, and can also identify the confidence that the object is a car, that is, the RAM model can output (car, 0.95), which means that the confidence that the object is a car is 95%. Based on this, a confidence threshold can be set in advance, and the category recognition of objects with low confidence is not considered. In this way, the amount of data processing can be reduced and the data processing efficiency can be improved.
[0191] It can be understood that the above steps 702 and 703 can be further explanations of the above step 703. In order to avoid repetition, the specific process can refer to the above step 703 and will not be repeated here.
[0192] 704: The second application sets a set of parameters.
[0193] It can be understood that parameters (such as the first adjustment parameter mentioned above) may include a color correction matrix (CCM), a three-dimensional display lookup table (3DLUT), a blur (blur) degree parameter, a sharpness degree parameter, a contrast degree parameter, a clarity degree parameter, an exposure degree parameter, etc.
[0194] In some specific implementations, this parameter can be used to adjust the image. For example, the image can be adjusted based on a color correction matrix (CCM) and a three-dimensional display lookup table (3DLUT). The specific adjustment method can be found above. In order to avoid repetition, it will not be described here.
[0195] 705: The second application scores each region and the entire image after adjustment.
[0196] It can be understood that the overall score of the adjusted image can be determined based on the similarity between the entire adjusted image and each corresponding description text pair. The regional score of each region can be determined based on the similarity between each region in the adjusted image and each corresponding description text pair. And the dimension score of each dimension of each region can be determined based on the similarity between each dimension of each region in the adjusted image and each corresponding description text pair. The specific determination method can be referred to above, and in order to avoid repetition, it will not be repeated here.
[0197] 706: The second application obtains the final score.
[0198] In some optional implementations, the overall score of the adjusted image, the regional scores of each region, and the sum of the dimension scores of each dimension of each region may be used as the final score of the adjusted image (ie, the total score mentioned above).
[0199] In some other optional implementations, the overall score of the adjusted image, the regional score of each region, and the product of the dimension score of each dimension of each region and the corresponding weight may be used as the total score of the adjusted image.
[0200] 707: The second application determines whether the score converges.
[0201] It can be understood that score convergence may mean that when an image is adjusted based on different adjustment parameters and the adjusted image is scored based on the above-mentioned method, the change amplitude of the final score of the adjusted image is less than the amplitude threshold.
[0202] 708: The second application applies the parameters to the image and outputs a beautified image.
[0203] It can be understood that when the score is judged to converge, the parameters in step 704 can be used as target adjustment parameters and acted on the original image, that is, the image input in step 701, to beautify the image and obtain a beautified image, that is, an adjusted image.
[0204] 709: The second application uses an optimization algorithm to adjust the parameters.
[0205] In some optional implementations, an evolutionary algorithm (EA) or a Bayesian optimization (BO) algorithm may be used to optimize the parameters, for example, to adjust the parameters in the color correction matrix and the HSL data in the three-dimensional display lookup table, that is, the value corresponding to each anchor point in the HSL color space.
[0206] The following is a detailed introduction to the evolutionary algorithm (EA) and Bayesian optimization (BO) algorithm.
[0207] In the evolutionary algorithm, first, the initial population of image adjustment parameters can be set, for example, the initial population of image adjustment parameters is set to 500, that is, 500 groups of random image adjustment parameters are initialized, which are called the parent generation. The images beautified by the parent generation are scored by using the scoring model mentioned above, and 250 groups of random image adjustment parameters with the highest scores are retained. Then, the 250 groups of random image adjustment parameters can be crossover and mutation processed to obtain 250 new groups of adjustment parameters, which are called the first offspring. The images beautified by the first offspring are scored again by using the scoring model mentioned above, and the 250 groups of random image adjustment parameters with the highest scores retained by the beautified images of the parent generation and the first offspring are re-retained. Then, the 250 groups of random image adjustment parameters are crossover and mutation processed again to obtain 250 new groups of adjustment parameters, which are called the second offspring. This is repeated until the score obtained by scoring the beautified image converges, that is, the score has reached the highest and cannot or cannot be increased again. At this time, the preset score threshold can be determined according to the highest score. And the image adjustment parameter with the highest score in the last generation can be used as the target image adjustment parameter. The target image adjustment parameter acts on the image to be processed, and a beautified image with the best beautification effect can be obtained.
[0208] Since the evolutionary algorithm is an optimization algorithm, it retains excellent adjustment parameters each time, so the best image adjustment parameters can be obtained through continuous iteration.
[0209] In the Bayesian optimization algorithm, after initializing a set of image adjustment parameters, the initialized image adjustment parameters can be applied to the image to be processed, and multiple beautified images can be scored and the scores can be normalized to obtain normalized scores. The Bayesian optimization algorithm will give the next set of image adjustment parameters based on the normalized scores, and the image adjustment parameters will be applied to the image to be processed again, and so on, until the scores obtained by scoring the beautified images converge, that is, the scores have reached the highest and cannot or cannot be improved again. At this time, a preset score threshold can be determined based on the highest score. And the image adjustment parameters with the highest scores can be used as target image adjustment parameters. The target image adjustment parameters are applied to the image to be processed to obtain a beautified image with the best beautification effect.
[0210] It should be understood that in some specific implementations, the score of the image to be processed can be determined based on the dimensional scores corresponding to all dimensions of each region of the image to be processed. The score of the image to be processed can also be determined based only on the dimensional scores corresponding to a single dimension of each region of the image to be processed, for example, the score of the image to be processed can be determined based only on the dimensional scores corresponding to the noise dimensions of each region of the image to be processed to reduce the noise of the image to be processed, which is not specifically limited in the embodiments of the present application.
[0211] It can be understood that after obtaining the beautified image, not only can the beautified image be scored using the scoring model to determine the image quality of the beautified image, but the quality of the beautified image can also be determined by performing Fourier transform, derivation, etc. on the beautified image. When the image quality of the beautified image is lower than the preset quality standard, the above-mentioned evolutionary algorithm or Bayesian optimization algorithm can be used to automatically adjust the image adjustment parameters.
[0212] It is understandable that the image processing method provided in the embodiment of the present application can be applied to electronic devices. The hardware structure of the electronic device to which the image processing method provided in the embodiment of the present application is applicable is exemplarily introduced below.
[0213] like Figure 8 As shown, the electronic device 800 may include a processor 810, an external memory interface 820, an internal memory 821, a universal serial bus (USB) interface 830, a charging management module 840, a power management module 841, a battery 842, an antenna 1, an antenna 2, a mobile communication module 850, a wireless communication module 860, an audio module 870, a speaker 870A, a receiver 870B, a microphone 870C, an earphone interface 870D, a sensor module 880, a button 890, a motor 891, an indicator 892, a camera 893, a display screen 894, and a subscriber identification module (SIM) card interface 895, etc. The sensor module 880 may include a pressure sensor 880A, etc.
[0214] It is to be understood that the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on the electronic device. In other embodiments of the present application, the electronic device 800 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0215] The processor 810 may include one or more processing units, for example, the processor 810 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0216] In some optional implementations, the processor 810 may execute the image processing method mentioned in the embodiments of the present application.
[0217] The controller can generate operation control signals according to the instruction operation code and timing signal to complete the control of instruction fetching and execution.
[0218] The processor 810 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 810 is a cache memory. The memory may store instructions or data that the processor 810 has just used or cyclically used. If the processor 810 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 810, and thus improves the efficiency of the system.
[0219] In some optional implementations, the memory may store instructions or data of the image processing method mentioned in the embodiments of the present application.
[0220] The wireless communication function of the electronic device can be implemented through antenna 1, antenna 2, mobile communication module 850, wireless communication module 860, modem processor and baseband processor.
[0221] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in the electronic device can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization of the antennas. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.
[0222] The mobile communication module 850 can provide solutions for wireless communications including 2G / 3G / 4G / 5G, etc., applied to electronic devices. The mobile communication module 850 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 850 can receive electromagnetic waves from the antenna 1, and filter, amplify, and process the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 850 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna 1. In some embodiments, at least some of the functional modules of the mobile communication module 850 may be set in the processor 810. In some embodiments, at least some of the functional modules of the mobile communication module 850 may be set in the same device as at least some of the modules of the processor 810.
[0223] The modem processor may include a modulator and a demodulator. The modulator is used to modulate the low-frequency baseband signal to be sent into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After the low-frequency baseband signal is processed by the baseband processor, it is passed to the application processor. The application processor outputs a sound signal through an audio device (not limited to a speaker 870A, a receiver 870B, etc.), or displays an image or video through a display screen 894. In some embodiments, the modem processor may be an independent device. In other embodiments, the modem processor may be independent of the processor 810 and may be set in the same device as the mobile communication module 850 or other functional modules.
[0224] The wireless communication module 860 can provide wireless communication solutions for electronic devices, including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc. The wireless communication module 860 can be one or more devices integrating at least one communication processing module. The wireless communication module 860 receives electromagnetic waves via antenna 2, modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 810. The wireless communication module 860 can also receive the signal to be sent from the processor 810, modulate the frequency, amplify it, and convert it into electromagnetic waves for radiation through antenna 2.
[0225] In some embodiments, the antenna 1 of the electronic device is coupled to the mobile communication module 850, and the antenna 2 is coupled to the wireless communication module 860, so that the electronic device can communicate with the network and other devices through wireless communication technology. The wireless communication technology may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), time-division code division multiple access (TD-SCDMA), long term evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technology, etc. The GNSS may include global positioning system (GPS), global navigation satellite system (GLONASS), Beidou navigation satellite system (BDS), quasi-zenith satellite system (QZSS) and / or satellite based augmentation system (SBAS).
[0226] The electronic device implements the display function through a GPU, a display screen 894, and an application processor. The GPU is a microprocessor for image processing, connecting the display screen 894 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 810 may include one or more GPUs that execute program instructions to generate or change display information.
[0227] The display screen 894 is used to display images, videos, etc. The display screen 894 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Mini-LED, MicroLED, Micro-OLED, quantum dot light-emitting diodes (QLED), etc. In some embodiments, the electronic device may include 1 or N display screens 894, where N is a positive integer greater than 1.
[0228] In some optional implementations, the display screen 894 may display the following: Figure 1 The content displayed.
[0229] The pressure sensor 880A is used to sense the pressure signal and can convert the pressure signal into an electrical signal. In some embodiments, the pressure sensor 880A can be set on the display screen 894. There are many types of pressure sensors 880A, such as resistive pressure sensors, inductive pressure sensors, capacitive pressure sensors, etc. The capacitive pressure sensor can be a parallel plate including at least two conductive materials. When a force acts on the pressure sensor 880A, the capacitance between the electrodes changes. The electronic device determines the intensity of the pressure based on the change in capacitance. When a touch operation acts on the display screen 894, the electronic device detects the touch operation intensity according to the pressure sensor 880A. The electronic device can also calculate the touch position according to the detection signal of the pressure sensor 880A. In some embodiments, touch operations acting on the same touch position but with different touch operation intensities can correspond to different operation instructions. For example: when a touch operation with a touch operation intensity less than the first pressure threshold acts on the short message application icon, an instruction to view the short message is executed. When a touch operation with a touch operation intensity greater than or equal to the first pressure threshold acts on the short message application icon, an instruction to create a new short message is executed.
[0230] The following is an exemplary introduction to the software structure of an electronic device to which the image processing method provided in the embodiment of the present application is applicable.
[0231] The software system of the electronic device may adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture, etc. The embodiment of the present invention takes the layered architecture as an example to illustrate the software structure of the electronic device. In some embodiments, the software structure of the electronic device may be the same.
[0232] Fig. 9 It is a software structure block diagram of the electronic device according to an embodiment of the present application.
[0233] The layered architecture divides the software into several layers, each with clear roles and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom: application layer, framework layer, system runtime, and kernel layer.
[0234] like Fig. 9 As shown, the application layer may include a series of application packages, which may include image processing, gallery, navigation, WLAN, Bluetooth, music, video, short message and other applications.
[0235] Among them, the image processing application can integrate the above-mentioned SAM model module, RAM model module and CLIP model module to implement the image processing method provided in the embodiment of the present application.
[0236] In some specific implementations, when beautifying an image to be processed, an image processing application obtains the image to be processed and at least one description text pair corresponding to the image to be processed, divides the image to be processed into multiple regions, and obtains at least one description text pair corresponding to each region. The overall score of the image to be processed is determined based on the similarity between the overall image feature representation vector of the image to be processed and the text feature representation vector of the description text in each corresponding description text pair. The local score of each region is determined based on the regional image feature representation vector of each region and the text feature representation vector of the description text in each corresponding description text pair. The total score of the image to be processed is determined based on the overall score and the local score. If the total score of the image to be processed meets a preset condition, the image to be processed is used as a target image.
[0237] In this way, when beautifying the image to be processed, the problem of separation between the local and the whole of the image can be reduced, making the image harmonious.
[0238] The application framework layer provides an application programming interface (API) and a programming framework for the applications in the application layer. The application framework layer includes some predefined functions.
[0239] like Fig. 9As shown, the application framework layer may include a window manager, a content provider, a phone manager, a resource manager, a notification manager, a view system, and the like.
[0240] The window manager is used to manage window programs. The window manager can obtain the display screen size, determine whether there is a status bar, lock the screen, capture the screen, etc.
[0241] Content providers are used to store and retrieve data and make it accessible to applications. The data may include videos, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.
[0242] The phone manager is used to provide communication functions for electronic devices, such as the management of call status (including answering, hanging up, etc.).
[0243] The resource manager provides various resources for applications, such as localized strings, icons, images, layout files, video files, and so on.
[0244] The notification manager enables applications to display notification information in the status bar. It can be used to convey notification-type messages and can disappear automatically after a short stay without user interaction. For example, the notification manager is used to notify download completion, message reminders, etc. The notification manager can also be a notification that appears in the system top status bar in the form of a chart or scroll bar text, such as notifications of applications running in the background, or a notification that appears on the screen in the form of a dialog window. For example, a text message is displayed in the status bar, a prompt sound is emitted, an electronic device vibrates, an indicator light flashes, etc.
[0245] The view system includes visual controls, such as controls for displaying text, controls for displaying images, etc. The view system can be used to build applications. A display interface can be composed of one or more views. For example, a display interface including a text notification icon can include a view for displaying text and a view for displaying images.
[0246] Android Runtime includes core libraries and virtual machines. Android runtime is responsible for scheduling and management of the Android system.
[0247] The core library consists of two parts: one part is the function that needs to be called by the Java language, and the other part is the Android core library.
[0248] The application layer and the application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.
[0249] The system library may include multiple functional modules, such as surface manager, 3D graphics processing library (such as OpenGL ES), 2D graphics engine (such as SGL), media libraries, etc.
[0250] The surface manager is used to manage the display subsystem and provide the fusion of 2D and 3D layers for multiple applications.
[0251] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.
[0252] A 2D graphics engine is a drawing engine for 2D drawings.
[0253] The media library supports playback and recording of a variety of commonly used audio and video formats, as well as static image files, etc. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
[0254] The kernel layer is the layer between hardware and software. The kernel layer contains at least display driver, camera driver, audio driver, and sensor driver.
[0255] In some cases, the embodiments disclosed herein may be implemented in hardware, firmware, software, or any combination thereof.
[0256] The embodiments disclosed in the present application may also be implemented as instructions carried or stored on one or more temporary or non-temporary machine-readable (e.g., computer-readable) storage media, which can be read and executed by one or more processors. For example, the instructions may be distributed over a network or through other computer-readable media. Therefore, the machine-readable medium may include any mechanism for storing or transmitting information in a form readable by a machine (e.g., a computer), including but not limited to a floppy disk, an optical disk, an optical disk, a magneto-optical disk, a read-only memory (ROM), a random access memory (RAM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic card or an optical card, a flash memory, or a tangible machine-readable memory for transmitting information (e.g., a carrier wave, an infrared signal, a digital signal, etc.) using the Internet in an electrical, optical, acoustic or other form of propagation signal. Therefore, the machine-readable medium includes any type of machine-readable medium suitable for storing or transmitting electronic instructions or information in a form readable by a machine (e.g., a computer).
[0257] Embodiments of the present application may be implemented as a computer program or program code executed on a programmable system comprising at least one processor, a storage system (including volatile and non-volatile memory and / or storage elements), at least one input device, and at least one output device.
[0258] Program code can be applied to input instructions to perform the functions described in this application and generate output information. The output information can be applied to one or more output devices in a known manner. For the purposes of this application, a processing system includes any system having a processor such as, for example, a digital signal processor (DSP), a microcontroller, an application specific integrated circuit, or a microprocessor.
[0259] Program code can be implemented with high-level programming language or object-oriented programming language to communicate with the processing system. When necessary, program code can also be implemented with assembly language or machine language. In fact, the mechanism described in this application is not limited to the scope of any specific programming language. In either case, the language can be a compiled language or an interpreted language.
[0260] The above describes the hardware structure that the electronic device may have. It is understood that the structure illustrated in the embodiments of the present application does not constitute a specific limitation on the electronic device. In other embodiments of the present application, the electronic device may include more or fewer components than shown in the figure, or combine certain components, or split certain components, or arrange the components differently. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0261] In the accompanying drawings, some structural or method features may be shown in a specific arrangement and / or order. However, it should be understood that such a specific arrangement and / or order may not be required. Instead, in some embodiments, these features may be arranged in a manner and / or order different from that shown in the illustrative drawings. In addition, the inclusion of structural or method features in a particular figure does not mean that such features are required in all embodiments, and in some embodiments, these features may not be included or may be combined with other features.
[0262] It should be noted that in the examples and description of this patent, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "including one" do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0263] Although the present application has been illustrated and described with reference to certain embodiments thereof, it will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the scope of the present application.
Claims
1. An image processing method, applied to electronic equipment, It is characterized in that include: Acquire a first image to be processed; Dividing the first image into a plurality of regions, and determining a region description text pair for each region, wherein the region description text pair includes a positive description text and a negative description text that are antonyms of each other; Inputting the region and the region description text pair of the region into a scoring model to obtain a local score of the region; A processing method for the first image is determined based on the local scores of the regions.
2. The method according to claim 1, It is characterized in that The scoring model includes a large language model.
3. The method according to claim 1, It is characterized in that The processing methods include: a first processing method, wherein the first processing method includes using the first image as a processed target image, and a second processing method, wherein the second processing method includes processing the first image to obtain a second image.
4. The method according to claim 3, It is characterized in that The region description text pair includes a first positive description text and a first negative description text which are antonyms of each other, wherein the first positive description text and the first negative description text are used to describe the image quality of the region, And the first positive description text corresponds to the first processing method, and the first negative description text corresponds to the second processing method.
5. The method according to claim 4, It is characterized in that The text meaning represented by the first positive description text is high image quality, and the text meaning represented by the first negative description text is low image quality.
6. The method according to claim 4, It is characterized in that The scoring model determines the local score of the region in the following manner; determining a first accuracy with which the first positive descriptive text describes the region, and a second accuracy with which the first negative descriptive text describes the region; The local score of the region is determined according to the proportion of the first accuracy to the total accuracy of the first positive description text and the first negative description text in describing the region, wherein the greater the proportion, the higher the local score of the region.
7. The method according to claim 4, It is characterized in that The region description text pair further includes a second positive description text and a second negative description text which are antonyms of each other. The second positive description text and the second negative description text are used to describe the quality of the region in the i-th dimension. And the second positive description text corresponds to the first processing method, and the second negative description text corresponds to the second processing method.
8. The method according to claim 7, It is characterized in that The i-th dimension includes at least one of noise, clarity, exposure, sharpness, and contrast.
9. The method according to claim 8, It is characterized in that Corresponding to the i-th dimension being noise, the text meaning represented by the second positive description text is small in noise, and the text meaning represented by the second negative description text is large in noise; Corresponding to the i-th dimension being clarity, the text meaning represented by the second positive description text is clear, and the text meaning represented by the second negative description text is vague; Corresponding to the i-th dimension being exposure, the text meaning represented by the second positive description text is strong exposure, and the text meaning represented by the second negative description text is weak exposure; Corresponding to the i-th dimension being sharpness, the text meaning represented by the second positive description text is small sharpness, and the text meaning represented by the second negative description text is large sharpness; Corresponding to the i-th dimension being contrast, the text meaning represented by the second positive description text has a small contrast, and the text meaning represented by the second negative description text has a large contrast.
10. The method according to claim 8, It is characterized in that The scoring model determines the local score of the region in the following manner: determining a first accuracy with which the first positive descriptive text describes the region, and a second accuracy with which the first negative descriptive text describes the region; and determining a third accuracy of the second positive description text in describing the region in the i-th dimension, and a fourth accuracy of the second negative description text in describing the region in the i-th dimension; The local score of the region is determined based on a first proportion of the first accuracy to the total accuracy of the first positive description text and the first negative description text in describing the region, and a second proportion of the third accuracy to the total accuracy of the second positive description text and the second negative description text in describing the region in the i-th dimension.
11. The method according to claim 10, It is characterized in that The local score of the region is determined based on the following formula: , in, score j Indicates j The local score of the region, B j represents the first specific gravity, A ij Indicates the second specific gravity, N indicates the j The total number of dimensions for each region.
12. The method according to claim 10, It is characterized in that The first accuracy is a first similarity between a first text feature representation vector of the first positive description text and a region image feature representation vector of the region; The second accuracy is a second similarity between a second text feature representation vector of the first negative description text and a region image feature representation vector of the region; The third accuracy is a third similarity between a third text feature representation vector of the second positive description text and an image feature representation vector of the region in the i-th dimension; The fourth accuracy is a fourth similarity between a fourth text feature representation vector of the second negative description text and an image feature representation vector of the region in the i-th dimension.
13. The method according to claim 10, It is characterized in that The determining, based on the local scores of the regions, a processing method of the first image includes: A processing method for the first image is determined based on the local score of the region and the overall score of the first image.
14. The method according to claim 13, It is characterized in that The overall score of the first image is obtained by: Obtain an image description text pair for the first image; The first image and the image description text pair of the first image are input into the scoring model to obtain an overall score of the first image.
15. The method according to claim 13 or 14, It is characterized in that The determining, based on the local score of the region and the overall score of the first image, a processing method of the first image includes: Determine the sum of the local score of the region and the overall score of the first image as the total score of the first image; Corresponding to the total score of the first image being greater than a preset score threshold, determining that the processing method for the first image is the first processing method; Corresponding to the total score of the first image being less than or equal to the preset score threshold, it is determined that the processing method for the first image is the second processing method.
16. The method according to claim 15, It is characterized in that The local score of the region includes the regional score of the region and the dimension score of the region in the i-th dimension; A first proportion of the first accuracy to the total accuracy of the first positive description text and the first negative description text in describing the region is: a region score of the region; The second proportion of the third accuracy to the total accuracy of the second positive description text and the second negative description text in describing the region in the i-th dimension is: the dimension score of the region in the i-th dimension.
17. The method according to claim 16, It is characterized in that The step of determining the sum of the local score of the region and the overall score of the first image as the total score of the first image includes: The total score of the first image is determined based on the weights of the local score of the region, the dimensional score of the region in the i-th dimension and the overall score of the first image in the total score, as well as the regional score of the region, the dimensional score of the region in the i-th dimension and the overall score of the first image.
18. The method according to claim 17, It is characterized in that The total score of the first image is determined by the following formula: , in, score all represents the total score of the first image, w 1 represents the weight of the overall score in the total score, C represents the overall score, w 2 represents the weight of the local score in the total score, w j Indicates j The weight of each region in the total score, B j Indicates the j The regional score of each region, w i Indicates i The weight of each dimension in the total score is: A ij Indicates the j Region i The dimension score of each dimension, M represents the total number of regions, and N represents the j The total number of dimensions of regions, and w 1 + w 2 =1, , .
19. The method according to claim 17 or 18, It is characterized in that The smaller the depth value of the region is, the greater the weight of the region score of the region in the total score is.
20. The method according to claim 17 or 18, It is characterized in that The weight of the dimension score of the region in the i-th dimension in the total score is related to the category label corresponding to the region.
21. The method according to claim 20, It is characterized in that Corresponding to the i-th dimension including saturation and clarity, the category label corresponding to the area is person, and the weight of the dimension score corresponding to the saturation in the total score is greater than the weight of the dimension score corresponding to the clarity in the total score.
22. The method according to claim 18, It is characterized in that The method further comprises: The overall score of the first image, the regional score of the region, and the dimensional score of the region in the i-th dimension are normalized so that the overall score of the first image, the regional score of the region, and the dimensional score of the region in the i-th dimension are in the same range.
23. The method according to claim 3, It is characterized in that The second processing method includes processing the first image based on the image adjustment parameter to obtain the second image, The image adjustment parameters include at least one of the following: Color correction matrix, three-dimensional display lookup table, blur degree parameter, sharpness degree parameter, contrast degree parameter, clarity degree parameter, exposure degree parameter.
24. An electronic device, It is characterized in that include: A memory, used to store instructions executed by one or more processors of the electronic device, and a processor, which is one of the one or more processors of the electronic device, used to execute the image processing method described in any one of claims 1-23.
25. A readable storage medium, It is characterized in that The readable storage medium stores instructions, and when the instructions are executed on an electronic device, the electronic device executes the image processing method according to any one of claims 1 to 23.
26. A computer program product, It is characterized in that The computer program product comprises computer instructions, and when executed by an electronic device, the electronic device executes the computer program code of the image processing method according to any one of claims 1 to 23.
Citation Information
Patent Citations
Multi-modal image aesthetic quality evaluation method fusing local and global image features
CN116012300A
Image processing system, image processing device, imaging device, image processing method, program, and recording medium
JP2016126750A
