Search

CN-122023896-A - Style migration method, device, storage medium and computer program product

CN122023896ACN 122023896 ACN122023896 ACN 122023896ACN-122023896-A

Abstract

The embodiment of the application provides a style migration method, equipment, a storage medium and a computer program product, wherein the method comprises the steps of obtaining a first image and a second image, wherein the styles of the first image and the second image are different, inputting the first image and the second image into a first model to obtain a third image, wherein the third image is similar to the first image in content and similar to the second image in style, the first model is obtained by training a first initial model based on a first loss function, the first initial model comprises an initial generator, the first loss function comprises a second loss function, the second loss function is used for measuring the difference between the texture information of an output image of the initial generator and the texture information of an input image, and the style of an output result can be controlled by controlling the style of the second image, so that a one-to-many style mapping relation is achieved, the cost is reduced, and the personalized requirements of different customers are met.

Inventors

  • YU ZHONGYANG

Assignees

  • 中移(苏州)软件技术有限公司
  • 中国移动通信集团有限公司

Dates

Publication Date
20260512
Application Date
20260127

Claims (10)

  1. 1. A style migration method, the method comprising: acquiring a first image and a second image, wherein the styles of the first image and the second image are different; Inputting the first image and the second image into a first model to obtain a third image, wherein the third image is similar to the content of the first image and similar to the style of the second image; The first model is obtained by training a first initial model based on a first loss function, wherein the first initial model comprises an initial generator, the first loss function comprises a second loss function, and the second loss function is used for measuring the difference between texture information of an output image of the initial generator and texture information of an input image.
  2. 2. The method of claim 1, wherein the first model comprises a generator comprising a first encoder, a second encoder, and a decoder; The inputting the first image and the second image into a first model to obtain a third image comprises the following steps: The first image is input to the first encoder to extract content characteristics to obtain first image characteristics, and the second image is input to the second encoder to extract style characteristics to obtain second image characteristics; and carrying out fusion processing on the first image feature and the second image feature through the decoder to obtain the third image.
  3. 3. The method of claim 2, wherein the first encoder comprises N two-dimensional convolutional layers, M residual blocks, and wherein N, M is a positive integer; the step of inputting the first image to the first encoder for content feature extraction to obtain a first image feature includes: And sequentially inputting the first image to the N two-dimensional convolution layers and M residual blocks, and outputting the first image characteristics.
  4. 4. The method of claim 2, wherein the second encoder comprises L two-dimensional convolutional layers, S average pooling layers, and L, S is a positive integer; Inputting the second image to the second encoder for style feature extraction to obtain a second image feature, including: and sequentially inputting the second image to the L two-dimensional convolution layers and the S average pooling layers, and outputting the second image features.
  5. 5. A method according to claim 2 or 3, wherein the decoder comprises P normalized residual blocks, Q upsampled convolutional layers, O fully connected layers, the P, Q, O being a positive integer; The fusing processing is performed on the first image feature and the second image feature by the decoder to obtain the third image, including: inputting the second image features to the O full-connection layers to obtain affine transformation features; And inputting the affine transformation feature and the first image feature into the P normalized residual blocks and the Q up-sampling convolution layers to obtain the third image.
  6. 6. The method of claim 1, wherein the first model further comprises a discriminator comprising E two-dimensional convolutional layers, full join layers, the E being a positive integer; after said inputting the first image and the second image into the first model, obtaining a third image, the method further comprises: and extracting features of the third image through the E two-dimensional convolution layers, and inputting a result obtained after the features are extracted into the full-connection layer to obtain a first feature vector so as to identify whether the third image is a real image or not based on the first feature vector.
  7. 7. The method of claim 1, wherein the first model is trained on the first initial model based on the first loss function, a first training data set, wherein the first initial model further comprises an initial discriminator; The first training data set comprises a first image database and a second image database, the first image database comprises one or more fourth images, the second image block comprises one or more fifth images, and the fourth images are different from the fifth images in style; the first loss function further comprises a third loss function and a fourth loss function, wherein the third loss function is at least used for measuring the difference between the real image and the output image of the initial generator by the initial discriminator, and the fourth loss function is used for measuring the similarity between the content of the output image of the initial generator and the content of the fourth image.
  8. 8. A style migration apparatus, characterized in that the style migration apparatus comprises a processor and a memory, wherein, The memory is used for storing a computer program capable of running on the processor; The processor being adapted to perform the method of any of claims 1-7 when the computer program is run.
  9. 9. A computer readable storage medium, characterized in that the storage medium has stored thereon a computer program code which, when executed by a computer, performs the method of any of claims 1-7.
  10. 10. A computer program product comprising a computer program, characterized in that the computer program, when executed by a processor, implements the method according to any of claims 1-7.

