Image processing method, electronic device and computer readable storage medium
By using multi-modal large-scale language models and user preference matching technology in electronic devices, the problem of failing to consider user aesthetic preferences in the existing technology is solved, and more accurate and personalized image processing effects are achieved.
Patent Information
- Application Number
- CN202311044671.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-17
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2043-08-17
AI Technical Summary
Existing image processing technology fails to fully consider the user's personal aesthetic preferences, resulting in deviations in image processing effects and reducing the accuracy of image processing.
By providing image processing methods in electronic devices, using multi-modal large-scale language models to extract image content and style encoding, combined with user preferences and frequency of use, match and convert image styles to achieve personalized image processing.
It improves the accuracy of image processing and user satisfaction, meets users' personalized aesthetic needs, and enhances the accuracy of image style conversion.
Smart Images

Figure CN117729421B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of image processing technology, and in particular, to an image processing method, an electronic device, and a computer-readable storage medium. Background Art
[0002] With the development of electronic device technology, more and more electronic devices are equipped with camera modules for users to capture images. Based on user shooting needs and aesthetics, users have different preferences for the images they capture. For example, different users have different requirements for the color tone, light, composition, etc. of the image.
[0003] At present, in order to meet the needs of users for image preferences, the camera function in electronic devices can automatically adjust the brightness or select the corresponding shooting mode according to the type of the photographed object, such as portrait, macro, night scene, etc. However, the existing method mainly considers the type of the photographed object, and does not fully consider the user's personal aesthetic preferences, resulting in deviations in image processing effects and reducing image processing accuracy. Summary of the invention
[0004] The embodiments of the present application provide an image processing method, an electronic device, and a computer-readable storage medium, which are used to solve the problem that existing image processing does not take into account the user's personal aesthetic preferences, resulting in deviations in image processing effects and reduced image processing accuracy.
[0005] To achieve the above objectives, the embodiments of the present application adopt the following technical solutions:
[0006] In a first aspect, an image processing method is provided, which is applied to an electronic device, in which a plurality of candidate image contents are stored, and each candidate image content corresponds to at least one image style, comprising: after the electronic device displays a first image of a first image style in a user interface, the electronic device receives a first operation of the user in the user interface, and the first operation is used to trigger the electronic device to convert the image style of the image in the user interface. Then, in response to the first operation, the electronic device extracts the image content of the first image, and uses at least one image style corresponding to the candidate image content with the highest similarity to the image content of the first image as the candidate image style. Finally, the user's preference for the candidate image style is obtained, and a second image style is selected from the candidate image styles according to the preference, and a second image of the second image style is displayed in the user interface. Wherein, the user interface can be a large image display page of a gallery in the electronic device, then the first image is an image in the gallery, and the second image is an image obtained by converting the first image from the first image style to the second image style. Alternatively, the user interface can also be a preview interface of an image captured by the electronic device, then the first image is obtained by processing an image captured in real time by the camera of the electronic device using the first image style, and the second image is obtained by processing an image captured in real time by the camera of the electronic device using the second image style.
[0007] Since the user's preference level can usually reflect the user's personal preference, the electronic device can match and select a second image style that meets the user's personal style aesthetic preference based on the user's personal preference level for the candidate image style, thereby achieving style processing of the image based on the user's personal aesthetic preference, thereby ensuring that the image processing effect meets the user's personal aesthetic and improving the accuracy of image processing. At the same time, by matching the candidate image style based on the image content of the first image displayed on the current user interface, an image style that meets the image content can be obtained, thereby further improving the accuracy of image style conversion processing while satisfying the user's personal aesthetic preference.
[0008] In a possible implementation of the first aspect, generally speaking, the more frequently a user uses an image style, the higher the user's preference for the image style. Therefore, the user's preference for a candidate image style can be: the personal usage frequency of the candidate image style. Therefore, the electronic device also stores the personal usage frequency of each image style corresponding to each candidate image content. In addition, since the electronic device is always used by the user, the personal usage frequency of each image style stored in the electronic device may change due to the user's selection behavior. Therefore, in order to ensure that the personal usage frequency can timely reflect the most realistic preference level, the electronic device can update the personal usage frequency according to the user's operation.
[0009] Based on this, the above-mentioned image processing method also includes: receiving a second operation of the user in the user interface, the second operation is used to trigger the electronic device to save a second image of the second image style; in response to the second operation, updating the saved personal usage frequency of the second image style. It can be seen that for the second image of the second image style that the user determines to save, the electronic device promptly updates the personal usage frequency of the second image style to ensure the authenticity of the personal usage frequency corresponding to the candidate image style.
[0010] In a possible implementation of the first aspect, extracting the image content of the first image includes: inputting the first image into a first multimodal large language model, and encoding the content output by the image encoder and the image-text alignment layer in the first multimodal large language model as the image content of the first image. The electronic device includes the first multimodal large language model, and the first multimodal large language model is a trained second multimodal large language model.
[0011] The image content of the first image is extracted by using the first multimodal large language model, thereby improving the accuracy of similarity calculation between the candidate image content and the image content of the first image.
[0012] In a possible implementation of the first aspect, if the data such as the candidate image content and image style are directly stored in the electronic device in the form of an image, a large amount of storage space will be occupied. Therefore, the image processing method also includes: extracting the content code of the candidate image using the image encoder and the image-text alignment layer in the first multimodal large language model, clustering the content code and annotating the content of each category after clustering to obtain the candidate image content; extracting text features from the candidate style description text using the large language model in the first multimodal large language model, and then using the linear projection layer to perform image-text alignment processing on the text features to obtain the style code, clustering the style code and annotating the style of each category after clustering to obtain the image style corresponding to the candidate image content. Among them, the first multimodal large language model is a trained second multimodal large language model; the first multimodal large language model includes an image encoder, an image-text alignment layer and a large language model. Thus, the candidate image content and image style in the encoded form are obtained by the first multimodal large language model, and each candidate image content and image style in the same cluster are clustered as a candidate image content and image style, thereby reducing the amount of stored data.
[0013] In a possible implementation manner of the first aspect, the image processing method further includes: after performing classification training on the second multimodal large language model for style decision factors, training the image content extraction capability of the second multimodal large language model to obtain the first multimodal large language model; wherein the style decision factors include at least one or more of the environment, light, and subject; the second multimodal large language model includes an image encoder, an image-text alignment layer, and a large language model; wherein the output of the image encoder is the input of the image-text alignment layer, and the output of the image-text alignment layer is the input of the large language model.
[0014] In this implementation, the first multimodal large language model is obtained by training the second multimodal large language model in two stages, so that the first multimodal large language model obtained by training has the ability to extract fine-grained image content while also having the ability to extract style decision factors.
[0015] In a possible implementation of the first aspect, generally speaking, the more times it is used, the higher the frequency of use. Conversely, the fewer times it is used, the lower the frequency of use. Therefore, the electronic device can determine the personal usage frequency by counting the number of times users personally use various image styles. Based on this, obtaining the user's personal usage frequency of the candidate image style includes: counting the number of times the user personally uses each candidate image style corresponding to the candidate image content; normalizing the number of times the user personally uses the candidate image style to obtain the personal usage frequency of the candidate image style. Therefore, determining the personal usage frequency by counting the number of times the user personally uses the image style can ensure the accuracy of the personal usage frequency.
[0016] In a possible implementation of the first aspect, the electronic device further stores the public usage frequency of each image style corresponding to each candidate image content; the public usage frequency is obtained by counting the number of public usages of each candidate image style corresponding to each candidate image content and then performing normalized calculation; obtaining the user's personal usage frequency of the candidate image style includes: performing weighted calculation on the public usage frequency and the personal usage frequency corresponding to the same candidate image style, and using the obtained weighted frequency as the final personal usage frequency of the candidate image style.
[0017] In this implementation, the electronic device combines the public usage frequency to obtain the user's final personal usage frequency, which can ensure the accuracy of the personal usage frequency when the user wants to refer to public aesthetics or the amount of user personal usage data is small.
[0018] In a possible implementation of the first aspect, the electronic device includes a first image generation model, and the first image generation model is a trained second image generation model; displaying a second image of a second image style on a user interface includes: inputting an image in a gallery or an image captured in real time by a camera of the electronic device and the second image style into the first image generation model, obtaining and displaying the second image on the user interface. In this implementation, the trained neural network model can be used to quickly and accurately generate a second image of the second image style.
[0019] In a possible implementation manner of the first aspect, the image processing method also includes: performing a first-stage training on a second image generation model using a noise image and a style description text to obtain a first-stage image generation model; performing a second-stage training on the first-stage image generation model using a first training image and a style description text to obtain a second-stage image generation model; performing a third-stage training on the second-stage image generation model using a second training image and a style description text to obtain a first image generation model; wherein the image style of the second training image is opposite to the image style described by the style description text.
[0020] In a possible implementation of the first aspect, the electronic device may select at least two second image styles from the candidate image styles according to the degree of preference, and the second image includes at least two second sub-images, and the second sub-images correspond to different second image styles. Furthermore, the electronic device may display the second image of the second image style in the user interface, which may include: displaying a second sub-image in the user interface; receiving a third operation of the user in the user interface, the third operation is used to trigger the electronic device to switch the display of the second sub-image; and responding to the third operation, switching to display another second sub-image. It can be seen that this implementation matches at least two second image styles according to the user's personal preference for the candidate image style, which can provide the user with more style choices to meet the user's personal aesthetic preferences and improve the accuracy of image processing.
[0021] In a possible implementation of the first aspect, in order to meet the user's demand for turning off personalized processing, after the second image of the second image style is displayed on the user interface, the image processing method also includes: receiving a fourth operation of the user on the user interface, the fourth operation being used to trigger the electronic device to restore the image style of the image in the user interface; and in response to the fourth operation, displaying the first image of the first image style on the user interface.
[0022] In a second aspect, the present application provides an electronic device, comprising: a memory, a display screen and one or more processors, wherein the memory and the display screen are coupled to the processor; the display screen is used to display a user interface, and one or more computer program codes are stored in the memory, wherein the computer program codes include computer instructions; when the processor executes the computer instructions, the electronic device performs the following steps: displaying a first image of a first image style in the user interface; receiving a first operation of the user in the user interface, wherein the first operation is used to trigger the electronic device to convert the image style of the image in the user interface. Then, in response to the first operation, the electronic device extracts the image content of the first image, and uses at least one image style corresponding to the candidate image content with the highest similarity to the image content of the first image as the candidate image style. Finally, the user's preference for the candidate image style is obtained, and a second image style is selected from the candidate image styles according to the preference, and a second image of the second image style is displayed in the user interface; wherein the user interface can be a large image display page of a gallery in the electronic device, then the first image is an image in the gallery, and the second image is an image obtained by converting the first image from the first image style to the second image style. Alternatively, the user interface can also be a preview interface of an image captured by the electronic device, then the first image is obtained by processing an image captured in real time by the camera of the electronic device using the first image style, and the second image is obtained by processing an image captured in real time by the camera of the electronic device using the second image style.
[0023] In a possible implementation of the second aspect, when the above-mentioned computer instructions are executed by the processor, the electronic device further performs the following steps: receiving a second operation of the user on the user interface, the second operation is used to trigger the electronic device to save a second image of a second image style; in response to the second operation, updating the personal usage frequency of the saved second image style.
[0024] In a possible implementation manner of the second aspect, when the above-mentioned computer instructions are executed by the processor, the electronic device further performs the following steps: inputting the first image into a first multimodal large language model, and encoding the content output by the image encoder and the image-text alignment layer in the first multimodal large language model as the image content of the first image.
[0025] In a possible implementation manner of the second aspect, when the above-mentioned computer instructions are executed by the processor, the electronic device further performs the following steps: using the image encoder and the image-text alignment layer in the first multimodal large language model to extract the content coding of the candidate image, clustering the content coding and annotating the content of each category after clustering to obtain the candidate image content; using the large language model in the first multimodal large language model to extract text features of the candidate style description text, and then using the linear projection layer to align the text features to obtain the style coding, clustering the style coding and style annotating each category after clustering to obtain the image style corresponding to the candidate image content.
[0026] In a possible implementation manner of the second aspect, when the above-mentioned computer instructions are executed by the processor, the electronic device further performs the following steps: after performing classification training on the second multimodal large language model for style decision factors, the image content extraction capability of the second multimodal large language model is trained to obtain the first multimodal large language model; wherein the style decision factors include at least one or more of the environment, light, and subject; the second multimodal large language model includes an image encoder, an image-text alignment layer, and a large language model; wherein the output of the image encoder is the input of the image-text alignment layer, and the output of the image-text alignment layer is the input of the large language model.
[0027] In a possible implementation of the second aspect, when the above-mentioned computer instructions are executed by the processor, the electronic device further performs the following steps: counting the number of times users personally use each candidate image style corresponding to the candidate image content; and performing normalized calculation on the number of times users personally use the candidate image style to obtain the personal usage frequency of the candidate image style.
[0028] In a possible implementation of the second aspect, when the above-mentioned computer instructions are executed by the processor, the electronic device further performs the following steps: weighted calculation of the public usage frequency and personal usage frequency corresponding to the same candidate image style, and using the obtained weighted frequency as the final personal usage frequency of the candidate image style.
[0029] In a possible implementation of the second aspect, when the above-mentioned computer instructions are executed by the processor, the electronic device further performs the following steps: inputting the image in the gallery or the image captured in real time by the camera of the electronic device and the second image style into the first image generation model, and obtaining and displaying the second image on the user interface.
[0030] In a possible implementation of the second aspect, when the above-mentioned computer instructions are executed by the processor, the electronic device further performs the following steps: performing a first-stage training on the second image generation model using the noise image and the style description text to obtain the first-stage image generation model; performing a second-stage training on the first-stage image generation model using the first training image and the style description text to obtain the second-stage image generation model; performing a third-stage training on the second-stage image generation model using the second training image and the style description text to obtain the first image generation model; wherein the image style of the second training image is opposite to the image style described by the style description text.
[0031] In a possible implementation of the second aspect, when the computer instructions are executed by the processor, the electronic device further performs the following steps: displaying a second sub-image on the user interface; receiving a third operation of the user on the user interface, the third operation is used to trigger the electronic device to switch the display of the second sub-image; and in response to the third operation, switching to display another second sub-image. The second sub-image corresponds to different second image styles, and at least two second image styles are selected from the candidate image styles according to the degree of preference.
[0032] In a possible implementation of the second aspect, when the above-mentioned computer instructions are executed by a processor, the electronic device further performs the following steps: receiving a fourth operation of the user in the user interface, the fourth operation is used to trigger the electronic device to restore the image style of the image in the user interface; in response to the fourth operation, displaying the first image of the first image style in the user interface.
[0033] In a third aspect, the present application provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor in an electronic device, the electronic device executes the image processing method of the first aspect and any possible design thereof.
[0034] In a fourth aspect, the present application provides a computer program product, which, when executed on a computer, enables the computer to execute the method of the first aspect and any possible design thereof. The computer may be the electronic device described above.
[0035] It can be understood that the beneficial effects that can be achieved by the electronic device of any possible design of the second aspect, the computer-readable storage medium of the third aspect, and the computer program product of the fourth aspect can be referred to as the beneficial effects in the first aspect and any possible design of the electronic device, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 A schematic diagram of image style preferences of different users in the same scene provided in an embodiment of the present application;
[0037] Figure 2 An operation diagram of performing a first operation on a user interface provided in an embodiment of the present application;
[0038] Figure 3 A schematic diagram of the structure of an electronic device 100 provided in an embodiment of the present application;
[0039] Figure 4 A software structure block diagram of an electronic device 100 provided in an embodiment of the present application;
[0040] Figure 5 A flowchart of an image processing method provided in an embodiment of the present application;
[0041] Figure 6 A schematic diagram of training a multimodal large language model provided in an embodiment of the present application;
[0042] Figure 7 A schematic diagram of a process for constructing candidate image content and image style provided in an embodiment of the present application;
[0043] Figure 8 A training diagram of a linear projection layer provided in an embodiment of the present application;
[0044] Fig. 9 A schematic diagram of image content extraction of a first image provided in an embodiment of the present application;
[0045] Fig.10 A schematic diagram of a personal frequency matrix provided in an embodiment of the present application;
[0046] Fig.11 A schematic diagram of a personal quantity matrix provided in an embodiment of the present application;
[0047] Fig.12 A schematic diagram of a training process of an image generation model provided in an embodiment of the present application;
[0048] Fig.13 A schematic diagram of a second image switching operation provided in an embodiment of the present application;
[0049] Fig.14 A flowchart of another image processing method provided in an embodiment of the present application;
[0050] Fig.15 An operation diagram of performing a fourth operation on a user interface provided in an embodiment of the present application;
[0051] Fig.16 A flowchart of another image processing method provided in an embodiment of the present application. DETAILED DESCRIPTION
[0052] The technical solutions of the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application. Among them, in the description of the embodiments of the present application, the terms used in the following embodiments are only for the purpose of describing specific embodiments, and are not intended to limit the present application. In addition, in order to facilitate the clear description of the technical solutions of the embodiments of the present application, in the embodiments of the present application, the words "first", "second" and the like are used to distinguish the same items or similar items with substantially the same functions and effects. It can be understood by those skilled in the art that the words "first", "second" and the like do not limit the quantity and execution order, and the words "first", "second" and the like do not limit certain differences. And, in the description of the embodiments of the present application, unless otherwise specified, the meaning of "multiple" means two or more.
[0053] With the development of electronic device technology, more and more electronic devices are equipped with camera modules for users to take pictures. Based on user shooting needs and aesthetics, users have different preferences for the image style of the images taken in the same scene. For example, different users have different requirements for the color tone, light, composition, etc. of the image. Figure 1 As shown, a schematic diagram of image style preferences of different users in the same scene is provided. Figure 1 (1a) in the figure is the image style preferred by user A in the portrait scene. Figure 1 (1b) in is the image style preferred by user B in the portrait scene. As can be seen from the figure, user B prefers grayscale image style more in the portrait scene than user A.
[0054] At present, in order to meet the needs of users with different image style preferences, the camera function in the electronic device can automatically adjust the brightness or select the corresponding shooting mode according to the type of the photographed object. For example, when the photographed object is a person, the electronic device can select the portrait mode accordingly. When the photographed object is food, the electronic device can select the gourmet mode accordingly. The electronic device can also select macro, night scene and other shooting modes according to other actual shooting situations.
[0055] However, the existing method mainly considers the type of the photographed object, that is, the type of the photographed subject, and does not fully consider the user's personal aesthetic preferences, resulting in deviations in image processing effects and reducing image processing accuracy.
[0056] In order to solve the above problems, an embodiment of the present application provides an image processing method. The image processing method is applied to electronic devices, and the image processing method provided by the embodiment of the present application is described below using electronic devices as an example.
[0057] First, the electronic device responds to the user's operation and displays a first image of a first image style in the user interface. The user interface may be a preview interface for images captured by the electronic device. Then, the first image may be the image displayed in the camera viewfinder after the electronic device responds to the user's operation to turn on the camera function. In other words, the first image may be an image captured in real time by the camera of the electronic device. In addition, the user interface may also be a large image display page of a gallery (album) in the electronic device. Then, the first image may also be an image that has been stored after the shooting is completed, such as an image stored in a gallery (album) in the electronic device. The first image style is the image style of the image in the user interface before the electronic device performs image style conversion, which can be understood as the original image style.
[0058] Then, the electronic device waits to receive a first operation of the user in the user interface. The first operation is used to trigger the electronic device to convert the image style of the image displayed in the user interface. In the embodiment of the present application, the conversion of the image style can be understood as performing personalized style processing on the image. Personalized style processing refers to performing corresponding style processing on the image based on the user's personal style aesthetic preference, including image tone processing, light processing, etc.
[0059] Secondly, since the user's preference degree can usually reflect his personal preference, in the embodiment of the present application, after the electronic device receives the user's first operation on the user interface, it responds to the first operation and matches the second image style that meets the user's personal style aesthetic preference according to the user's personal preference degree for all candidate image styles. Among them, the candidate image style is obtained by matching the image content of the first image. In the electronic device, a variety of candidate image contents are pre-stored, and each candidate image content corresponds to at least one image style. Furthermore, when the electronic device receives the first operation to determine that the image style needs to be converted, the image content of the first image is first extracted. Then, the electronic device matches the extracted image content of the first image with the stored multiple candidate image contents. The image style corresponding to the candidate image content that matches the image content of the first image is the image style corresponding to the image content of the first image, which is referred to as the candidate image style in the embodiment of the present application. Among them, whether the image content matches can be determined by calculating the similarity, and the image style corresponding to the candidate image content with the highest similarity to the image content of the first image is used as the candidate image style.
[0060] After obtaining the candidate image styles, the electronic device selects an image style from the candidate image styles as the second image style according to the user's preference level (preference level) for each candidate image style. For example, the image style with the highest user preference level (preference level) may be selected from the candidate image styles as the second image style that meets the user's personal aesthetic preference.
[0061] In an embodiment of the present application, by selecting an image style as the second image style based on the image content of the first image displayed by the current user interface and the user's preference, an image style that is more in line with the currently displayed image content can be obtained, thereby further improving the accuracy of the image style conversion processing while satisfying the user's personal aesthetic preferences.
[0062] Finally, the electronic device performs image style conversion according to the matched second image style, converts the image style of the image in the user interface, and converts its image style to the selected second image style. After the image style conversion is completed, the electronic device displays the second image of the second image style in the user interface.
[0063] Among them, when the user interface is a large image display page of a gallery (album), and the first image is an image saved in the gallery (album), since the first image is an image that has been shot and saved, its image content generally does not change. Therefore, the second image is an image that converts the first image from the first image style to the second image style. In other words, in this case, the image styles of the first image and the second image are different, but the image content is exactly the same.
[0064] When the user interface is a preview interface of the camera function in the electronic device, the image in the viewfinder in the preview interface is an image captured in real time by the camera of the electronic device. Therefore, when the electronic device is held by the user, the image captured by the camera is prone to change due to the user's actions, causing the image content in the viewfinder to change. Or, when the object captured by the camera of the electronic device is dynamically changing (such as sunrise, sunset, etc.), it will also cause slight changes in the image content in the viewfinder. Therefore, the first image and the second image are images captured in real time by the camera of the electronic device at different times. The image content of the first image and the second image is not necessarily exactly the same. Therefore, the second image of the second image style displayed in the user interface is not necessarily an image that converts the first image from the first image style to the second image style. At this time, the second image should be an image captured in real time by the camera processed with the second image style. Similarly, the first image of the first image style displayed in the user interface is an image captured in real time by the camera processed with the first image style.
[0065] In summary, when the user interface is a preview interface, the image content of the first image and the second image are based on the image content captured by the camera of the electronic device in real time. In this case, after the electronic device performs image style conversion processing, the image content of the first image and the second image may be exactly the same except for the different image styles, or may differ due to the user's hand-held movements or dynamic changes in the object captured by the camera. Only when the image captured by the camera of the electronic device in real time before and after the image style conversion is completely unchanged, can the second image be understood as an image that converts the first image from the first image style to the second image style.
[0066] Exemplarily, the first operation may be a user clicking an "image style processing" button / control on the electronic device. The "image style processing" is displayed on the user interface, and the "image style processing" button / control may be any icon or character according to the design requirements of the actual functional interface of the user interface.
[0067] Take mobile phones as an example, for example, Figure 2 The user interface shown is a preview interface of the camera in the mobile phone. The "Image Style Processing" button / control is Figure 2 Therefore, when the electronic device receives the user's click operation (first operation) on the "AI" button / control in the preview interface, the electronic device begins to respond to the first operation. Figure 2 The character image in the preview interface shown is style converted.
[0068] For example, Figure 3 As shown, a structural schematic diagram of an electronic device 100 is provided.
[0069] The electronic device 100 in the embodiment of the present application may include at least one of a mobile phone, a camera, a camcorder, a foldable electronic device, a tablet computer, a desktop computer, a laptop computer, a handheld computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, a cellular phone, a personal digital assistant (PDA), an augmented reality (AR) device, a virtual reality (VR) device, an artificial intelligence (AI) device, a wearable device, a vehicle-mounted device, a smart home device, or a smart city device.
[0070] The embodiment of the present application does not impose any special limitation on the specific type of the electronic device.
[0071] The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) connector 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera module 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. Among them, the sensor module 180 may include a pressure sensor, a gyroscope sensor, an air pressure sensor, a magnetic sensor, an acceleration sensor, a distance sensor, a proximity light sensor, a fingerprint sensor, a temperature sensor, a touch sensor, an ambient light sensor, a bone conduction sensor, etc.
[0072] The processor 110 may include one or more processing units, for example, the processor 110 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.
[0073] The processor 110 can generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions. Specifically in the embodiment of the present application, the conversion of image style can be achieved by executing relevant instructions by the processor 110 of the electronic device 100. That is, the processor 110 of the electronic device responds to the first operation, extracts the first image to obtain the image content, and uses at least one image style corresponding to the candidate image content with the highest similarity to the image content of the first image among multiple candidate image contents as the candidate image style. Then, the processor 110 obtains the user's preference for the candidate image style, and selects a second image style from the candidate image styles according to the preference. Finally, the second image of the second image style is displayed on the user interface.
[0074] A memory may also be provided in the processor 110 for storing instructions and data. In some embodiments, the memory in the processor 110 may be a cache memory. The memory may store instructions or data that have been used by the processor 110 or are used frequently. If the processor 110 needs to use the instruction or data, it may be directly called from the memory. Repeated access is avoided, and the waiting time of the processor 110 is reduced, thereby improving the efficiency of the system. Specifically in the embodiment of the present application, the memory may store a plurality of candidate image contents, and store at least one image style corresponding to each candidate image content.
[0075] In some embodiments, the processor 110 may include one or more interfaces. The interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc. The processor 110 may be connected to a touch sensor, an audio module, a wireless communication module, a display screen, a camera module, and the like through at least one of the above interfaces.
[0076] It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present application is only a schematic illustration and does not constitute a structural limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
[0077] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to implement a data storage function. For example, files such as music and videos are stored in the external memory card. Or files such as music and videos are transferred from the electronic device to the external memory card.
[0078] The internal memory 121 can be used to store computer executable program codes, which include instructions. The internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system, an application required for at least one function (such as an image capture function, a sound playback function, an image playback function, etc.), etc. The data storage area may store data created during the use of the electronic device 100 (such as audio data, a phone book, etc.), etc. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc. The processor 110 executes various functional methods or data processing of the electronic device 100 by running instructions stored in the internal memory 121, and / or instructions stored in a memory provided in the processor.
[0079] The charging management module 140 is used to receive the charging input of the charger and charge the battery 142. While the charging management module 140 is charging the battery 142, it can also power the electronic device through the power management module 141.
[0080] The power management module 141 is used to connect the battery 142, the charging management module 140 and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140, and supplies power to the processor 110, the internal memory 121, the display screen 194, the camera module 193, the wireless communication module 160, etc. The power management module 141 can also be used to monitor parameters such as battery capacity, battery cycle number, battery health status (leakage, impedance), etc. In some other embodiments, the power management module 141 can also be set in the processor 110. In other embodiments, the power management module 141 and the charging management module 140 can also be set in the same device.
[0081] The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.
[0082] Among them, antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. The mobile communication module 150 can provide solutions for wireless communications including 2G / 3G / 4G / 5G applied to the electronic device 100. The wireless communication module 160 can provide solutions for wireless communications including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), Bluetooth low energy (BLE), ultra wide band (UWB), global navigation satellite system (GNSS), frequency modulation (FM), near field communication technology (NFC), infrared technology (IR), etc. applied to the electronic device 100.
[0083] In some embodiments, antenna 1 of electronic device 100 is coupled to mobile communication module 150, and antenna 2 is coupled to wireless communication module 160, so that electronic device 100 can communicate with a network and other electronic devices through wireless communication technology.
[0084] The electronic device 100 can realize the display function through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs, which execute program instructions to generate or change display information.
[0085] The display screen 194 is used to display images, videos, etc. Specifically in the embodiment of the present application, the display screen 194 can display the user interface in the embodiment of the present application, and display the first image of the first image style and the second image of the second image style in the user interface. The display screen 194 includes a display panel. In the embodiment of the present application, the display panel can adopt 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), Miniled, MicroLed, Micro-oLed, a quantum dot light emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include one or more display screens 194.
[0086] The electronic device 100 can realize the camera function through the camera module 193, ISP, video codec, GPU, display screen 194, application processor AP, neural network processor NPU, etc.
[0087] The camera module 193 can be used to collect color image data and depth data of the photographed object. The ISP can be used to process the color image data collected by the camera module 193. For example, when taking a photo, the shutter is opened, and the light is transmitted to the camera photosensitive element through the lens. The light signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to the ISP for processing and converts it into an image visible to the naked eye (such as the first image and the second image in the embodiment of the present application). The ISP can also perform algorithm optimization on the noise, brightness, and skin color of the image. The ISP can also optimize the exposure, color temperature and other parameters of the shooting scene. In some embodiments, the ISP can be set in the camera module 193.
[0088] In some embodiments, the camera module 193 may be composed of a color camera module and a 3D sensing module.
[0089] In some embodiments, the photosensitive element of the camera of the color camera module can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the light signal into an electrical signal, and then transmits the electrical signal to the ISP to be converted into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in a standard RGB, YUV or other format.
[0090] In some embodiments, the 3D sensing module may be a time of flight (TOF) 3D sensing module or a structured light 3D sensing module. Among them, structured light 3D sensing is an active depth sensing technology, and the basic components of the structured light 3D sensing module may include an infrared emitter, an IR camera module, etc. The working principle of the structured light 3D sensing module is to first emit a light spot of a specific pattern to the object being photographed, and then receive the light spot pattern coding (light coding) on the surface of the object, and then compare the similarities and differences with the original projected light spot, and use the triangulation principle to calculate the three-dimensional coordinates of the object. The three-dimensional coordinates include the distance between the electronic device 100 and the object being photographed. Among them, TOF 3D sensing may be an active depth sensing technology, and the basic components of the TOF 3D sensing module may include an infrared emitter, an IR camera module, etc. The working principle of the TOF 3D sensing module is to calculate the distance (i.e., depth) between the TOF 3D sensing module and the object being photographed by the time when the infrared rays return to obtain a 3D depth map.
[0091] The structured light 3D sensing module can also be applied to face recognition, somatosensory game consoles, industrial machine vision inspection and other fields. The TOF 3D sensing module can also be applied to game consoles, augmented reality (AR) / virtual reality (VR) and other fields.
[0092] In other embodiments, the camera module 193 may also be composed of two or more cameras. The two or more cameras may include a color camera, which can be used to collect color image data of the photographed object. The two or more cameras may use stereo vision technology to collect depth data of the photographed object. Stereo vision technology is based on the principle of human eye parallax. Under natural light, two or more cameras are used to capture images of the same object from different angles, and then triangulation and other operations are performed to obtain the distance information between the electronic device 100 and the photographed object, that is, depth information.
[0093] In some embodiments, the electronic device 100 may include one or more camera modules 193. Specifically, the electronic device 100 may include one front camera module 193 and one rear camera module 193. The front camera module 193 may generally be used to collect color image data and depth data of the photographer facing the display screen 194, and the rear camera module may be used to collect color image data and depth data of the subject (such as a person, scenery, etc.) facing the photographer.
[0094] In some embodiments, the CPU or GPU or NPU in the processor 110 can process the color image data and depth data collected by the camera module 193. In some embodiments, the NPU can identify the color image data collected by the camera module 193 (specifically the color camera module) through a neural network algorithm based on the skeleton point recognition technology, such as a convolutional neural network algorithm (CNN), to determine the image content of the photographed object. The CPU or GPU can also run a neural network algorithm to determine the image content of the photographed object based on the color image data.
[0095] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 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.
[0096] refer to Figure 4 , which is a software structure block diagram of the electronic device 100 according to an embodiment of the present application.
[0097] 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 five layers, from top to bottom: application layer (applications), application framework layer (application framework), Android runtime (Android runtime, ART) and native C / C++ library, hardware abstract layer (HAL) and kernel layer (kernel).
[0098] The application layer can include a series of applications. Figure 4 As shown, the application package may include camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message and other applications.
[0099] The application framework layer provides application programming interface (API) and programming framework for the applications in the application layer. The application framework layer includes some predefined functions. Figure 4 As shown, the application framework layer may include a window manager, a content provider, a view system, a resource manager, a notification manager, an activity manager, an input manager, and the like.
[0100] The window manager provides window management services (WMS). WMS can be used for window management, window animation management, surface management, and as a transfer station for the input system.
[0101] Content providers are used to store and retrieve data and make it accessible to applications. This data can include video, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.
[0102] 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.
[0103] The resource manager provides various resources for applications, such as localized strings, icons, images, layout files, video files, and so on.
[0104] 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.
[0105] The activity manager can provide activity management services (AMS), which can be used to start, switch, and schedule system components (such as activities, services, content providers, and broadcast receivers) as well as manage and schedule application processes.
[0106] The input manager can provide input management services (IMS), which can be used to manage system input, such as touch screen input, key input, sensor input, etc. IMS takes events from input device nodes and distributes them to appropriate windows through interaction with WMS.
[0107] The Android runtime includes the core library and the Android runtime. The Android runtime is responsible for converting source code into machine code. The Android runtime mainly uses the ahead of time (AOT) compilation technology and the just in time (JIT) compilation technology.
[0108] The core library is mainly used to provide basic Java class library functions, such as basic data structures, mathematics, IO, tools, databases, networks, etc. The core library provides an API for users to develop Android applications.
[0109] The native C / C++ library can include multiple functional modules, such as surface manager, media framework, libc, OpenGL ES, SQLite, Webkit, etc.
[0110] Among them, the surface manager is used to manage the display subsystem and provide fusion of 2D and 3D layers for multiple applications. The media framework 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. OpenGL ES provides drawing and operation of 2D graphics and 3D graphics in applications. SQLite provides a lightweight relational database for applications of electronic device 100.
[0111] The hardware abstraction layer runs in user space, encapsulates the kernel layer driver, and provides a calling interface to the upper layer. The hardware abstraction layer includes at least a display module, an audio module, a camera module, and a Bluetooth module.
[0112] The kernel layer is the layer between hardware and software. The kernel layer includes at least display driver, camera driver, audio driver, and Bluetooth driver.
[0113] The following is an illustrative description of the workflow of the software and hardware of the electronic device 100 in conjunction with capturing a photo scene.
[0114] When the touch sensor receives a touch operation, the corresponding hardware interrupt is sent to the kernel layer. The kernel layer processes the touch operation into an original input event (including touch coordinates, timestamp of the touch operation, and other information). The original input event is stored in the kernel layer. The application framework layer obtains the original input event from the kernel layer and identifies the control corresponding to the input event. Taking the touch operation as a touch single-click operation, and the control corresponding to the single-click operation as an example, the camera application calls the interface of the application framework layer, starts the camera application, and then starts the camera driver by calling the kernel layer, and captures a static image or video through the camera module 193. Specifically to the embodiment of the present application, the image or video captured by the camera module 193 can be regarded as the first image or the second image in the embodiment of the present application.
[0115] like Figure 5 As shown, a flowchart of an image processing method is provided. Figure 5 The image processing method provided in the embodiment of the present application is described in detail. Figure 5 , the image processing method includes steps S501-S505.
[0116] S501: The electronic device displays a first image of a first image style on a user interface.
[0117] S502: The electronic device receives a first operation performed by a user on a user interface.
[0118] The user interface may be a large image display page of a gallery in an electronic device, and the first image style is the image style before the electronic device performs style conversion, which can be understood as the original image style. The first image is the image displayed in the large image display page, that is, the image saved in the gallery. The image style of the first image is the first image style.
[0119] The user interface can also be a preview interface of the image captured in the electronic device. Then the first image is the image captured in real time by the camera of the electronic device, and it is processed using the first image style and displayed in the user interface, that is, the image captured in real time by the camera is displayed in the user interface in the first image style.
[0120] The first operation is used to trigger the electronic device to convert the image style of the image in the user interface. For example, the image displayed in the user interface is converted from a first image style to a second image style.
[0121] S503: In response to the first operation, the electronic device extracts image content of the first image, and uses at least one image style corresponding to the candidate image content having the highest similarity to the image content of the first image as a candidate image style.
[0122] S504, obtaining the user's preference for the candidate image styles, and selecting a second image style from the candidate image styles according to the preference.
[0123] The electronic device stores a plurality of candidate image contents, and each candidate image content stores at least one image style. The candidate image contents and image styles can be understood as candidate data pre-stored for the electronic device to match the second image style. The electronic device determines the candidate image style corresponding to the image content of the first image from the stored image styles.
[0124] The preference level is used to measure the user's personal preference for the candidate image style. The higher the preference level of the candidate image style, the more the user's shooting needs and aesthetics prefer the candidate image style. Therefore, the candidate image style with a higher preference level is more in line with the user's personal aesthetic preference needs.
[0125] Specifically, the electronic device first extracts the image content of the first image, matches the image content with the candidate image content stored locally, and uses all image styles corresponding to the matched candidate image content as the candidate image styles of the embodiment of the present application. The matching process can be determined by calculating the similarity of the two image contents, and the electronic device selects the image style corresponding to the candidate image content with the highest similarity to the image content of the first image as the candidate image style.
[0126] Exemplarily, assuming that the candidate image contents stored in the electronic device include image content 1, image content 2, ... image content n, then when the image content of the first image has the highest similarity to image content 2, image style 1, image style 2, ... image style n corresponding to image content 2 are determined as candidate image styles.
[0127] Then, the electronic device selects an image style as the second image style according to the user's preference for each candidate style, such as image style 1, image style 2, ..., image style n. For example, the electronic device may select the image style with the highest preference of the user from the candidate image styles as the second image style matched and selected in the embodiment of the present application.
[0128] In some embodiments, a storage space may be allocated locally in the electronic device to store candidate image content and image styles corresponding to the candidate image content. This is equivalent to establishing a style library locally in the electronic device, storing the determined candidate image content and image style in the style library, and subsequently the electronic device directly matches the candidate image style corresponding to the image content of the first image in the style library.
[0129] Based on this, if the candidate image content and image style data are directly stored in the style library in the form of images, it will inevitably take up a large amount of storage space in the electronic device. Therefore, in order to reduce the amount of data stored in the local style library, the storage space occupied by the style library should be reduced as much as possible. The candidate image content and image style can be stored in the style library in a coded form, and a large number of candidate image content and image styles can be divided in advance by clustering, and each candidate image content and image style in the same cluster after clustering is regarded as a candidate image content and image style, thereby achieving the purpose of reducing the amount of data.
[0130] Therefore, the construction of multiple candidate image contents in the local style library of the electronic device and at least one image style corresponding to each candidate image content may include: using the image encoder and the image-text alignment layer in the first multimodal large language model to extract the content code of the candidate image, clustering the content code and annotating the content of each category after clustering to obtain the candidate image content; using the large language model in the first multimodal large language model to extract text features of the candidate style description text, and then using the linear projection layer to align the text features to obtain the style code, clustering the style code and style-annotating each category after clustering to obtain the image style corresponding to the candidate image content.
[0131] Among them, the electronic device includes a first multimodal large language model, and the first multimodal large language model is a trained second multimodal large language model. It can be seen that the first multimodal large language model and the second multimodal large language model have the same structure. The difference is that the first multimodal large language model is a trained model, and the second multimodal large language model is a model before training. Since the model weights of each structural module will be updated after the model is trained, the difference between the first multimodal large language model and the second multimodal large language model is only that the model weights are different.
[0132] The model structure of the first multimodal large language model and the second multimodal large language model can refer to any existing multimodal large language model, such as the miniGPT-4 model. A multimodal large language model is a multimodal neural network model whose input is an image and whose output is text. In simple terms, the second multimodal large language model can be understood as an open source multimodal large language model, which has certain image recognition question-answering capabilities. The first multimodal large language model in the embodiment of the present application is a model obtained by further targeted training based on the actual application field (image style processing field) on the basis of the second multimodal large language model.
[0133] In an embodiment of the present application, the multimodal large language model includes an image encoder, an image & text alignment layer and a large language model.
[0134] The image encoder is a module used to extract visual features from an image, and can also be called a visual encoder. The image-text alignment layer is used to align images with text. Since images and text are data of different modalities, it is usually necessary to align the image features extracted by the image encoder with the text through alignment processing so that the two can be analyzed and understood together. Simply put, image-text alignment in a multimodal large language model can be understood as mapping the output of the image encoder to the same dimension as the large language model, so that the large language model can obtain the output of the image encoder. The large language model, which can be referred to as LLM for short, is a module used to extract semantic features from text and generate text.
[0135] In the multimodal large language model, the input of the image encoder is an image, which is first processed by the image encoder. Then the output of the image encoder is the input of the image-text alignment layer, and the output of the image-text alignment layer is the input of the large language model. The output of the large language model is the final output of the multimodal large language model.
[0136] To facilitate understanding of the solution, the following first introduces a training process of training the second multimodal large language model to obtain the first multimodal large language model in an embodiment of the present application.
[0137] In an embodiment of the present application, in order to enhance the capabilities of the second multimodal large language model in the application field of image style processing, in addition to training the second multimodal large language model's ability to extract fine-grained image content, the second multimodal large language model's ability to extract style decision factors is also trained. Furthermore, when image recognition question and answer is implemented using the trained first multimodal large language model, the model output not only includes detailed image content features, but also style decision factors to assist in the construction of a style library. In summary, the training process of the second multimodal large language model in an embodiment of the present application may include: after performing classification training on the second multimodal large language model for style decision factors, training the second multimodal large language model's ability to extract image content.
[0138] It can be seen that the training of the second multimodal large language model includes two training stages. The first training stage is used to train the second multimodal large language model to extract the features of style decision factors. The second training stage is used to train the second multimodal large language model to extract fine-grained image content. Among them, the style decision factors include at least one or more of the environment, light, and theme.
[0139] It should be understood that since the multimodal large language model is an open source chatbot model with image understanding capabilities and can realize image recognition question and answer, it can describe images or answer questions about the content of images. Therefore, whether it is the training or application of the multimodal large language model, in addition to the input image, it is also necessary to input the questions that the multimodal large language model needs to answer so that the multimodal large language model can output the corresponding image description text. Among them, the input questions need to be determined based on the actual application situation, and the embodiments of the present application are not limited to this. For example, for the embodiments of the present application, the input questions can be "Please describe the environment / light / theme in this image", "Please describe this image", "How should this image be retouched", "What style is suitable for this image", etc.
[0140] Specifically, Figure 6 As shown, a schematic diagram of training a multimodal large language model is provided.
[0141] refer to Figure 6 In the first training phase, the main purpose is to train the multimodal large prediction model to extract features of style decision factors, so the questions input to the large language model are mainly "please describe the environment / light / theme in this image". Correspondingly, the output of the large language model is mainly text descriptions related to factors such as environment / light / theme.
[0142] In the second training phase, since the main purpose is to train the image content extraction capability, in addition to the image, the questions input to the large language model will be changed to "Please describe this image", "How should this image be edited", "What style is suitable for this image", etc. Then the corresponding output of the large language model is a text description with the image content. At the same time, since the multimodal large language model has completed the first phase of training at this time, the text description it outputs will also include descriptions of some style decision factors.
[0143] In addition, it should be understood that in open source multimodal large language models, image encoders and large language models are usually pre-trained, so most of the training of existing multimodal large language models is mainly to train the image-text alignment layer. Therefore, during the model training process, the model weights of the image encoder and the large language model can be frozen, so that only the model weights of the image-text alignment layer are updated. Of course, it is also possible to choose not to freeze the parameters of the image encoder and the large language model based on actual conditions, so that the model weights of each module in the multimodal large language model are updated to the expected value through training. Embodiments of the present application Figure 6 The example of updating only the model weight of the image-text alignment layer is shown.
[0144] After the training of the multimodal large language model is completed, the parameters of the trained first multimodal large language model are fixed. Then, the first multimodal large language model is called to construct a style library.
[0145] Specifically, refer to Figure 7 When constructing a style library to obtain candidate image content and image style, the electronic device first obtains the collected candidate images and candidate style description texts. The candidate images are images collected for constructing candidate image content, and the candidate style description texts are texts collected for constructing image style.
[0146] After the candidate image is processed by the image encoder and the image-text alignment layer in the first multimodal large language model, the content code is obtained. At the same time, the candidate style description text is input into the large language model in the multimodal large language model to extract text features, and then input into an additional linear projection layer (projector) for image-text alignment processing to obtain the style code. Among them, the linear projection layer has the same function as the image-text alignment layer in the first multimodal large language model, and both are modules for realizing image-text alignment. Therefore, in the embodiment of the present application, the specific network structure of the image-text alignment layer and the linear projection layer can be the same.
[0147] Then, the obtained content codes and style codes are clustered respectively, and the clustering can adopt any existing clustering method, such as K-means clustering, mean shift clustering, density-based clustering method, etc. After clustering, the content codes and style codes will be divided into multiple clusters, that is, divided into multiple categories and each cluster will be briefly labeled.
[0148] The content coding cluster performs content annotation to obtain candidate image content. For example, the candidate image content may be "nature-animal-close-up", "portrait-window-overexposed", etc. The style coding cluster also performs style annotation to obtain image style, such as enhancing brightness, clarity, and vividness. The content annotation and style annotation may be manual annotation, and after the manual annotation is completed, the candidate image content and image style are stored in the electronic device.
[0149] Thus, by pre-building candidate image content and image style and storing them in the local style library of the electronic device, the subsequent electronic device can directly match the corresponding second image style from the local style library to improve the efficiency of image processing. At the same time, the construction of the style library is achieved through clustering, which can further reduce a certain amount of data to save storage space.
[0150] In addition, since the image encoder, image-text alignment layer and large language model used in the embodiments of the present application are modules in the first multimodal large language model. Because the first multimodal large language model is a trained model, these modules can be directly called for use. However, the linear projection layer is an additional module to obtain a style encoding aligned with the content encoding, so in order to enable it to have the corresponding image-text alignment capability, it is necessary to train it in conjunction with the various modules in the first multimodal large language model and put it into use. Moreover, when training the linear projection layer, in order to avoid parameter changes in each module in the trained first multimodal large language model, it is necessary to freeze modules such as the image encoder, image-text alignment layer and large language model during the training process so that these modules will not change due to the training of the linear projection layer.
[0151] Exemplary, reference Figure 8 , the training of the linear projection layer is mainly achieved by constructing comparative learning of content encoding and style encoding with true and false samples (positive and negative samples). Among them, the true sample includes the candidate image used for training and the style description text describing the candidate image. In other words, the image content and the style description text in the true sample are corresponding, and the two are matched, then the label of the true sample is "1" to indicate recommendation. The false sample is the candidate image used for training and the style description text that is completely unrelated to the candidate image. That is, the image content and the style description text in the false sample are different or even opposite, indicating that the image and the style do not correspond, then the label of the false sample is "0" to indicate not recommended.
[0152] Then, the linear projection layer is trained using the constructed true and false samples, and through the "0 / 1" label task, while the true samples guide the linear projection layer to forward learn, the false samples are used to assist in improving the understanding of the linear projection layer, thereby improving the performance of the linear projection layer, so that the linear projection layer can learn to generate different style encodings that match and align with the corresponding content encodings of the image content for text descriptions of different styles.
[0153] After the training of the linear projection layer is completed, it can be used in conjunction with the various modules in the first multimodal large language model to process any collected candidate images and candidate style description texts to obtain aligned content encodings and style encodings. Then, these content encodings and style encodings are clustered to obtain candidate image content and image style to construct a style library. Among them, the number of clusters in the embodiment of the present application can be set according to actual needs, for example, it can be determined according to the storage space of the electronic device, which can be 200 categories, 100 categories, 50 categories, etc., and the embodiment of the present application is not limited to this.
[0154] In some embodiments, since the candidate image content stored in the local style library of the electronic device is represented by the content encoding output by the image encoder and the image-text alignment layer in the first multimodal large language model, in order to improve the accuracy of the similarity calculation between the candidate image content and the image content of the first image, the image content of the first image can be directly extracted by calling the first multimodal large language model.
[0155] Based on this, extracting the image content of the first image may include: inputting the first image into a first multimodal large language model, and encoding the content output by the image encoder and the image-text alignment layer in the first multimodal large language model as the image content of the first image.
[0156] Specifically, when the electronic device extracts the image content of the first image, it first calls the trained first multimodal large language model. After the electronic device calls the first multimodal large language model, it inputs the first image into the first multimodal large language model. Since the embodiment of the present application only needs to obtain the image content of the first image, it is sufficient to directly obtain the output of the image-text alignment layer in the first multimodal large language model. In other words, it is only necessary to obtain the content encoding output after being processed by the image encoder and the image-text alignment layer in the first multimodal large language model. Fig. 9 As shown, an embodiment of the present application provides a schematic diagram of image content extraction.
[0157] In some embodiments, generally speaking, the more frequently a user uses an image style, the higher the user's preference for the image style. Therefore, in the embodiments of the present application, the user's personal preference for the image style can be measured by the user's personal usage frequency of the candidate image style. Based on this, the electronic device also stores the personal usage frequency of each image style corresponding to each candidate image content. The user's personal usage frequency can be the frequency obtained by the electronic device based on the user's historical behavior of selecting and using the image style.
[0158] Specifically, the candidate image content, image style, and personal usage frequency may be stored in a local style library of the electronic device in the form of a matrix, and the matrix in the embodiment of the present application is referred to as a personal frequency matrix.
[0159] Exemplary, reference Fig.10 , each row of the personal frequency matrix represents a candidate image content, each column represents an image style, and the matrix elements represent the personal usage frequency of the candidate image content and its corresponding image style. That is, Fig.10 The image content 1, image content 2, image content 3, ... image content n in are candidate image contents. The image style 1, image style 2, ... image style n are image styles corresponding to the candidate image contents. The matrix elements 11, 12, ... 1n, 21, 22, ... 2n, 31, 32, 3n, ... n1, n2, nn, etc. represent the personal usage frequency.
[0160] After the electronic device determines the candidate image styles corresponding to the image content of the first image, it selects an image style from the candidate image styles as the second image style based on the personal usage frequency of each candidate image style. Generally speaking, the more frequently used image style is the more favorite image style of the user. Therefore, the electronic device can compare the personal usage frequencies of all candidate image styles corresponding to the image content of the first image, and select the image style with the highest personal usage frequency as the second image style. For example, assuming that the candidate image content with the highest similarity to the image content of the first image is Fig.10 If the image content is 1, the corresponding individual usage frequencies of the candidate image styles include 11, 12, ..., 1n. When the individual usage frequency 12 is the maximum value, the electronic device can use the image style 2 corresponding to the individual usage frequency 12 as the second image style.
[0161] In some embodiments, the more times the image is used, the higher the usage frequency. Conversely, the fewer times the image is used, the lower the usage frequency. Therefore, the electronic device can determine the personal usage frequency by counting the number of times the user personally uses various image styles.
[0162] Based on this, obtaining the personal usage frequency of the candidate image styles may include: counting the number of times users personally use each candidate image style corresponding to the candidate image content; and performing normalized calculation on the number of times users personally use the candidate image styles to obtain the personal usage frequency of the candidate image styles.
[0163] Specifically, the electronic device counts the number of times the user personally uses each image style corresponding to the candidate image content according to the image style selected by the user for the candidate image content history.
[0164] For example, Fig.10 Taking the candidate image content and image style as an example, assuming that the historical user has selected and used image style 1 3 times for image content 1, then image style 1 is under image content 1, and the corresponding number of times the user personally uses it is 3. And assuming that the historical user has selected and used image style 1 2 times for image content 2, then image style 1 is under image content 2, and the corresponding number of times the user personally uses it is 2. Then, the electronic device normalizes and calculates the number of times the user personally uses all image styles corresponding to each candidate image content, thereby obtaining the personal use frequency of each image style corresponding to each candidate image content.
[0165] In the embodiment of the present application, the number of times a user uses the service can also be represented by a matrix, which is called a personal quantity matrix in the embodiment of the present application. Fig.11 As shown, a schematic diagram of the individual quantity matrix is provided.
[0166] refer to Fig.11 , the difference between the personal quantity matrix and the personal frequency matrix is that the matrix elements of the personal quantity matrix represent the number of times the user has used it personally. For example, the first row of matrix elements in the personal quantity matrix represents the number of times the user has used each image style under image content 1. That is to say, after the electronic device establishes the quantity matrix, the initial value of the elements in the matrix is 0. The electronic device updates the matrix elements in the quantity matrix according to the image style selected by the user for different candidate image contents. This is equivalent to the electronic device detecting that each time the user selects an image style for a candidate image content, the value of the matrix element corresponding to the candidate image content and image style increases by 1.
[0167] For example, refer to Fig.11 , when the user selects to use image style 1 once for image content 1, the usage count 11 is incremented by 1. If the usage count 11 is currently the initial value 0, the usage count 11 is incremented and updated to 1. If the usage count 11 is currently 2, the usage count 11 is incremented and updated to 3, and so on.
[0168] Then, the electronic device performs normalization calculations on each row of matrix elements in the personal number matrix, thereby obtaining a personal frequency matrix. In order to ensure the accuracy of the personal frequency matrix, once the personal number matrix is updated a number of times, the electronic device needs to recalculate the personal usage frequency of the image style once, and complete the update of the personal frequency matrix at the same time. It should be understood that in the personal number matrix and the personal frequency matrix, the image content is represented by the matrix row, and the image style is represented by the matrix column, which is used in the example of the embodiment of the present application, and the embodiment of the present application is not limited to this. Based on usage requirements, the image style can also be represented by the matrix row, and the matrix column can be represented by the image content, which does not affect the implementation of the embodiment of the present application.
[0169] In some embodiments, when the user wants to refer to the public aesthetics or the user's personal usage data is small, the electronic device can consider the public aesthetics in addition to the user's personal aesthetics when selecting the image style as the second image style in the local style library. Therefore, the electronic device can also pre-store the public usage frequency of each image style corresponding to each candidate image content.
[0170] The public usage frequency represents the public's preference for image styles, and the image styles commonly used by most users for a certain image content can be determined based on the public usage frequency. In the embodiment of the present application, the statistical method of the public usage frequency is similar to the statistical method of the personal usage frequency, which is obtained by normalizing the public usage frequency of the image style corresponding to the candidate image content after counting the number of times the public chooses to use the image style for the candidate image content (i.e., the public usage frequency).
[0171] Specifically, after determining the candidate image content and image style, a quantity matrix can also be established based on the candidate image content and image style as a public quantity matrix. Then, based on the collected public image data, the co-occurrence times of the candidate image content and image style are counted, and the co-occurrence times are filled into the corresponding positions in the public quantity matrix as the public usage times. Then, a normalized calculation is performed based on the public quantity matrix to obtain a public frequency matrix, and the public frequency matrix is stored locally in the electronic device.
[0172] That is to say, the personal quantity matrix and personal frequency matrix are matrices that are maintained and updated in real time by the electronic device based on the user's behavior of using image styles for candidate image content. The public frequency matrix is constructed by counting the co-occurrence counts of candidate image content and image style based on the collected public image data after obtaining the candidate image content and image style, and then normalizing the rows of the public quantity matrix. Since the public frequency matrix is constructed based on the collected existing public image data, the frequencies in the public frequency matrix can represent the public's preference for using image styles for different image content.
[0173] Based on this, obtaining the personal usage frequency of the candidate image style may also include: performing weighted calculation on the public usage frequency and the user's personal usage frequency corresponding to the same candidate image style, and using the obtained weighted frequency as the final personal usage frequency of the candidate image style.
[0174] Specifically, when the electronic device determines the preference level of each candidate image style corresponding to the image content of the first image, in addition to obtaining the personal usage frequency of the corresponding candidate image style from the stored personal frequency matrix, it is also necessary to obtain the public usage frequency of the corresponding candidate image style from the locally stored public frequency matrix. Then, the public usage frequency and the personal usage frequency belonging to the same candidate image style are weighted. The electronic device uses the weighted frequency obtained after the weighted calculation as the final personal usage frequency of the candidate image style, and uses the final personal usage frequency of the candidate image style to measure the user's preference level for the candidate image style.
[0175] That is to say, without considering the public aesthetic preferences, the electronic device can directly select the second image style based on the personal usage frequency of the candidate image style in the personal frequency matrix as an indicator. In the case of considering the public aesthetic preferences, the electronic device needs to obtain the public usage frequency of the candidate image style in the public frequency matrix while obtaining the personal usage frequency of the candidate image style in the personal frequency matrix. Then, the personal usage frequency and the public usage frequency corresponding to the same candidate image style are weighted to obtain the personal usage frequency of the candidate image style that is ultimately used to measure the user's preference. That is, the electronic device selects the second image style based on the weighted personal usage frequency as an indicator.
[0176] Among them, the weight ratio of the public usage frequency and the personal usage frequency in the weighted calculation can first set an initial weight, such as 0.5 each. The subsequent electronic device can always use the set initial weight for weighting, or the electronic device can adjust and update the weight ratio based on the user's use of the image style. For example, when the electronic device repeatedly counts that the user uses a certain image style for a certain candidate image content, then for the candidate image content, the weight ratio of the personal usage frequency of the image style can be increased accordingly.
[0177] For example, suppose that the public usage frequency corresponding to image style 1 in the candidate image styles is A, and the personal usage frequency is B. Taking the initial weight 0.5 as an example, the final user personal usage frequency of image style 1 is 0.5A+0.5B.
[0178] S505: The electronic device displays a second image of a second image style on the user interface.
[0179] Specifically, after the electronic device matches and selects the second image style from the local style library, it can convert the image style of the first image displayed in the user interface, thereby generating and displaying a second image of the second image style.
[0180] When the user interface is a large image display page of a gallery (album), and the first image is an image stored in the gallery (album), the second image is an image obtained by converting the first image from a first image style to a second image style. When the user interface is a preview interface of a camera function in an electronic device, and the first image is an image captured in real time by the camera of the current electronic device, the second image is an image captured in real time by the camera that has been processed using the second image style.
[0181] In some embodiments, in order to quickly and accurately generate a second image in the style of a second image, the generation of the second image may be achieved using a trained neural network model.
[0182] Based on this, S505 may include: inputting the image in the gallery or the image captured in real time by the camera of the electronic device and the second image style into the first image generation model, and obtaining and displaying the second image on the user interface.
[0183] Among them, the electronic device includes a first image generation model, and the first image generation model is a trained second image generation model. The second image generation model can be understood as an open source image generation model that has not been trained by the embodiment of the present application. Although existing open source image generation models, such as diffusion models, generative adversarial models (GANs), etc., already have certain image generation capabilities and can be used directly to generate images. However, the image generation capabilities of the open source image generation model may not necessarily meet the expectations of the image style conversion required by the embodiment of the present application.
[0184] Therefore, in order to enable the image generation model to have sufficient image style conversion capabilities, the embodiment of the present application needs to perform model training on the second image generation model to obtain the first image generation model.
[0185] To facilitate understanding of the solution, the following embodiment of the present application first introduces a training process of training the second image generation model to obtain the first image generation model.
[0186] like Fig.12 As shown, the training process of the image generation model mainly includes three training stages.
[0187] First, the second image generation model is fine-tuned based on the image style. In this training step, the second image generation model is trained in the first stage using a noise image without any image content and a style description text as training data. The purpose of the first stage of training is mainly to enable the second image generation model to recognize text descriptions of various styles. The style description text of the embodiment of the present application can be obtained by collecting and crawling various images (the image is referred to as the first training image in the embodiment of the present application), and then forming a style description text based on the actual image style of the first training image, thereby obtaining a text description of various image styles. Some style description texts can also be artificially constructed as training data.
[0188] Exemplary, reference Fig.12 , the noise image and the style text description "This is a warm-toned image" are input into the image generation model, and the image generation model outputs a warm-toned image. The image generation model after the first stage of training is referred to as the first stage image generation model in this embodiment of the application.
[0189] Then, the image style transfer capability of the first-stage image generation model is pre-trained. In this training step, images with image content, such as the first training images and style description texts collected in the first stage, are used as training data to perform the second-stage training on the first-stage image generation model. The purpose of the second-stage training is mainly to train the image style transfer capability of the image generation model, which requires performing style transfer on the image while ensuring that the image content remains unchanged. In particular, in order to ensure that the training can be supported by a large amount of training data, the first training image can undergo some preprocessing to increase the data volume of the first training image data set. For example, the first training image can be subjected to operations such as noise addition and RGB shift. Exemplary, refer to Fig.12 , the first training image and the style text description "This is a warm-toned image" are input into the image generation model, and the image generation model outputs a warm-toned image. The image generation model after the second stage training is referred to as the second stage image generation model in this embodiment of the application.
[0190] Finally, the image generation capability of the second-stage image generation model is fine-tuned. In this training step, images with strong style colors are collected (the images are referred to as second training images in the embodiment of the present application). The second training image and the text description of the image style that is completely opposite to the image style corresponding to the second training image are used as training data to perform the third stage of training on the second-stage image generation model, thereby obtaining a trained first image generation model.
[0191] The purpose of the third stage of training is to enhance the style transfer capability of the image generation model. Fig.12, the cold-toned image and the style text description "This is a warm-toned picture" are input into the image generation model, and the image generation model outputs a warm-toned image.
[0192] It can be seen that since the first image generation model is the second image generation model after three stages of training, the model structures of the first image generation model and the second image generation model are substantially the same, and the only difference is the model weights. The model structures of the first image generation model and the second image generation model can be any existing generation model that can synthesize images, such as the model results of diffusion models, generative adversarial models (GANs), and other models.
[0193] After the model training is completed, the trained first image generation model is deployed to the electronic device. After that, the electronic device can directly call the first image generation model to generate a second image with a second image style.
[0194] Specifically, the electronic device inputs the original image and the image style into the called first image generation model. The original image is the first image displayed by the user interface in the embodiment of the present application. Depending on the user interface, the first image may be an image in the gallery or an image captured by the camera in real time. The image style input to the first image generation model is the second image style selected by the electronic device from the style library.
[0195] That is, the electronic device calls the first image generation model, inputs the first image displayed on the user interface and the matched selected second image style into the first image generation model, and generates the second image with the second image style by the first image generation model.
[0196] When the first image is an image in the gallery, the second image output by the first image generation model is the first image with the second image style. When the first image is an image captured by the camera in real time in the preview interface, the second image output by the first image generation model is the image captured by the camera in real time with the second image style.
[0197] In some embodiments, since the electronic device is always used by the user, the user's personal usage times of each image style stored in the electronic device may be updated at any time. Then, after the personal quantity matrix is updated, the electronic device should re-normalize and calculate to complete the update of the personal frequency matrix.
[0198] Based on this, when the electronic device receives the second operation of the user on the user interface, the electronic device responds to the second operation and updates the personal usage frequency of the second image style saved by the user. The second operation is used to trigger the electronic device to save the second image of the second image style.
[0199] Exemplary, reference Fig.10 and Fig.11 When the electronic device detects that the second image style corresponding to the second image saved corresponding to the second operation is image style 1 under image content 1, Fig.11 The usage count 11 in the personal quantity matrix shown is incremented by 1, thereby completing the update of the user's personal usage count in the personal quantity matrix based on the user's current saving operation.
[0200] Then, due to Fig.11 The personal quantity matrix shown is updated, and the electronic device needs to re-normalize the calculation based on the updated personal quantity matrix to complete the update of the personal usage frequency, that is, to complete Fig.10 The personal frequency matrix is updated. Since the update this time is the number of times image style 1 is used under image content 1, the updated personal usage frequencies are the personal usage frequencies of all image styles under image content 1, that is, personal usage frequency 11, personal usage frequency 12... personal usage frequency 1n will be updated. In the embodiment of the present application, the user's personal usage frequency is updated in time according to the user's usage behavior, so that the image style can be matched based on the latest personal usage frequency next time to improve the accuracy of matching.
[0201] In some embodiments, in order to provide users with more style choices, at least two second image styles can be matched according to the user's personal preference for the candidate image style. Then, the corresponding second image includes at least two images. For ease of description, in the case of at least two second images, the embodiment of the present application refers to them as second sub-images, and different second sub-images correspond to different second image styles.
[0202] Exemplarily, when the electronic device matches two second image styles, image style 1 and image style 2, from the candidate image styles according to the preference level (personal usage frequency), the generated second image includes a second sub-image A and a second sub-image B. The second sub-image A corresponds to image style 1, that is, the second sub-image A is an image with image style 1. The second sub-image B corresponds to image style 2, and the second sub-image B is an image with image style 2.
[0203] Based on this, the electronic device displaying the second image with the second image style in the user interface may include: displaying a second sub-image in the user interface, receiving a third operation of the user in the user interface; and switching to display another second sub-image in response to the third operation. The third operation is an operation for triggering the switching of the display of the second sub-image.
[0204] Specifically, after the electronic device generates corresponding second sub-images based on at least two matched second image styles, the electronic device can first display any one of the second sub-images on the display screen, or it can display the second sub-images corresponding to the second image styles with high personal usage frequency in descending order.
[0205] Then, the electronic device waits to receive a third operation of the user on the user interface, and in response to the third operation, switches to display another second sub-image.
[0206] Exemplary, reference Fig.13 The third operation may be a sliding operation, and the electronic device switches to display different second sub-images in response to the user's sliding operation to the left or right. That is, the electronic device may receive the user's sliding operation within the viewfinder 20. When the user's sliding operation is sliding to the left, the electronic device displays the next second sub-image. When the user's sliding operation is sliding to the right, the electronic device displays the previous second sub-image.
[0207] In some embodiments, reference Fig.14 In order to meet the user's requirement of closing the personalized processing, after S505, the image processing method further includes:
[0208] S506: The electronic device receives a fourth operation of the user on the user interface.
[0209] S507: The electronic device responds to the fourth operation by displaying the first image of the first image style on the user interface.
[0210] Specifically, the fourth operation is a click operation for triggering the electronic device to turn off the personalized style processing, that is, for triggering the electronic device to restore the image style of the image in the user interface. The first operation is a click operation for triggering the electronic device to perform personalized style processing on the first image. It can be seen that the event triggered by the fourth operation is the opposite of the event triggered by the first operation. The electronic device responds to the user's fourth operation, turns off the personalized style processing, and the electronic device resumes displaying the original image (that is, the first image with the first image style is displayed again in the user interface).
[0211] For example, the fourth operation may also be a user clicking an "image style processing" button / control on the electronic device. Fig.15 The “image style processing” button / control can also be an “AI” button / control, and the “AI” button / control is currently turned on. Therefore, when the electronic device receives a user’s click operation (the fourth operation) to close the “AI” button / control while the “AI” button / control is turned on, the electronic device turns off the “AI” button / control. Fig.15The character image in the preview interface viewfinder 20 is processed with a personalized style, and the original first image with the first image style is displayed again (refer to Figure 2 ).
[0212] In some embodiments, Fig.16 As shown in FIG. 1 , a flow chart of an image processing method is provided. Fig.16 The image processing method of the embodiment of the present application is described by taking FIG.
[0213] Specifically, after the electronic device displays the first image of the first image style in the user interface, it waits to receive the first operation of the user. When the electronic device receives the first operation of the user in the user interface, it extracts the image content of the first image in response to the first operation. The extraction of the image content can be implemented by calling the first multimodal large language model. After the first image is input into the first multimodal large language model, the content encoding output by the image encoder and the image-text alignment layer in the first multimodal large language model is obtained as the image content of the first image. Reference Fig.16 , the extracted image content is “outdoors + people”.
[0214] Then, the electronic device uses the image content to match and select a second image style in the local style library. The electronic device first matches the candidate image content with the highest similarity to the image content, and uses the image style corresponding to the candidate image content as the candidate image style of the image content. A certain number of second image styles are matched based on the personal usage frequency of the candidate image style. Fig.16 , the second image styles matched for the image content “outdoors+person” include “vivid” and “clear”.
[0215] Finally, the electronic device inputs the first image and the second image style selected to the trained first image generation model, and the first image generation model generates and outputs a second image with the second image style, and displays it on the user interface. Fig.16 The embodiment of the present application illustrates a second image when the image captured by the camera before and after the image style conversion remains unchanged, that is, the image content of the second image is the same as that of the first image. Fig.16 Characters shown.
[0216] In addition, after the electronic device displays the second image of the second image style in the user interface, the electronic device may also respond to the user's left-right sliding operation in the viewfinder, that is, the electronic device switches to display the next second image in response to the third operation. For example, the electronic device first displays the second image with an image style of "bright". After the electronic device receives the user's third operation, it responds to the third operation to display the second image with an image style of "clear".
[0217] Meanwhile, when the user is not satisfied with all the recommended second image styles, the electronic device may also respond to a fourth operation of the user, close the personalized style processing, and redisplay the first image of the first image style.
[0218] Another embodiment of the present application provides an electronic device, which includes: a memory, a display screen and one or more processors, wherein the memory, the display screen and the processor are coupled; the display screen is used to display a user interface, and the memory stores one or more computer program codes, and the computer program codes include computer instructions; when the processor executes the computer instructions, the electronic device implements the image processing method described in any of the above embodiments.
[0219] Another embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor in an electronic device, the electronic device implements the image processing method described in any of the above embodiments.
[0220] The embodiment of the present application also provides a computer program product. When the computer program product is run on a computer, the computer is enabled to execute each function or step in the above method embodiment.
[0221] Through the description of the above implementation methods, technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0222] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0223] The units described as separate components may or may not be physically separated, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0224] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0225] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium, including several instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to perform all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program codes.
[0226] The above contents are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application shall be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.
Claims
1. An image processing method, It is characterized in that Applied to an electronic device, wherein a plurality of candidate image contents are stored in the electronic device, and each of the candidate image contents corresponds to at least one image style; the electronic device comprises a first multimodal large language model, and the first multimodal large language model comprises a large language model; the method comprises: Displaying a first image of a first image style in a user interface; Receive a first operation of the user in the user interface, where the first operation is used to trigger the electronic device to change the image style of an image in the user interface; In response to the first operation, extracting image content of the first image, and taking at least one image style corresponding to the candidate image content having the highest similarity to the image content of the first image as a candidate image style; Acquiring the user's preference for the candidate image styles, and selecting a second image style from the candidate image styles according to the preference; displaying a second image of the second image style on the user interface; The user interface is a large image display page of a gallery in the electronic device, the first image is an image in the gallery, and the second image is an image obtained by converting the first image from the first image style to the second image style; or, the user interface is a preview interface of an image captured by the electronic device, the first image is obtained by processing an image captured in real time by a camera of the electronic device using the first image style, and the second image is obtained by processing an image captured in real time by a camera of the electronic device using the second image style; The method further comprises: After using the large language model in the first multimodal large language model to extract text features from the candidate style description text, a linear projection layer is used to align the text features to obtain a style code, the style codes are clustered and each category after clustering is style-labeled to obtain an image style corresponding to the candidate image content.
2. The method according to claim 1, It is characterized in that The user's preference for the candidate image style is: the personal usage frequency of the candidate image style; wherein the electronic device further stores the personal usage frequency of each image style corresponding to each candidate image content; After the user interface displays the second image of the second image style, the method further includes: receiving a second operation of the user on the user interface, where the second operation is used to trigger the electronic device to save a second image of the second image style; In response to the second operation, the saved personal usage frequency of the second image style is updated.
3. The method according to claim 1, It is characterized in that The first multimodal large language model is a trained second multimodal large language model; The extracting the image content of the first image comprises: The first image is input into the first multimodal large language model, and content outputted by the image encoder and the image-text alignment layer in the first multimodal large language model is encoded as image content of the first image.
4. The method according to claim 1, It is characterized in that The first multimodal large language model is a trained second multimodal large language model; the first multimodal large language model also includes an image encoder and an image-text alignment layer; The method further comprises: The image encoder and the image-text alignment layer in the first multimodal large language model are used to extract content codes of candidate images, the content codes are clustered and content annotation is performed on each category after clustering to obtain candidate image content.
5. The method according to claim 3 or 4, It is characterized in that The method further comprises: After performing classification training on the style decision factors on the second multimodal large language model, the image content extraction capability of the second multimodal large language model is further trained to obtain the first multimodal large language model; The style decision factors include at least one or more of environment, light, and subject matter; the second multimodal large language model includes an image encoder, a picture-text alignment layer, and a large language model; the output of the image encoder is the input of the picture-text alignment layer, and the output of the picture-text alignment layer is the input of the large language model.
6. The method according to claim 2, It is characterized in that Obtaining the user's personal usage frequency of the candidate image style, including: Counting the number of times each candidate image style corresponding to the candidate image content is used by a user; The number of times the user personally uses the candidate image style is normalized and calculated to obtain the personal usage frequency of the candidate image style.
7. The method according to claim 2 or 6, It is characterized in that The electronic device also stores the public usage frequency of each image style corresponding to each candidate image content; the public usage frequency is obtained by counting the number of times each candidate image style corresponding to the candidate image content is used by the public and then normalized; The obtaining of the user's personal usage frequency of the candidate image style includes: The public usage frequency and the personal usage frequency corresponding to the same candidate image style are weightedly calculated, and the obtained weighted frequency is used as the final personal usage frequency of the candidate image style.
8. The method according to any one of claims 1 to 4, It is characterized in that The electronic device includes a first image generation model, and the first image generation model is a trained second image generation model; Displaying the second image of the second image style in the user interface includes: The image in the gallery or the image captured in real time by the camera of the electronic device and the second image style are input into the first image generation model to obtain and display the second image on the user interface.
9. The method according to claim 8, It is characterized in that The method further comprises: Performing a first-stage training on the second image generation model using the noise image and the style description text to obtain a first-stage image generation model; Performing second-stage training on the first-stage image generation model using the first training image and the style description text to obtain a second-stage image generation model; The second-stage image generation model is trained in the third stage using the second training image and the style description text to obtain a first image generation model; wherein the image style of the second training image is opposite to the image style described by the style description text.
10. The method according to any one of claims 1 to 4, It is characterized in that selecting at least two second image styles from the candidate image styles according to the preference level, the second image including at least two second sub-images, the second sub-images corresponding to different second image styles; Displaying the second image of the second image style in the user interface includes: Displaying the second sub-image on the user interface; receiving a third operation of the user on the user interface, wherein the third operation is used to trigger the electronic device to switch display of the second sub-image; In response to the third operation, another second sub-image is switched to be displayed.
11. The method according to any one of claims 1 to 4, It is characterized in that After the user interface displays the second image of the second image style, the method further includes: receiving a fourth operation performed by the user on the user interface, wherein the fourth operation is used to trigger the electronic device to restore the image style of the image in the user interface; In response to the fourth operation, a first image of the first image style is displayed on the user interface.
12. An electronic device, It is characterized in that include: A memory, a display screen and one or more processors, wherein the memory, the display screen and the processor are coupled; The display screen is used to display a user interface, and the memory stores one or more computer program codes, wherein the computer program codes include computer instructions; when the processor executes the computer instructions, the electronic device executes the image processing method as described in any one of claims 1 to 11.
13. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor of an electronic device, the electronic device executes the image processing method according to any one of claims 1 to 11.
Citation Information
Patent Citations
Picture style conversion method, device and equipment and computer readable storage medium
CN110599393A
Image processing apparatus and method for style transformation
US20220067421A1
