Image synthesis method, device, electronic device and computer readable storage medium
By generating semantic vectors related to semantics and appearance and adjusting the parameters of the residual calculation unit, the problem of inconsistent processing of similar local areas during semantic segmentation image conversion is solved, and the display effect of image synthesis is improved.
Patent Information
- Application Number
- CN202110133445.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-01-29
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2041-01-29
AI Technical Summary
When the existing technology converts semantic segmentation images into natural images, similar local areas are processed inconsistently, resulting in poor display of synthetic images.
By obtaining the semantic segmentation map and the sampling noise map, semantic and appearance-related semantic vectors are generated based on the similarity information of the class labels, and the sampling noise map is processed through the semantic rendering sub-network, and the residual calculation unit parameters are adjusted to improve the processing consistency of similar areas. sex.
The display effect of synthesized images is improved, so that similar areas present more similar effects in the final image, improving the quality of image synthesis.
Smart Images

Figure CN112818997B_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of image processing, and specifically relates to an image synthesis method, device, electronic device and computer-readable storage medium. Background Art
[0002] The semantic segmentation image is input into the adversarial network to convert the semantic segmentation map into a more realistic natural image. Since the labels corresponding to each part in the semantic segmentation image are different, the processing methods of each part are also different when synthesizing natural images, resulting in large differences between similar parts in the final synthesized natural image, such as asymmetry between the left and right eyes, inconsistent colors of the left and right eyebrows, etc., which affects the display effect of the natural image.
[0003] Through appearance similarity, connections are established between local areas, so that when each local area is subsequently transformed, a similar processing method is adopted (the semantic vector values of similar positions are similar, and the resulting residual calculation units are also similar), which is beneficial to improving the display effect of the composite image. Summary of the invention
[0004] In view of this, the purpose of the present application is to provide an image synthesis method, device, electronic device and computer-readable storage medium, which are conducive to improving the display effect of the synthesized image.
[0005] The embodiment of the present application is implemented as follows:
[0006] In a first aspect, an embodiment of the present application provides an image synthesis method, the method comprising:
[0007] A semantic segmentation map including multiple local areas and a sampling noise map of the same scale as the semantic segmentation map is obtained, wherein each local area has a class label for characterizing the category to which it belongs; according to the similarity information between the objects represented by each class label obtained in advance, the semantic segmentation map is converted into a semantic vector related to semantics and appearance; and a synthetic image is obtained by processing the semantic vector and the sampling noise map.
[0008] In the above-mentioned image synthesis process, since the semantic segmentation map is converted into a semantic vector related to semantics and appearance according to the similarity information between the objects represented by each class label, the corresponding scalars used to represent similar areas (such as the left eye area and the right eye area) in the semantic segmentation map in the subsequently generated semantic vector are also similar. Therefore, the subsequent processing parameters used to process similar areas are similar, so that the areas that should be similar present similar effects in the final synthesized image, which is beneficial to improving the display effect.
[0009] In combination with the first aspect, in some embodiments, the method is applied to an image synthesis network, which includes a semantic vector generation subnetwork and a semantic rendering subnetwork; the semantic segmentation map is converted into a semantic vector related to semantics and appearance based on the similarity information between objects represented by each class label acquired in advance, including: processing the semantic segmentation map through the semantic vector generation subnetwork and the similarity information between objects represented by each class label to obtain a semantic vector corresponding to the semantic segmentation map.
[0010] In combination with the first aspect, in some embodiments, the semantic vector generation subnetwork includes a feature extraction unit and a conversion unit; the semantic segmentation map is processed by the semantic vector generation subnetwork and the similarity information between the objects represented by each class label to obtain a semantic vector corresponding to the semantic segmentation map, including:
[0011] Each of the feature extraction units obtains first input information, wherein the first input information of the first feature extraction unit is the semantic segmentation map, and the first input information of the second to last feature extraction units includes the output result of the previous feature extraction unit and the corresponding semantic segmentation map, the corresponding semantic segmentation map is homologous to the semantic segmentation map obtained by the previous feature extraction unit, and the scale of the corresponding semantic segmentation map is a preset multiple of the semantic segmentation map obtained by the previous feature extraction unit; each of the feature extraction units performs feature extraction on the first input information according to the similarity information between the objects represented by the various class labels obtained in advance, and outputs a feature map with a scale that is the preset multiple of the scale of the first input information; the conversion unit adjusts each of the feature maps to obtain multiple semantic vectors.
[0012] In combination with the first aspect, in some embodiments, the feature extraction is performed on the first input information based on the similarity information between objects represented by each class label obtained in advance, and a feature map with a scale that is a preset multiple of the scale of the first input information is output, including: performing a convolution operation, an activation function operation, a convolution operation, and an upsampling operation of the preset multiple on the first input information in sequence to obtain feature values of each position of the image corresponding to the first input information; adjusting the feature values of each position according to the corresponding class label to which the each position belongs and the similarity information between the objects represented by the each class label so that the feature values corresponding to the regions with higher similarity are more similar, thereby obtaining the feature map.
[0013] In combination with the first aspect, in some embodiments, each of the feature maps is adjusted to obtain multiple semantic vectors, including: for each of the feature maps, the number of channels of the feature map is adjusted to a preset channel value, and the feature map after the channel number is adjusted is normalized to obtain a semantic vector corresponding to the feature map.
[0014] In combination with the first aspect, in some implementations, the feature map after adjusting the number of channels is V∈R h×w×n , where R is a real number, h, w, and n are the width, height, and number of channels of the feature map after adjusting the number of channels, respectively. The feature map after adjusting the number of channels is normalized to obtain a semantic vector corresponding to the feature map, including: based on the formula Each value of V is processed to normalize each value of V to between 0 and 1, and V∈[0,1] is obtained. h×w×n , so that the corresponding semantic vector V i,j ∈[0,1] n ; Wherein, i, j, and x represent the row number, column number, and channel number of the feature map V after adjusting the number of channels, respectively, V i,j,x The feature value representing the feature at the i-th row, j-th column, and x-th channel in the feature map V after adjusting the number of channels, τ is a preset parameter, y is a parameter with a value range of 1 to n and is an integer, and the semantic vector V ij Represents the n-dimensional feature vector corresponding to the i-th row and j-th column in the semantic segmentation map currently being processed.
[0015] In combination with the first aspect, in some implementations, the number of the feature extraction units is one or more.
[0016] In combination with the first aspect, in some embodiments, the method is applied to an image synthesis network, which includes a semantic rendering sub-network; the synthesized image is obtained by processing the semantic vector and the sampling noise map, including: inputting the semantic vector and the sampling noise map into the semantic rendering sub-network; adjusting the parameters of the residual calculation unit in the semantic rendering sub-network for processing the sampling noise map according to different values of the semantic vector, and processing the sampling noise map through the residual calculation unit after adjusting the parameters, and outputting the synthesized image.
[0017] In combination with the first aspect, in some embodiments, the image synthesis network includes a semantic vector generation subnetwork, the semantic vector generation subnetwork includes a feature extraction unit, the semantic rendering subnetwork includes a residual calculation unit, and the feature extraction unit corresponds to the residual calculation unit one-to-one; the inputting the semantic vector and the sampling noise map into the semantic rendering subnetwork includes: each of the residual calculation units obtains second input information, wherein the second input information of each of the residual calculation units includes the semantic vector from the feature extraction unit corresponding thereto, and includes the second output information output by the previous residual calculation unit, and the second input information of the first residual calculation unit also includes a sampling noise map of the same scale as the semantic segmentation map.
[0018] In conjunction with the first aspect, in some implementations, the semantic vector is V i,j ∈[0,1] n , represents the n-dimensional feature vector corresponding to the i-th row and j-th column in the semantic segmentation map currently being processed, the residual calculation unit includes a spatial variation convolution subunit and an affine transformation subunit, and the parameters of the residual calculation unit for processing the sampled noise map in the semantic rendering subnetwork are adjusted according to different values of the semantic vector, including: for each value combination of i and j, obtaining V under the value combination ij n numerical values determined when n takes different values; performing linear weighted summation on the n numerical values and the n pre-saved convolution weights to obtain the parameters of the spatial variation convolution subunit included in the residual calculation unit under the current combination of i and j values; performing linear weighted summation on the n numerical values and the n pre-saved affine transformation weights to obtain the parameters of the affine transformation subunit included in the residual calculation unit under the current combination of i and j values.
[0019] In combination with the first aspect, in some embodiments, the residual calculation unit includes multiple groups of residual calculation subunits, each group of the residual calculation subunits includes at least one pair of the spatially varying convolution subunits and the affine transformation subunits, and the residual calculation unit after adjusting the parameters processes the sampled noise map, including: after upsampling the processing object by the preset multiple, inputting it into each group of the residual calculation subunits included in the residual calculation unit for affine transformation processing and convolution processing to obtain an output result; performing a matrix addition operation on each of the output results to obtain the second output information output by itself; wherein, under the current combination of i and j values, the residual calculation unit processes the area corresponding to the i-th row and j-th column in the processing object; the processing object of the first residual calculation unit is the sampled noise map, and the processing objects of the remaining residual calculation units are the second output information output by the previous residual calculation subunit.
[0020] In the second aspect, the embodiment of the present application also provides an image synthesis device, including: an acquisition module, a conversion module and a synthesis module. The acquisition module is used to obtain a semantic segmentation map including multiple local areas and a sampling noise map of the same scale as the semantic segmentation map, and each local area has a class label for characterizing the category to which it belongs; the conversion module is used to convert the semantic segmentation map into a semantic vector related to semantics and appearance according to the similarity information between the objects represented by each class label acquired in advance; the synthesis module is used to obtain a synthesized image by processing the semantic vector and the sampling noise map.
[0021] In combination with the second aspect, in some embodiments, the device is applied to an image synthesis network, which includes a semantic vector generation subnetwork and a semantic rendering subnetwork; the conversion module is used to process the semantic segmentation map through the semantic vector generation subnetwork and the similarity information between the objects represented by the various class labels to obtain a semantic vector corresponding to the semantic segmentation map.
[0022] In combination with the second aspect, in some embodiments, the semantic vector generation subnetwork includes a feature extraction unit and a conversion unit; the conversion module is used to obtain first input information through each of the feature extraction units, wherein the first input information of the first feature extraction unit is the semantic segmentation map, and the first input information of the second feature extraction unit to the last feature extraction unit includes the output result of the previous feature extraction unit and the corresponding semantic segmentation map, the corresponding semantic segmentation map is homologous to the semantic segmentation map obtained by the previous feature extraction unit, and the scale is a preset multiple of the semantic segmentation map obtained by the previous feature extraction unit; each feature extraction unit performs feature extraction on the first input information according to the similarity information between objects represented by each class label obtained in advance, and outputs a feature map with a scale that is the preset multiple of the scale of the first input information; each feature map is adjusted by the conversion unit to obtain multiple semantic vectors.
[0023] In combination with the first aspect, in some embodiments, the conversion module is used to perform convolution operation, activation function operation, convolution operation and upsampling operation of the preset multiple on the first input information in sequence to obtain feature values of each position of the image corresponding to the first input information; according to the corresponding class labels to which the respective positions belong and the similarity information between the objects represented by the respective class labels, the feature values of the respective positions are adjusted so that the feature values corresponding to the regions with higher similarity are more similar, thereby obtaining the feature map.
[0024] In combination with the second aspect, in some embodiments, the conversion module is used to adjust the number of channels of each feature map to a preset channel value, and then normalize the feature map after the channel number is adjusted to obtain a semantic vector corresponding to the feature map.
[0025] In combination with the second aspect, in some implementations, the feature map after adjusting the number of channels is V∈R h×w×n , where R is a real number, h, w, and n are the width, height, and number of channels of the feature map after adjusting the number of channels, respectively. The conversion module is used based on the formula Each value of V is processed to normalize each value of V to between 0 and 1, and V∈[0,1] is obtained. h×w×n , so that the corresponding semantic vector V i,j ∈[0,1] n ; Wherein, i, j, and x represent the row number, column number, and channel number of the feature map V after adjusting the number of channels, respectively, V i,j,x The feature value representing the feature at the i-th row, j-th column, and x-th channel in the feature map V after adjusting the number of channels, τ is a preset parameter, y is a parameter with a value range of 1 to n and is an integer, and the semantic vector V ij Represents the n-dimensional feature vector corresponding to the i-th row and j-th column in the semantic segmentation map currently being processed.
[0026] In combination with the second aspect, in some implementations, the number of the feature extraction units is one or more.
[0027] In combination with the second aspect, in some embodiments, the device is applied to an image synthesis network, which includes a semantic rendering sub-network; the synthesis module is used to input the semantic vector and the sampling noise map into the semantic rendering sub-network; according to different values of the semantic vector, the parameters of the residual calculation unit in the semantic rendering sub-network for processing the sampling noise map are adjusted, and the sampling noise map is processed by the residual calculation unit after the adjustment of the parameters to output the synthesized image.
[0028] In combination with the second aspect, in some embodiments, the image synthesis network includes a semantic vector generation subnetwork, the semantic vector generation subnetwork includes a feature extraction unit, the semantic rendering subnetwork includes a residual calculation unit, and the feature extraction unit corresponds one-to-one to the residual calculation unit; the synthesis module is used to obtain second input information through each of the residual calculation units, wherein the second input information of each of the residual calculation units includes a semantic vector from the feature extraction unit corresponding to it, and second output information output by the previous residual calculation unit, and the second input information of the first residual calculation unit also includes a sampling noise map of the same scale as the semantic segmentation map.
[0029] In conjunction with the second aspect, in some implementations, the semantic vector is V i,j ∈[0,1] n , represents the n-dimensional feature vector corresponding to the i-th row and j-th column of the semantic segmentation map currently being processed, the residual calculation unit includes a spatial variation convolution subunit and an affine transformation subunit, and the synthesis module is used to obtain, for each value combination of i and j, V under the value combination ij n numerical values determined when n takes different values; performing linear weighted summation on the n numerical values and the n pre-saved convolution weights to obtain the parameters of the spatial variation convolution subunit included in the residual calculation unit under the current combination of i and j values; performing linear weighted summation on the n numerical values and the n pre-saved affine transformation weights to obtain the parameters of the affine transformation subunit included in the residual calculation unit under the current combination of i and j values.
[0030] In combination with the second aspect, in some embodiments, the residual calculation unit includes multiple groups of residual calculation subunits, each group of the residual calculation subunits includes at least one pair of the spatially varying convolution subunit and the affine transformation subunit, and the synthesis module is used to upsample the processing object by the preset multiple, and then input it into each group of the residual calculation subunits included in the residual calculation unit for affine transformation processing and convolution processing to obtain an output result; each of the output results is subjected to a matrix addition operation to obtain the second output information output by itself; wherein, under the current combination of i and j values, the residual calculation unit processes the area corresponding to the i-th row and j-th column in the processing object; the processing object of the first residual calculation unit is the sampling noise map, and the processing objects of the remaining residual calculation units are the second output information output by the previous residual calculation subunit.
[0031] In a third aspect, an embodiment of the present application further provides an electronic device, comprising: a memory and a processor, wherein the memory and the processor are connected; the memory is used to store programs; the processor calls the program stored in the memory to execute the method provided in the above-mentioned first aspect embodiment and / or any possible implementation method in combination with the first aspect embodiment.
[0032] In a fourth aspect, an embodiment of the present application further provides a non-volatile computer-readable storage medium (hereinafter referred to as computer-readable storage medium), on which a computer program is stored. When the computer program is run by a computer, it executes the method provided by the above-mentioned first aspect embodiment and / or any possible implementation method in combination with the first aspect embodiment.
[0033] Other features and advantages of the present application will be described in the following description, and partly become apparent from the description, or understood by implementing the embodiments of the present application. The purpose and other advantages of the present application can be realized and obtained by the structures specifically pointed out in the written description and the drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can also be obtained based on these drawings without creative work. As shown in the drawings, the above and other purposes, features and advantages of the present application will be clearer. The same reference numerals indicate the same parts in all the drawings. The drawings are not deliberately scaled to the actual size, and the focus is on showing the main purpose of the present application.
[0035] Figure 1 One of the flowcharts of the image synthesis method provided in the embodiment of the present application is shown.
[0036] Figure 2 A schematic diagram of the structure of an image synthesis network provided in an embodiment of the present application is shown.
[0037] Figure 3 The second flowchart of the image synthesis method provided in the embodiment of the present application is shown.
[0038] Figure 4 One of the structural schematic diagrams of the residual calculation unit provided in the embodiment of the present application is shown.
[0039] Figure 5 A second structural schematic diagram of the residual calculation unit provided in an embodiment of the present application is shown.
[0040] Figure 6A structural block diagram of an image synthesis device provided in an embodiment of the present application is shown.
[0041] Figure 7 A schematic structural diagram of an electronic device provided in an embodiment of the present application is shown.
[0042] Icon: 100-electronic device; 110-processor; 120-memory; 200-image synthesis network; 210-semantic vector generation subnetwork; 211-feature extraction unit; 212-conversion unit; 220-semantic rendering subnetwork; 221-residual calculation unit; 222-residual calculation subunit; 2211-space-varying convolution subunit; 2212-affine transformation subunit; 2213-function layer; 400-image synthesis device; 410-acquisition module; 420-conversion module; 430-synthesis module. DETAILED DESCRIPTION
[0043] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.
[0044] It should be noted that similar numbers and letters represent similar items in the following figures, so once an item is defined in one figure, it does not need to be further defined and explained in the subsequent figures. At the same time, in the description of this application, relational terms such as "first", "second", etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that there is any such actual relationship or order between these entities or operations. Moreover, the term "comprise" or any other variant thereof is intended to cover non-exclusive inclusion, so that the process, method, article or equipment including a series of elements includes not only those elements, but also includes other elements that are not clearly listed, or also includes elements inherent to such process, method, article or equipment. In the absence of more restrictions, the elements defined by the statement "comprise one..." do not exclude the existence of other identical elements in the process, method, article or equipment including the elements.
[0045] In addition, the defects existing in the semantic segmentation image synthesis method in the prior art (the display effect of the synthesized natural image is not good) are the results obtained by the applicant after practice and careful research. Therefore, the discovery process of the above defects and the solutions proposed in the embodiments of this application for the above defects below should be recognized as the applicant's contribution to this application.
[0046] In order to solve the above problems, the embodiments of the present application provide an image synthesis method, device, electronic device and computer-readable storage medium, which are conducive to improving the display effect of the synthesized image.
[0047] The technology can be implemented by using corresponding software, hardware or a combination of software and hardware. The following is a detailed introduction to the embodiments of the present application.
[0048] The following is an introduction to the image synthesis method provided in this application.
[0049] First, please refer to Figure 1 The present application embodiment provides an image synthesis method, which may include the following steps:
[0050] Step S110: obtaining a semantic segmentation map including a plurality of local regions and a sampling noise map of the same scale as the semantic segmentation map, wherein each local region has a class label for characterizing the category to which it belongs.
[0051] Step S120: converting the semantic segmentation map into a semantic vector related to semantics and appearance according to the similarity information between the objects represented by the various class labels acquired in advance.
[0052] Step S130: obtaining a composite image by processing the semantic vector and the sampled noise map.
[0053] Among them, the method can be applied to image synthesis networks.
[0054] like Figure 2 As shown, the image synthesis network 200 may include a semantic vector generation subnetwork 210 and a semantic rendering subnetwork 220 .
[0055] The semantic vector generation sub-network 210 includes a feature extraction unit 211 and a conversion unit 212 , and the semantic rendering sub-network 220 includes a residual calculation unit 221 .
[0056] It is worth pointing out that there is a one-to-one correspondence between the feature extraction units 211 and the residual calculation units 221. That is, the number of the feature extraction units 211 and the residual calculation units 221 is the same.
[0057] For example, in some embodiments, when the number of feature extraction units 211 is one, the number of residual calculation units 221 is also one; for example, in other embodiments, when the number of feature extraction units 211 is N, the number of residual calculation units 221 is also N.
[0058] Depend on Figure 2It can be seen that when the number of feature extraction units 211 and residual calculation units 221 is one, after the unique feature extraction unit 211 obtains the first input information, it passes the obtained output result to the conversion unit 212 for processing to output the intermediate processing result. Subsequently, the unique residual calculation unit 221 obtains the second input information and processes it, and the part of the input information included in the second input information is the intermediate processing result output by the conversion unit 212.
[0059] Depend on Figure 2 It can be seen that when the number of feature extraction units 211 and residual calculation units 221 is N, each feature extraction unit 211 is connected in sequence and is connected to the conversion unit 212. In addition, each residual calculation unit 221 is connected in sequence and is connected to the conversion unit 212.
[0060] At this time, after each feature extraction unit 211 obtains the complete first input information, it processes the first input information to obtain an output result. Then, the feature extraction unit 211 not only passes the output result to the conversion unit 212 for processing to output an intermediate processing result, but also passes the output result to the next feature extraction unit 211.
[0061] The first input information obtained by the first feature extraction unit 211 is information from external input, and the first input information obtained by other feature extraction units 211 includes not only information from external input, but also output results from the previous feature extraction unit 211. Of course, the information from external input obtained by each feature extraction unit 211 is different.
[0062] After processing the output results output by the N feature extraction units 211, the conversion unit 212 obtains N intermediate processing results, and then the conversion unit 212 inputs each intermediate processing result to the residual calculation unit 221 corresponding to the upstream feature extraction unit 211 of the intermediate processing result.
[0063] That is, each residual calculation unit 221 can obtain the intermediate processing result obtained after the output result of the feature extraction unit 211 corresponding to itself is processed by the conversion unit 212.
[0064] In addition, after acquiring the complete second input information, each residual calculation unit 221 processes the second input information to obtain an output result.
[0065] Among them, the second input information obtained by the first residual calculation unit 221 is the information from the external input and the corresponding intermediate processing result output from the conversion unit 212; the second input information obtained by other residual calculation units 221 includes not only the corresponding intermediate processing result output from the conversion unit 212, but also the output result from the previous residual calculation unit 221.
[0066] The following will be combined Figure 3 The steps included in the image synthesis method applied to the image synthesis network 200 are described.
[0067] Step S210: Each of the feature extraction units obtains first input information.
[0068] In an embodiment of the present application, when a target semantic segmentation map needs to be processed to synthesize a natural image corresponding to the target semantic segmentation map, the target semantic segmentation map can be input into the image synthesis network 200 for processing.
[0069] It is worth noting that in the embodiment of the present application, the presentation form of the target semantic segmentation map can be a matrix including matrix data, or a visual image including matrix data.
[0070] In addition, the target semantic segmentation map includes multiple local regions, and each local region is pre-labeled with a class label, which is used to characterize the category to which the corresponding local region belongs.
[0071] For example, when the content represented by the target semantic segmentation map is a face image, the target semantic segmentation map may include 10 local areas, namely, the left eye area, the right eye area, the left eyebrow area, the right eyebrow area, the mouth area, the nose area, the left ear area, the right ear area, the hair area, and the skin area. Accordingly, a corresponding class label is pre-labeled for each local area, for example, the left eye area is represented by class label 1, the right eye area is represented by class label 2, the left eyebrow area is represented by class label 3, the right eyebrow area is represented by class label 4, the mouth area is represented by class label 5, the nose area is represented by class label 6, the left ear area is represented by class label 7, the right ear area is represented by class label 8, the hair area is represented by class label 9, and the skin area is represented by class label 10.
[0072] Of course, in some implementations, other characters may be used to represent the class label, for example, letters A, B, C, . . . may be used to represent the class label.
[0073] As mentioned above, the semantic vector generation subnetwork 210 of the image synthesis network 200 may include a feature extraction unit 211, and correspondingly, the semantic rendering subnetwork 220 of the image synthesis network 200 also includes a residual calculation unit 221. In this embodiment, the target semantic segmentation map can be directly input into the image synthesis network 200 (equivalent to downsampling the target semantic segmentation map by a preset multiple of 1), and at this time, the first input information obtained by the feature extraction unit 211 is the target semantic segmentation map.
[0074] In addition, in some embodiments, when the semantic vector generation subnetwork 210 includes N (for example, 3) feature extraction units 211, the semantic rendering subnetwork 220 also includes 3 residual calculation units 221. In this embodiment, the target semantic segmentation map can be scaled in advance, for example, the target semantic segmentation map is iteratively downsampled by a preset multiple to obtain semantic segmentation maps of different scales, which are the same number as the number N of feature extraction units 211.
[0075] For example, under the premise of N=3, the scale of the target semantic segmentation map is 32×32, and the preset multiple is 2. Under this assumption, three downsamplings are required to obtain three semantic segmentation maps. Assume that in the first downsampling, the scale of the obtained semantic segmentation map is 1 / 2 of the scale of the target semantic segmentation map. Figure 1 , when downsampling for the second time, the semantic segmentation with a scale of 1 / 4 of the target semantic segmentation map is obtained Figure 2 , when downsampling for the third time, the semantic segmentation with a scale of 1 / 8 of the target semantic segmentation map is obtained Figure 3 Correspondingly, semantic segmentation Figure 1 The scale is 16×16, semantic segmentation Figure 2 The scale is 8×8, semantic segmentation Figure 3 The scale is 4×4.
[0076] Of course, it is worth pointing out that after downsampling the target semantic segmentation map, the information that changes is mainly the scale information. Therefore, the semantic segmentation map obtained by each feature extraction unit 211 includes the same number of local areas and the class labels marked on each local area are the same.
[0077] After obtaining three semantic segmentation maps of different scales, the semantic segmentation maps are matched one-to-one with the feature extraction units 211 , and the corresponding semantic segmentation maps are input into the corresponding feature extraction units 211 .
[0078] It is worth pointing out that when the semantic segmentation maps are associated with the feature extraction units 211 one by one, the generation order of the semantic segmentation maps is in reverse order with the connection order of the feature extraction units 211. That is, the first semantic segmentation map is generated. Figure 1Corresponding to the last feature extraction unit 211, the last semantic segmentation obtained Figure 3 Corresponding to the first feature extraction unit 211.
[0079] In this embodiment, the first input information obtained by the first feature extraction unit 211 is semantic segmentation Figure 3 (4×4), the first input information obtained by the subsequent other feature extraction units 211 includes the semantic segmentation map obtained by itself and the output result output by the previous feature extraction unit 211. Among them, the semantic segmentation map obtained by the second feature extraction unit 211 is the semantic segmentation map. Figure 1 (8×8), the semantic segmentation map obtained by the third feature extraction unit 211 is the semantic segmentation map Figure 1 (16×16).
[0080] Step S220: Each of the feature extraction units extracts features from the first input information according to the similarity information between the objects represented by the class labels acquired in advance, and outputs a feature map having a scale that is a preset multiple of the scale of the first input information.
[0081] Among them, for each feature extraction unit 211, after obtaining the first input information, convolution processing can be performed on the first input information to obtain an output result, which is a feature map of the semantic segmentation map included in the first input information obtained by the feature extraction unit 211, and the scale of the feature map is a preset multiple of the scale of the semantic segmentation map included in the first input information.
[0082] For example, corresponding to the example in which the semantic vector generation subnetwork 210 includes three feature extraction units 211, for the first feature extraction unit 211, the semantic segmentation included in the first input information obtained by it Figure 3 The scale is 4×4, and its output is the same as the semantic segmentation Figure 3 The corresponding feature map and semantic segmentation Figure 3 The scale of the corresponding feature map is 8×8; for the second feature extraction unit 211, the semantic segmentation included in the first input information obtained by it Figure 2 The scale is 8×8, and its output is the same as the semantic segmentation Figure 2 The corresponding feature map and semantic segmentation Figure 2 The scale of the corresponding feature map is 16×16; for the third feature extraction unit 211, the semantic segmentation included in the first input information obtained by it Figure 1 The scale is 16×16, and its output is the same as the semantic segmentation Figure 1 The corresponding feature map and semantic segmentation Figure 1 The scale of the corresponding feature map is 32×32.
[0083] As mentioned above, the semantic segmentation map obtained by each feature extraction unit 211 includes local regions and class labels of each local region. In the embodiment of the present application, when each feature extraction unit 211 extracts features from its respective first input information, it needs to consider the class labels of each local region in the semantic segmentation map obtained by itself.
[0084] Optionally, each feature extraction unit 211 includes a convolution layer (conv), an activation function layer (leakyReLU) and an upsampling layer (upsample), wherein the upsampling layer is a preset multiple involved when the upsampling multiple is iterative downsampling of the target semantic segmentation map. For example, corresponding to the above example, when the preset multiple is 2, the upsampling layer needs to be upsampled by 2 times. At this time, the structure presented by each feature extraction unit 211 can be: convolution layer (conv) → activation function layer (leakyReLU) → convolution layer (conv) → upsampling layer (upsample, X2, nearest, that is, the sampling mode is 2 times upsampling of nearest).
[0085] In the above embodiment, each feature extraction unit 211 performs convolution operation, activation function operation, convolution operation, convolution operation and upsampling operation of a preset multiple (2 times in the example above) on its own first input information in sequence to obtain the feature value of each position in the semantic segmentation map corresponding to its own first input information.
[0086] After obtaining the feature values of each position in the corresponding semantic segmentation map, each feature extraction unit 211 adjusts the feature values of each position according to the similarity information between the objects represented by each class label and the corresponding class label to which each position belongs in the corresponding semantic segmentation map, thereby obtaining a feature map corresponding to itself formed by each adjusted feature value. Among them, in the corresponding feature map, the adjusted feature values corresponding to the region with higher similarity are more similar.
[0087] It is worth pointing out that the similarity information between the objects represented by each class label can be stored locally in advance, or can be temporarily acquired by the feature extraction unit 211. In addition, the similarity information between the objects represented by each class label is uniformly configured in advance by the staff. For example, the similarity between label 1 used to represent the left eye area and label 2 used to represent the right eye area is set to 95%, indicating that the two are extremely similar.
[0088] As for the rules for each feature extraction unit 211 to adjust the feature value according to the similarity information between the objects represented by each class label, it is determined by the intermediate parameters formed by the semantic vector generation sub-network 210 during the training process.
[0089] It is worth noting that the last feature extraction unit 211 included in the semantic vector generation subnetwork 210 may include a convolution layer (conv) and an activation function layer (hard tanh) in addition to the layer structure mentioned above, so that the convolution layer (conv) and the activation function layer (hard tanh) of the last feature extraction unit 211 continue to perform convolution operations and truncation operations on the output results of the aforementioned layer structure of the last feature extraction unit 211, so that the last feature extraction unit 211 can finally output a rough prediction image Coarse Pred.
[0090] When the semantic vector generation subnetwork 210 is trained, each input training sample includes a target semantic segmentation map and a real natural image Ground Truth corresponding to the target semantic segmentation map. During the training process, for each training sample, a coarse prediction image CoarsePred can be output by the last feature extraction unit 211. Subsequently, by minimizing the Euclidean distance of the corresponding positions between the coarse prediction image Coarse Pred of the training sample and the real natural image Ground Truth of the training sample (pixels at corresponding positions are subtracted and then back-gradient propagated), each feature extraction unit 211 updates its own intermediate adjustment parameter, which is used to determine how to adjust the feature value according to the similarity information between the objects represented by each class label, so that each feature extraction unit 211 re-encodes the adjusted feature value, so that the coarse prediction image Coarse Pred output by the semantic vector generation subnetwork 210 finally meets the preset requirements, for example, the Euclidean distance of the corresponding positions between the coarse prediction image Coarse Pred and the corresponding real natural image Ground Truth is less than the preset parameter.
[0091] Step S230: The conversion unit adjusts each of the feature maps to obtain multiple semantic vectors.
[0092] As mentioned above, after each feature extraction unit 211 generates a feature map, in addition to passing the feature map to the next feature extraction unit 211, the feature map is also passed to the conversion unit 212 for processing.
[0093] The main function of the conversion unit 212 is to generate semantic vectors corresponding to each feature map. The generation process can refer to the following method.
[0094] Assume that the feature map is S∈R h×w×c , where R is a real number, h, w, and c represent the width, height, and number of channels of the feature map S, respectively.
[0095] In some embodiments, for each feature map S∈R h×w×c , after adjusting the number of channels of the feature map to a uniform preset channel value n (n < c), the feature map V∈R after the number of channels is adjusted h×w×n , where R is a real number, h, w, and n are the width, height, and number of channels of the feature map V after adjusting the number of channels.
[0096] After obtaining the feature map V∈R after adjusting the number of channels h×w×n Then, V∈R h×w×n Normalize it to get the semantic vector corresponding to the feature map, that is, V∈R h×w×n ->V∈[0,1] h×w×n .
[0097] Optionally, V∈R can be processed by a softmax function h×w×n Normalization can be performed based on the formula Each value of V is processed to normalize it to between 0 and 1, and V∈[0,1] is obtained. h×w×n , so that the corresponding semantic vector V i,j ∈[0,1] n .
[0098] Among them, i, j, and x represent the row number, column number, and channel number of the feature map V after adjusting the number of channels, respectively. i,j,x The feature value representing the feature at the i-th row, j-th column, and x-th channel in the feature map V after adjusting the number of channels; τ is a preset parameter, which is predetermined by the staff. For example, in some embodiments, τ is set to 0.05; y is a parameter with a value range of 1 to n and is an integer; the semantic vector V ij Represents the n-dimensional feature vector corresponding to the i-th row and j-th column in the semantic segmentation map currently being processed.
[0099] After the conversion unit 212 processes the feature graph corresponding to each feature extraction unit 211 according to the above process, a semantic vector V corresponding to each feature extraction unit 211 is obtained. t (i.e. the intermediate processing result mentioned above), and the number of generated semantic vectors is consistent with the number of feature extraction units 211, therefore, {V t} t=1,...N . Where V∈[0,1] h'×w'×n, N refers to N feature maps. For example, in one embodiment above, there are 3 feature extraction units 211, and correspondingly there are 3 feature maps.
[0100] Step S240: Each of the residual calculation units obtains second input information.
[0101] As mentioned above, the number of residual calculation units 221 included in the semantic rendering sub-network 220 is consistent with that of the feature extraction units 211 .
[0102] The second input information obtained by the first residual calculation unit 221 is the information from the external input and the corresponding intermediate processing result (semantic vector) output from the conversion unit 212; the second input information obtained by other residual calculation units 221 includes not only the corresponding intermediate processing result (semantic vector) output from the conversion unit 212, but also the output result from the previous residual calculation unit 221. The second input information of the first residual calculation unit 221 also includes a sampling noise map of the same scale as the semantic segmentation map input to the first feature extraction unit 211.
[0103] The sampled noise map is obtained by reshaping the noise sampled from the standard Gaussian distribution. For example, in some of the examples shown above, the semantic segmentation of the first feature extraction unit 211 is input Figure 3 The scale of is 4×4, so the scale of the sampled noise map is also 4×4.
[0104] It is worth noting that, for the first residual calculation unit 221, since there is no previous residual calculation unit 221, the output result from the previous residual calculation unit 221 in the second input information obtained by the first residual calculation unit 221 is empty.
[0105] Assume that N=3, the scale of the target semantic segmentation map is 32×32, and the preset multiple is 2. Under this assumption, the semantic segmentation map included in the first input information obtained by the first feature extraction unit 211 Figure 3 The scale is 4×4, and its output is the same as the semantic segmentation Figure 3 The scale of the corresponding feature map is 8×8, and the conversion unit 212 is related to the semantic segmentation Figure 3 After the corresponding feature map is processed, the semantic vector 1{V 1}; The semantic segmentation included in the first input information obtained by the second feature extraction unit 211 Figure 2 The scale is 8×8, and its output is the same as the semantic segmentation Figure 2 The scale of the corresponding feature map is 16×16, and the conversion unit 212 is related to the semantic segmentation Figure 2After the corresponding feature map is processed, the semantic vector 2{V 2}; The semantic segmentation included in the first input information obtained by the third feature extraction unit 211 Figure 1 The scale is 16×16, and its output is the same as the semantic segmentation Figure 1 The scale of the corresponding feature map is 32×32, and the conversion unit 212 is related to the semantic segmentation Figure 1 After the corresponding feature map is processed, the semantic vector 3{V 3}.
[0106] Correspondingly, the second input information obtained by the first residual calculation unit 221 includes a sampling noise map with a scale of 4×4 and a semantic vector 1 corresponding to the first feature extraction unit 211; the second input information obtained by the second residual calculation unit 221 includes the output result of the first residual calculation unit 221 and the semantic vector 2 corresponding to the second feature extraction unit 211; the second input information obtained by the third residual calculation unit 221 includes the output result of the second residual calculation unit 221 and the semantic vector 3 corresponding to the third feature extraction unit 211.
[0107] Step S250: Each of the residual calculation units adjusts its own parameters according to different values of the acquired semantic vector, processes the second input information, and the last residual calculation unit outputs a synthesized image.
[0108] It is worth noting that n convolution weights and n affine transformation weights are pre-stored in the semantic rendering sub-network 220. The value of n is the same as the preset channel value of the feature map after adjusting the number of channels mentioned above.
[0109] Each residual calculation unit 221 included in the semantic rendering sub-network 220 includes a spatial variation convolution sub-unit 2211 and an affine transformation sub-unit 2212. In the process of processing the second input information of each residual calculation unit 221, the parameters of the spatial variation convolution sub-unit 2211 need to be calculated in real time according to the pre-stored n convolution weights, and the parameters of the affine transformation sub-unit 2212 also need to be calculated in real time according to the pre-stored n affine transformation weights.
[0110] For each residual calculation unit 221 included in the semantic rendering sub-network 220, its own parameters (i.e., convolution weights and affine transformation weights) can be adjusted according to different values of the semantic vector included in the second input information, so as to process other information in the second input information based on the adjusted parameters.
[0111] Optionally, after each residual calculation unit 221 obtains the second input information corresponding to itself, if there are P value combinations of rows and columns of the semantic vector included in the second input information, accordingly, in the process of each residual calculation unit 221 processing its own second input information, the parameters of its spatial variation convolution subunit 2211 and the parameters of its affine transformation subunit 2212 need to be changed P times.
[0112] The following will take one of the residual calculation units M as an example to introduce a process in which the residual calculation unit M adjusts its own parameters according to different values of the semantic vector included in its second input information.
[0113] Assume that the second input information obtained by the residual calculation unit M includes the semantic vector partial information V i,j ∈[0,1] n And the non-semantic vector part information F.
[0114] Among them, when the residual calculation unit M is the first residual calculation unit 221, the non-semantic vector part information obtained includes the sampling noise map; when the residual calculation unit M is other residual calculation unit 221, the non-semantic vector part information obtained includes the output result of the previous residual calculation unit 221.
[0115] The semantic vector information is V i,j ∈[0,1] n , represents the n-dimensional feature vector corresponding to the i-th row and j-th column in the semantic segmentation map obtained by the feature extraction unit M corresponding to the residual calculation unit M.
[0116] The residual calculation unit M obtains the semantic vector V i,j ∈[0,1] n After that, i and j are respectively taken from 1 in turn, so as to obtain multiple value combinations of i and j.
[0117] For each combination of i and j, obtain the value of V under this combination. ij The n values determined when n is different: V ij1 、V ij2 , ..., V ijn , and then perform a linear weighted summation on these n values and the n pre-saved convolution weights to obtain the parameters of each spatially varying convolution sub-unit 2211 included in the residual calculation unit M under the current combination of values of i and j, i.e., the convolution weight.
[0118] Optionally, assuming that the n pre-saved convolution weights are k1, k2, ..., kn, respectively, when performing linear weighted summation, V ij1 ×k1+V ij2×k2+...+V ijn ×kn, the final result is the convolution weight of each spatially varying convolution subunit 2211 of the residual calculation unit M under the current value combination of i and j. In other words, the convolution kernel of each spatially varying convolution subunit 2211 (SCC) is i and j mark the row and column numbers of the feature map currently processed by the residual calculation unit M, and y marks the channel number of V and the number of the candidate weight.
[0119] In addition, for each combination of i and j, the values can also be combined, V ij The n represented values are linearly weighted and summed with the n pre-saved affine transformation weights to obtain the parameters of each affine transformation sub-unit 2212 included in the residual calculation unit M under the current combination of values of i and j, namely, the affine transformation weight.
[0120] Optionally, assume that n pre-saved affine transformation weights {s1 (standard deviation), m1 (mean)}, {s2, m2}, ... {sn, mn} are used. When performing linear weighted summation, V ij1 ×s1+V ij2 ×s2+...+V ijn ×sn, the final result is the standard deviation under the current value combination of i and j. In addition, V ij1 ×m1+V ij2 ×m2+...+V ijn ×mn, the final result is the mean under the current value combination of i and j, thereby obtaining the affine transformation weight of each affine transformation subunit 2212 of the residual calculation unit M under the current value combination of i and j. In other words, the standard deviation of each affine transformation subunit 2212 (SCN) is The mean value of each affine transformation subunit 2212 (SCN) is Among them, i and j mark the row number and column number of the feature map currently processed by the residual calculation unit M, and y marks the channel number of V and the number of the candidate weight.
[0121] In addition, it is worth noting that the basic structure of each residual calculation unit 221 included in the semantic rendering sub-network 220 is the same, including at least one group of residual calculation sub-units 222, wherein the substructures included in each group of residual calculation sub-units 222 may be the same or different, and each group of residual calculation sub-units 222 includes at least one pair of spatially varying convolution sub-units 2211, a function layer 2213, and an affine transformation sub-unit 2212.
[0122] In some embodiments, each residual calculation unit 221 includes a group of residual calculation subunits 222, and the group of residual calculation subunits 222 includes two pairs of spatial variation convolution subunits 2211, a function layer 2213 and an affine transformation subunit 2212, thereby forming Figure 4 The structure shown: spatially varying convolution subunit 2211 (SCN) → function layer 2213 (LReLU) → affine transformation subunit 2212 (SCC) → spatially varying convolution subunit 2211 (SCN) → function layer 2213 (LReLU) → affine transformation subunit 2212 (SCC).
[0123] In some embodiments, each residual calculation unit 221 includes two groups of residual calculation subunits 222, and the first group of residual calculation subunits 222 includes two pairs of spatial variation convolution subunits 2211, function layer 2213 and affine transformation subunit 2212: spatial variation convolution subunit 2211 (SCN) → function layer 2213 (LReLU) → affine transformation subunit 2212 (SCC) → spatial variation convolution subunit 2211 (SCN) → function layer 2213 (LReLU) )→affine transformation subunit 2212 (SCC); the second group of residual calculation subunits 222 includes a pair of spatial variation convolution subunits 2211, a function layer 2213 and an affine transformation subunit 2212: spatial variation convolution subunit 2211 (SCN)→function layer 2213 (LReLU)→affine transformation subunit 2212 (SCC), in addition, the output of the first group of residual calculation subunits 222 and the output of the second group of residual calculation subunits 222 are matrix-added to form the following: Figure 5 The structure shown.
[0124] It is worth noting that no matter how many groups of residual calculation subunits 222 are included in the residual calculation unit 221, each spatial variation convolution subunit 2211 and each affine transformation subunit 2212 in each group of residual calculation subunits 222 need to obtain the semantic vector part information V included in the second input information. i,j ∈[0,1] n , and each group of residual calculation sub-units 222 needs to obtain the non-semantic vector part information F included in the second input information.
[0125] After each residual calculation unit 221 determines the affine transformation weight and convolution weight under the current combination of i and j values through the above process, it determines the parameters of each spatial variation convolution sub-unit 2211 and the parameters of each affine transformation sub-unit 2212 currently included in itself, and can process the second input information through the currently determined parameters.
[0126] Optionally, in the process of processing the second input information, each residual calculation unit 221 may first perform the above-mentioned preset multiple up-sampling on the non-semantic vector part information included in the second input information, and then input the up-sampled data into each group of residual calculation subunits 222 included therein, so that the affine transformation subunit 2212 (SCN) in each group of residual calculation subunits 222 performs radial transformation on the non-semantic vector part information, the function layer 2213 (LReLU) in each group of residual calculation subunits 222 performs activation function processing on the result of the previous SCN, and the spatial variation convolution subunit 2211 (SCC) in each group of residual calculation subunits 222 performs convolution processing on the processing result of the previous LReLU, so as to obtain the final processing result of each group of residual calculation subunits 222. Subsequently, the final processing result of each group of residual calculation subunits 222 is subjected to matrix addition operation to obtain the second output information output by itself.
[0127] It is worth pointing out that, under the current combination of values of i and j, the processing area targeted by the above processing process of the residual calculation unit 221 is the area corresponding to the i-th row and the j-th column in the processing object (the non-semantic vector partial information included in the second input information). That is to say, for each residual calculation unit 221, after it obtains the second input information, if the value combination of i and j in the semantic vector partial information in the second input information it obtains includes P, then when the residual calculation unit 221 processes the non-semantic vector partial information in the second input information, it needs to process it in P times, and each time it processes a local area in the non-semantic vector partial information in the second input information.
[0128] During this period, each time the value combination V of i and j is determined ij The residual calculation unit 221 calculates the current affine transformation weight and convolution weight once, and updates its own parameters with the currently determined affine transformation weight and convolution weight, and processes the non-semantic vector part information (assuming F) in the second input information with the updated parameters. ij area.
[0129] After each residual calculation unit 221 performs the above processing operation, the last residual calculation unit 221 outputs a synthesized image.
[0130] In the above process, since the eigenvalues of the feature map are adjusted according to the similarity information between the objects represented by each class label, the corresponding scalars used to represent the similar areas in the feature map (such as the left eye area and the right eye area) in the subsequently generated semantic vector are also similar. Therefore, the affine transformation weights and convolution weights of the residual calculation unit 221 used to process the similar areas are also similar, that is, the processing parameters are similar and related, thereby enhancing the correlation between the various areas in the composite image, so that the areas that should be similar present similar effects in the final composite image, which is beneficial to improving the display effect.
[0131] like Figure 6 As shown, the embodiment of the present application further provides an image synthesis device 400 , which may include: an acquisition module 410 , a conversion module 420 and a synthesis module 430 .
[0132] An acquisition module 410 is used to acquire a semantic segmentation map including multiple local regions and a sampling noise map of the same scale as the semantic segmentation map, wherein each local region has a class label for characterizing the category to which it belongs;
[0133] A conversion module 420, configured to convert the semantic segmentation map into a semantic vector related to semantics and appearance according to the similarity information between the objects represented by the various class labels acquired in advance;
[0134] The synthesis module 430 is used to obtain a synthesized image by processing the semantic vector and the sampled noise map.
[0135] In some embodiments, the device is applied to an image synthesis network, which includes a semantic vector generation subnetwork and a semantic rendering subnetwork; the conversion module is used to process the semantic segmentation map through the semantic vector generation subnetwork and the similarity information between the objects represented by the various class labels to obtain a semantic vector corresponding to the semantic segmentation map.
[0136] In some embodiments, the semantic vector generation subnetwork includes a feature extraction unit and a conversion unit; the conversion module 420 is used to obtain first input information through each of the feature extraction units, wherein the first input information of the first feature extraction unit is the semantic segmentation map, and the first input information of the second feature extraction unit to the last feature extraction unit includes the output result of the previous feature extraction unit and the corresponding semantic segmentation map, the corresponding semantic segmentation map is homologous to the semantic segmentation map obtained by the previous feature extraction unit, and the scale is a preset multiple of the semantic segmentation map obtained by the previous feature extraction unit; each feature extraction unit performs feature extraction on the first input information according to the similarity information between objects represented by each class label obtained in advance, and outputs a feature map with a scale that is the preset multiple of the scale of the first input information; each feature map is adjusted by the conversion unit to obtain multiple semantic vectors.
[0137] In some embodiments, the conversion module 420 is used to perform convolution operation, activation function operation, convolution operation and upsampling operation of the preset multiple on the first input information in sequence to obtain feature values of each position of the image corresponding to the first input information; according to the corresponding class labels to which the respective positions belong and the similarity information between the objects represented by the respective class labels, the feature values of the respective positions are adjusted so that the feature values corresponding to the regions with higher similarity are more similar, thereby obtaining the feature map.
[0138] In some embodiments, the conversion module 420 is used to adjust the number of channels of each feature map to a preset channel value, and then normalize the feature map after the channel number is adjusted to obtain a semantic vector corresponding to the feature map.
[0139] In some embodiments, the feature map after adjusting the number of channels is V∈R h×w×n , where R is a real number, h, w, and n are the width, height, and number of channels of the feature map after adjusting the number of channels, respectively. The conversion module 420 is used to calculate the feature map based on the formula Each value of V is processed to normalize each value of V to between 0 and 1, and V∈[0,1] is obtained. h×w×n , so that the corresponding semantic vector V i,j ∈[0,1] n ; Wherein, i, j, and x represent the row number, column number, and channel number of the feature map V after adjusting the number of channels, respectively, V i,j,xThe feature value representing the feature at the i-th row, j-th column, and x-th channel in the feature map V after adjusting the number of channels, τ is a preset parameter, y is a parameter with a value range of 1 to n and is an integer, and the semantic vector V ij Represents the n-dimensional feature vector corresponding to the i-th row and j-th column in the semantic segmentation map currently being processed.
[0140] In some implementations, the number of the feature extraction units is one or more.
[0141] In some embodiments, the device is applied to an image synthesis network, which includes a semantic rendering sub-network; the synthesis module 430 is used to input the semantic vector and the sampling noise map into the semantic rendering sub-network; according to different values of the semantic vector, the parameters of the residual calculation unit in the semantic rendering sub-network for processing the sampling noise map are adjusted, and the sampling noise map is processed by the residual calculation unit after the adjustment of the parameters to output the synthesized image.
[0142] In some embodiments, the image synthesis network includes a semantic vector generation subnetwork, the semantic vector generation subnetwork includes a feature extraction unit, the semantic rendering subnetwork includes a residual calculation unit, and the feature extraction unit corresponds one-to-one to the residual calculation unit; the synthesis module 430 is used to obtain second input information through each of the residual calculation units, wherein the second input information of each of the residual calculation units includes a semantic vector from the feature extraction unit corresponding to it, and second output information including the output of the previous residual calculation unit, and the second input information of the first residual calculation unit also includes a sampling noise map of the same scale as the semantic segmentation map.
[0143] In some embodiments, the semantic vector is V i,j ∈[0,1] n , represents the n-dimensional feature vector corresponding to the i-th row and j-th column of the semantic segmentation map currently being processed, the residual calculation unit includes a spatial variation convolution subunit and an affine transformation subunit, and the synthesis module 430 is used to obtain, for each value combination of i and j, V under the value combination. ij n numerical values determined when n takes different values; performing linear weighted summation on the n numerical values and the n pre-saved convolution weights to obtain the parameters of the spatial variation convolution subunit included in the residual calculation unit under the current combination of i and j values; performing linear weighted summation on the n numerical values and the n pre-saved affine transformation weights to obtain the parameters of the affine transformation subunit included in the residual calculation unit under the current combination of i and j values.
[0144] In some embodiments, the residual calculation unit includes multiple groups of residual calculation subunits, each group of the residual calculation subunits includes at least one pair of the spatial variation convolution subunit and the affine transformation subunit, and the synthesis module 430 is used to upsample the processing object by the preset multiple, and then input it into each group of the residual calculation subunits included in the residual calculation unit for affine transformation processing and convolution processing to obtain an output result; each of the output results is subjected to a matrix addition operation to obtain the second output information output by itself; wherein, under the current combination of i and j values, the residual calculation unit processes the area corresponding to the i-th row and j-th column in the processing object; the processing object of the first residual calculation unit is the sampling noise map, and the processing objects of the remaining residual calculation units are the second output information output by the previous residual calculation subunit.
[0145] The image synthesis device 400 provided in the embodiment of the present application has the same implementation principle and technical effects as those of the aforementioned method embodiment. For the sake of brief description, for matters not mentioned in the device embodiment, reference may be made to the corresponding contents in the aforementioned method embodiment.
[0146] In addition, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a computer, the steps included in the above-mentioned image synthesis method are executed.
[0147] In addition, please refer to Figure 7 The embodiment of the present application also provides an electronic device 100 for implementing the image synthesis method and device of the embodiment of the present application.
[0148] The electronic device 100 can process the semantically segmented image to perform a function of synthesizing the semantically segmented image.
[0149] Optionally, the electronic device 100 may be, but not limited to, a personal computer (PC), a smart phone, a mobile Internet device (MID), a server, etc. The server may be, but not limited to, a network server, a cloud server, etc.
[0150] The electronic device 100 may include: a processor 110 (including a CPU and a GPU) and a memory 120 .
[0151] It should be noted that Figure 7The components and structures of the electronic device 100 shown are only exemplary and non-restrictive. The electronic device 100 may also have other components and structures as required. For example, in some cases, the electronic device 100 may also include a display for displaying the synthesized image.
[0152] The processor 110, the memory 120, and other components that may appear in the electronic device 100 are directly or indirectly electrically connected to each other to achieve data transmission or interaction. For example, the processor 110, the memory 120, and other components that may appear may be electrically connected to each other via one or more communication buses or signal lines.
[0153] The memory 120 is used to store programs, for example, a program corresponding to the image synthesis method mentioned above or an image synthesis device mentioned above. Optionally, when the image synthesis device is stored in the memory 120, the image synthesis device includes at least one software function module that can be stored in the memory 120 in the form of software or firmware.
[0154] Optionally, the software function modules included in the image synthesis device may also be embedded in the operating system (OS) of the electronic device 100 .
[0155] The processor 110 is used to execute executable modules stored in the memory 120, such as software function modules or computer programs included in the image synthesis device. After receiving the execution instruction, the processor 110 can execute the computer program, for example, to execute: obtaining a semantic segmentation map including multiple local areas and a sampling noise map of the same scale as the semantic segmentation map, each of the local areas has a class label for representing the category to which it belongs; according to the similarity information between the objects represented by each class label obtained in advance, converting the semantic segmentation map into a semantic vector related to semantics and appearance; and obtaining a synthesized image by processing the semantic vector and the sampling noise map.
[0156] Alternatively, the electronic device 100 includes an image synthesis network, and the image synthesis network includes a semantic vector generation subnetwork and a semantic rendering subnetwork, the semantic vector generation subnetwork includes a feature extraction unit and a conversion unit, the semantic rendering subnetwork includes a residual calculation unit, and the feature extraction unit corresponds to the residual calculation unit one-to-one, the processor 110 can execute after receiving the execution instruction: each of the feature extraction units obtains first input information, wherein the first input information of the first feature extraction unit is a semantic segmentation map including multiple local areas, each of the local areas has a class label for characterizing the category to which it belongs, and the first input information of the second feature extraction unit to the last feature extraction unit includes the output result of the previous feature extraction unit and the corresponding semantic segmentation map, the corresponding semantic segmentation map is homologous to the semantic segmentation map obtained by the previous feature extraction unit, and the scale is the same as that of the previous feature extraction unit. a preset multiple of the acquired semantic segmentation map; each of the feature extraction units performs feature extraction on the first input information according to the similarity information between the objects represented by the various class labels acquired in advance, and outputs a feature map with a scale that is the preset multiple of the scale of the first input information; the conversion unit adjusts each of the feature maps to obtain multiple semantic vectors; each of the residual calculation units obtains second input information, wherein the second input information of each of the residual calculation units includes the semantic vector from the corresponding feature extraction unit, and the second output information output by the previous residual calculation unit, and the second input information of the first residual calculation unit also includes a sampling noise map of the same scale as the semantic segmentation map input to the first feature extraction unit; each of the residual calculation units adjusts its own parameters according to the different values of the acquired semantic vectors, processes the second input information, and the last residual calculation unit outputs a composite image.
[0157] Of course, the method disclosed in any embodiment of the present application can be applied to the processor 110 or implemented by the processor 110.
[0158] In summary, the image synthesis method, device, electronic device and computer-readable storage medium proposed in the embodiments of the present invention convert the semantic segmentation map into a semantic vector related to semantics and appearance based on the similarity information between objects represented by each class label, so that in the subsequently generated semantic vector, the corresponding scalars used to represent similar areas (such as the left eye area and the right eye area) in the semantic segmentation map are also similar. Therefore, the subsequent processing parameters used to process similar areas are similar, so that the areas that should be similar present similar effects in the final synthesized image, which is beneficial to improving the display effect.
[0159] It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0160] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0161] In addition, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
[0162] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a laptop, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0163] The above description is only a specific implementation manner of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application.
Claims
1. An image synthesis method, characterized in that: The method comprises: Obtaining a semantic segmentation map including a plurality of local regions and a sampling noise map of the same scale as the semantic segmentation map, wherein each local region has a class label for characterizing the category to which it belongs; According to the similarity information between the objects represented by the various class labels obtained in advance, the semantic segmentation map is converted into a semantic vector related to semantics and appearance; Obtaining a synthetic image by processing the semantic vector and the sampled noise map; The method of converting the semantic segmentation map into a semantic vector related to semantics and appearance according to the similarity information between objects represented by each class label acquired in advance includes: Obtaining feature values of each position in the semantic segmentation map; According to the corresponding class labels to which each position belongs and the similarity information between the objects represented by each class label, the feature values of each position are adjusted so that the feature values corresponding to the regions with higher similarity are more similar, and a feature map corresponding to itself is obtained which is formed by each adjusted feature value; Each of the feature maps is adjusted to obtain multiple semantic vectors.
2. The method according to claim 1, characterized in that: The method is applied to an image synthesis network, the image synthesis network includes a semantic vector generation subnetwork and a semantic rendering subnetwork; the method converts the semantic segmentation map into a semantic vector related to semantics and appearance according to the similarity information between objects represented by each class label acquired in advance, including: The semantic segmentation map is processed by generating similarity information between the subnetwork and the objects represented by the various class labels through the semantic vector to obtain a semantic vector corresponding to the semantic segmentation map.
3. The method according to claim 2, characterized in that The semantic vector generation subnetwork includes a feature extraction unit and a conversion unit; the semantic segmentation map is processed by the semantic vector generation subnetwork and the similarity information between the objects represented by each class label to obtain a semantic vector corresponding to the semantic segmentation map, including: Each of the feature extraction units obtains first input information, wherein the first input information of the first feature extraction unit is the semantic segmentation map, and the first input information of the second feature extraction unit to the last feature extraction unit includes the output result of the previous feature extraction unit and the corresponding semantic segmentation map, and the corresponding semantic segmentation map is homologous to the semantic segmentation map obtained by the previous feature extraction unit, and the scale is a preset multiple of the semantic segmentation map obtained by the previous feature extraction unit; Each of the feature extraction units extracts features from the first input information according to the similarity information between the objects represented by the respective class labels acquired in advance, and outputs a feature map whose scale is the preset multiple of the scale of the first input information; The conversion unit adjusts each of the feature maps to obtain multiple semantic vectors.
4. The method according to claim 3, characterized in that The step of extracting features from the first input information according to the similarity information between objects represented by the pre-acquired class labels, and outputting a feature map whose scale is the preset multiple of the scale of the first input information, includes: Performing a convolution operation, an activation function operation, a convolution operation, and an upsampling operation of the preset multiple on the first input information in sequence to obtain feature values of various positions of the image corresponding to the first input information; According to the corresponding class labels to which the respective positions belong and the similarity information between the objects represented by the respective class labels, the feature values of the respective positions are adjusted so that the feature values corresponding to the regions with higher similarity are more similar, thereby obtaining the feature map.
5. The method according to claim 3, characterized in that: The step of adjusting each of the feature maps to obtain a plurality of semantic vectors includes: For each of the feature maps, after adjusting the number of channels of the feature map to a preset channel value, the feature map after the adjusted number of channels is normalized to obtain a semantic vector corresponding to the feature map.
6. The method according to claim 5, characterized in that The feature map after adjusting the number of channels is V∈R h ×w×n , where R is a real number, h, w, and n are the width, height, and number of channels of the feature map after adjusting the number of channels, respectively. The feature map after adjusting the number of channels is normalized to obtain a semantic vector corresponding to the feature map, including: Based on the formula Each value of V is processed to normalize each value of V to between 0 and 1, and V∈[0,1] is obtained. h×w×n , so that the corresponding semantic vector V i,j ∈[0,1] n ; Wherein, i, j, and x represent the row number, column number, and channel number of the feature map V after adjusting the number of channels, respectively. i,j,x The feature value representing the feature at the i-th row, j-th column, and x-th channel in the feature map V after adjusting the number of channels, τ is a preset parameter, y is a parameter with a value range of 1 to n and is an integer, and the semantic vector V ij Represents the n-dimensional feature vector corresponding to the i-th row and j-th column in the semantic segmentation map currently being processed.
7. The method according to any one of claims 3 to 6, characterized in that: The number of the feature extraction units is one or more.
8. The method according to claim 1, characterized in that The method is applied to an image synthesis network, wherein the image synthesis network includes a semantic rendering subnetwork; the method obtains a synthesized image by processing the semantic vector and the sampled noise map, including: Inputting the semantic vector and the sampled noise map into the semantic rendering sub-network; According to different values of the semantic vector, the parameters of the residual calculation unit in the semantic rendering sub-network for processing the sampled noise image are adjusted, and the sampled noise image is processed by the residual calculation unit with the adjusted parameters to output the synthesized image.
9. The method according to claim 8, characterized in that The image synthesis network includes a semantic vector generation subnetwork, the semantic vector generation subnetwork includes a feature extraction unit, the semantic rendering subnetwork includes a residual calculation unit, and the feature extraction unit corresponds to the residual calculation unit one by one; The step of inputting the semantic vector and the sampling noise map into the semantic rendering sub-network includes: Each of the residual calculation units obtains second input information, wherein the second input information of each of the residual calculation units includes a semantic vector from a feature extraction unit corresponding thereto, and second output information output by a previous residual calculation unit, and the second input information of the first residual calculation unit also includes a sampling noise map of the same scale as the semantic segmentation map.
10. The method according to claim 8 or 9, characterized in that: The semantic vector is V i,j ∈[0,1] n , representing an n-dimensional feature vector corresponding to the i-th row and j-th column in the semantic segmentation map currently being processed, the residual calculation unit includes a spatial variation convolution subunit and an affine transformation subunit, and adjusting the parameters of the residual calculation unit for processing the sampled noise map in the semantic rendering subnetwork according to different values of the semantic vector, including: For each combination of i and j, obtain the value of V under this combination. ij The n values determined when n is different; Performing a linear weighted summation on the n numerical values and the n pre-saved convolution weights to obtain the parameters of the spatial variation convolution subunit included in the residual calculation unit under the current value combination of i and j; The n numerical values are linearly weighted summed with n pre-saved affine transformation weights to obtain the parameters of the affine transformation sub-unit included in the residual calculation unit under the current combination of values of i and j.
11. The method according to claim 10, characterized in that The residual calculation unit includes a plurality of groups of residual calculation subunits, each group of the residual calculation subunits includes at least one pair of the spatial variation convolution subunits and the affine transformation subunits, and the residual calculation unit after adjusting the parameters processes the sampled noise map, including: After upsampling the processing object by a preset multiple, the processing object is input into each group of the residual calculation subunits included in the residual calculation unit for affine transformation processing and convolution processing to obtain an output result; Performing a matrix addition operation on each of the output results to obtain second output information outputted by itself; Wherein, under the current value combination of i and j, the residual calculation unit processes the area corresponding to the i-th row and j-th column in the processing object; The processing object of the first residual calculation unit is the sampling noise map, and the processing objects of the remaining residual calculation units are the second output information output by the previous residual calculation subunit.
12. An image synthesis device, characterized in that: include: An acquisition module, used to acquire a semantic segmentation map including a plurality of local regions and a sampling noise map of the same scale as the semantic segmentation map, wherein each local region has a class label for characterizing the category to which it belongs; A conversion module, used to convert the semantic segmentation map into a semantic vector related to semantics and appearance according to the similarity information between the objects represented by the various class labels acquired in advance; A synthesis module, used for obtaining a synthesized image by processing the semantic vector and the sampled noise map; Among them, the conversion module is specifically used to obtain the feature value of each position in the semantic segmentation map; according to the corresponding class label to each position and the similarity information between the objects represented by each class label, the feature value of each position is adjusted so that the feature values corresponding to the regions with higher similarity are more similar, and a feature map corresponding to itself is obtained by each adjusted feature value; each feature map is adjusted to obtain multiple semantic vectors.
13. An electronic device, characterized in that: include: A memory and a processor, wherein the memory and the processor are connected; The memory is used to store programs; The processor calls the program stored in the memory to execute the method according to any one of claims 1 to 11.
14. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and when the computer program is executed by a computer, the method according to any one of claims 1 to 11 is executed.
Citation Information
Patent Citations
Semantic segmentation network training method, image semantic segmentation method and devices
CN108537292A
Method and device for establishing cross-domain joint distribution matching model and application thereof
CN108985362A