Description

Style migration method, device, storage medium and computer program product Technical Field The present application relates to the field of image processing technologies, and in particular, to a style migration method, apparatus, storage medium, and computer program product. Background Style migration is an image processing technique aimed at migrating the visual style of one image onto another image, thereby realizing personalized expression in appearance on the premise of keeping the content unchanged. The technology is widely applied to the fields of digital media, man-machine interaction interface design and the like, has important value in UI Web (webpage user interface) design, and can help to promote emotion resonance and overall experience of users. In the related art, a deep learning-based style migration method generally employs a structure of generating an countermeasure Network or a convolutional neural Network to achieve a style migration effect, for example, a cyclic countermeasure generation Network (CYCLE GENERATIVE ADVERSARIAL Network, cycle-GAN) can learn a one-to-one mapping relationship between two styles, so as to convert an input image into an image of a specific certain style. However, the Cycle-GAN can only learn a one-to-one mapping relationship between two styles, that is, can only convert an input image into an image of a specific style, cannot control the conversion of the input image into an image of a specific style, cannot meet the personalized needs of clients, and the Cycle-GAN requires a large amount of training data and time to learn the mapping relationship between two different styles, so that training cost can be greatly increased due to the fact that training a high-quality model can take days or weeks, and meanwhile, the popularization and use of the model in a scene with high real-time requirements such as UI design are affected due to the fact that distortion still exists in image conversion of a complex scene. Disclosure of Invention The embodiment of the application provides a style migration method, a device, a storage medium and a computer program product, which can achieve one-to-many style mapping relation, meet the personalized requirements of different clients and greatly reduce training cost. The technical scheme of the embodiment of the application is realized as follows: In a first aspect, an embodiment of the present application provides a style migration method, where the method includes: acquiring a first image and a second image, wherein the styles of the first image and the second image are different; Inputting the first image and the second image into a first model to obtain a third image, wherein the third image is similar to the content of the first image and similar to the style of the second image; The first model is obtained by training a first initial model based on a first loss function, wherein the first initial model comprises an initial generator, the first loss function comprises a second loss function, and the second loss function is used for measuring the difference between texture information of an output image of the initial generator and texture information of an input image. In a second aspect, an embodiment of the present application provides a style migration apparatus, where the style migration apparatus includes a processor and a memory, where, The memory is used for storing a computer program capable of running on the processor; The processor is configured to execute the style migration method as described above when the computer program is run. In a third aspect, embodiments of the present application provide a computer-readable storage medium having stored thereon computer program code which, when executed by a computer, implements a style migration method as described above. In a fourth aspect, embodiments of the present application provide a computer program product comprising a computer program which, when executed by a processor, implements a style migration method as described above. The embodiment of the application provides a style migration method, equipment, a storage medium and a computer program product, wherein the method comprises the steps of obtaining a first image and a second image, wherein the styles of the first image and the second image are different, inputting the first image and the second image into a first model to obtain a third image, the third image is similar to the first image in content and similar to the second image in style, the first model is obtained by training a first initial model based on a first loss function, the first initial model comprises an initial generator, the first loss function comprises a second loss function, and the second loss function is used for measuring the difference between texture information of an output image of the initial generator and texture information of an input image. Therefore, by acquiring the first image and the second image with different styles and