Training method of style transfer model and training method of virtual building detection model

The style conversion model is used to perform style conversion and discrimination on virtual images, and introduces adversarial loss and CAM loss, which solves the problem of large differences between virtual images and real images, and significantly improves the realism of virtual images.

CN114077891BActive Publication Date: 2024-10-15BEIJING DAJIA INTERNET INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010788041.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-08-07
Publication Date
2024-10-15
Estimated Expiration
2040-08-07

AI Technical Summary

Technical Problem

In the existing technology, computer-generated virtual images are quite different from real images, resulting in poor realism of virtual images in applications such as building plane detection.

Method used

The style transfer model is used to perform style transfer and discrimination on virtual images through the first generator and discriminator, and adversarial loss and CAM loss are introduced for joint training to improve the realism of virtual images.

Benefits of technology

By introducing CAM loss in the model training process, the style transfer model pays more attention to key areas in the image during the image style conversion and discrimination process, which significantly improves the realism effect of the virtual image and enhances the realism of the virtual image.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114077891B_ABST
    Figure CN114077891B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a training method for a style transfer model and a training method for a virtual building detection model, and belongs to the field of image processing technology. The training method of the style transfer model includes: inputting each sample virtual image and the sample real image into the first generator of the style transfer model to generate a conversion image corresponding to each sample virtual image, and an attention heat map of each sample virtual image and the sample real image; inputting each conversion image and the sample real image into the discriminator of the style transfer model to generate a discrimination result and an attention heat map of each conversion image and the sample real image; generating an adversarial loss value and a class activation mapping loss value according to the discrimination result of the discriminator and each attention heat map; and training the style transfer model according to the sum of the adversarial loss value and the class activation mapping loss value. Thus, the virtual image realization effect of the model is improved, and the realism of the virtual image is enhanced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of image processing technology, and in particular to a training method for a style conversion model, a training method for a virtual building detection model, a device, an electronic device, and a storage medium. Background Art

[0002] With the development and advancement of artificial intelligence technology, computer vision technology based on deep learning is increasingly being used in building plane detection, face recognition, autonomous driving, quality inspection, etc. For example, in building plane detection scenarios, the building plane detection model is usually trained by collecting images of buildings to form a training data set, so that the building plane detection task can be completed more reliably and efficiently through computer vision technology, and mapping and other processing can be performed in the building plane, saving manpower and time costs.

[0003] In related technologies, the effect of deep learning models depends largely on the size and quality of training data sets, so that the model can learn enough features to achieve "learning from one example to apply to other situations", thereby preventing overfitting caused by too little training data. However, in practical applications, it is often impossible to obtain sufficient and high-quality real images as training samples, so data sets can be constructed by generating virtual images instead of real images, but the virtual images generated by computers are quite different from real images. Summary of the invention

[0004] The present disclosure provides a style transfer model training method, a virtual building detection model training method, a device, an electronic device, a storage medium and a computer program product, so as to at least solve the problem in the related art that the virtual image generated by the computer is quite different from the real image. The technical solution of the present disclosure is as follows:

[0005] According to a first aspect of an embodiment of the present disclosure, a training method for a style transfer model is provided, wherein the style transfer model includes a first generator and a discriminator, and the method includes: obtaining a plurality of sample virtual images and a plurality of sample real images to be converted from the sample virtual images; inputting each of the sample virtual images and each of the sample real images into the first generator to generate a conversion image corresponding to each of the sample virtual images after style conversion to the sample real image, as well as a first attention heat map corresponding to each of the sample virtual images and a second attention heat map corresponding to each of the sample real images; inputting each of the conversion images into the discriminator to generate a discrimination result corresponding to each of the conversion images and a third attention heat map; inputting each of the sample real images into the discriminator to generate a discrimination result corresponding to each of the sample real images and a fourth attention heat map; generating an adversarial loss value based on the discrimination result corresponding to each of the conversion images and the discrimination result corresponding to each of the sample real images; generating a first CAM (ClassActivation Mapping, class activation mapping) loss value; generating a second CAM loss value according to each of the third attention heat map and each of the fourth attention heat map; determining a total loss value according to the adversarial loss value, the first CAM loss value and the second CAM loss value; and training the style transfer model according to the total loss value.

[0006] Optionally, in a possible implementation manner of the embodiment of the first aspect of the present disclosure, the style conversion model further includes a second generator, and before determining the total loss value, further includes:

[0007] Inputting each of the converted images into a second generator to restore the converted image and generate a restored image corresponding to each of the converted images;

[0008] Calculating a cycle consistency loss value according to each of the sample virtual images and each of the restored images;

[0009] The determining a total loss value according to the adversarial loss value, the first type activation mapping loss value, and the second type activation mapping loss value comprises:

[0010] The total loss value is determined according to the adversarial loss value, the first CAM loss value, the second CAM loss value and the cycle consistent loss value.

[0011] Optionally, in another possible implementation manner of the embodiment of the first aspect of the present disclosure, before determining the total loss value, the method further includes:

[0012] Calculating a first identity loss value according to each of the sample virtual images and each of the transformed images;

[0013] The determining a total loss value according to the adversarial loss value, the first type activation mapping loss value, and the second type activation mapping loss value comprises:

[0014] The total loss value is determined according to the adversarial loss value, the first CAM loss value, the second CAM loss value, the cycle consistency loss value and the first identity loss value.

[0015] Optionally, in another possible implementation manner of the embodiment of the first aspect of the present disclosure, before determining the total loss value, the method further includes:

[0016] Calculating a second identity loss value according to the converted image and the restored image;

[0017] The determining a total loss value according to the adversarial loss value, the first type activation mapping loss value, and the second type activation mapping loss value comprises:

[0018] The total loss value is determined according to the adversarial loss value, the first CAM loss value, the second CAM loss value, the cycle-consistent loss value, the first identity loss value, and the second identity loss value.

[0019] According to a second aspect of an embodiment of the present disclosure, a training method for a virtual building detection model is provided, comprising: acquiring a plurality of virtual images; performing style conversion on the virtual images using a style conversion model trained according to the training method as described above to generate a conversion image corresponding to each of the virtual images; and training the virtual building detection model according to each of the conversion images.

[0020] Optionally, in a possible implementation manner of the second aspect of the present disclosure, the training of the virtual building detection model according to each of the conversion images includes:

[0021] Segmenting the foreground and background of each virtual image to generate a segmentation map and a background map of each virtual image;

[0022] Segmenting the corresponding conversion image according to the segmentation map of each of the virtual images to extract a foreground image in each of the conversion images; and

[0023] The foreground image of each of the converted images and the background image of the virtual image are fused to generate a training image corresponding to each virtual image, and each of the training images is used to train the virtual building detection model.

[0024] Optionally, in another possible implementation manner of the second aspect of the present disclosure, the training of the virtual building detection model according to each of the conversion images includes:

[0025] Segmenting the foreground and background of each virtual image to extract the foreground image of each virtual image;

[0026] Inputting each of the foreground images into the style transfer model to generate a foreground converted image; and

[0027] Each of the foreground conversion images is fused with the background image of the corresponding virtual image to generate each of the training images, and each of the training images is used to train the virtual building detection model.

[0028] Optionally, in another possible implementation manner of the embodiment of the second aspect of the present disclosure, before using each of the training graphs to train the virtual building detection model, the method further includes:

[0029] Select at least one enhancement method from among the preset enhancement methods; and

[0030] Performing data enhancement on each of the training graphs according to the selected enhancement method to generate a plurality of enhanced training graphs corresponding to each of the training graphs;

[0031] The training of the virtual building detection model comprises:

[0032] The virtual building detection model is trained using each of the enhanced training images.

[0033] Optionally, in another possible implementation of the second aspect of the present disclosure, the preset enhancement method includes a random rotation enhancement method, a color enhancement method or a noise enhancement method.

[0034] Optionally, in another possible implementation manner of the second aspect of the present disclosure, acquiring multiple virtual images includes:

[0035] Generate the shape of the target virtual object;

[0036] Acquire a physical object image corresponding to the target virtual object;

[0037] Acquiring texture data of the physical object from the physical object image; and

[0038] The texture data of the physical object is merged into the shape of the target virtual object to form a plurality of virtual images of the target virtual object.

[0039] Optionally, in another possible implementation manner of the second aspect of the present disclosure, after fusing the texture data of the physical object into the shape of the target virtual object to form a plurality of virtual images of the target virtual object, the method further includes:

[0040] Randomly generate shooting parameters; and

[0041] Each virtual image in the virtual image set is adjusted according to the randomly generated shooting parameters to expand the virtual image of the target virtual object.

[0042] According to a third aspect of an embodiment of the present disclosure, a training device for a style transfer model is provided, wherein the style transfer model includes a first generator and a discriminator, and the device includes: a first acquisition module, configured to execute the step of acquiring a plurality of sample virtual image sets and a plurality of sample real images to be converted from the sample virtual images; a first generation module, configured to execute the step of inputting each of the sample virtual images and each of the sample real images into the first generator to generate a conversion image corresponding to each of the sample virtual images after style conversion to the sample real image, as well as a first attention heat map corresponding to each of the sample virtual images and a second attention heat map corresponding to each of the sample real images; a second generation module, configured to execute the step of inputting each of the conversion images into the discriminator to generate a discrimination result corresponding to each of the conversion images and a third attention heat map; a third generation module, configured to execute the step of inputting each of the conversion images into the discriminator to generate a discrimination result corresponding to the conversion image and a third attention heat map; Each of the sample real images is input into the discriminator to generate a discrimination result corresponding to each of the sample real images and a fourth attention heat map; a fourth generation module is configured to execute the step of generating an adversarial loss value according to the discrimination result corresponding to each of the conversion images and the discrimination result corresponding to each of the sample real images; a fifth generation module is configured to execute the step of generating a first CAM loss value according to each of the first attention heat maps and each of the second attention heat maps; a sixth generation module is configured to execute the step of generating a second CAM loss value according to each of the third attention heat maps and each of the fourth attention heat maps; a first determination module is configured to execute the step of determining a total loss value according to the adversarial loss value, the first CAM loss value and the second CAM loss value; and a first training module is configured to execute the step of training the style transfer model according to the total loss value.

[0043] Optionally, in a possible implementation manner of the embodiment of the third aspect of the present disclosure, the style transfer model further includes a second generator, and the device further includes:

[0044] a seventh generating module, configured to execute the step of inputting each of the converted images into a second generator to restore the converted image and generate a restored image corresponding to each of the converted images;

[0045] A first calculation module is configured to calculate a cycle consistency loss value according to each of the sample virtual images and each of the restored images;

[0046] The first determining module includes:

[0047] The first determining unit is configured to execute the step of determining the total loss value according to the adversarial loss value, the first CAM loss value, the second CAM loss value and the cycle consistent loss value.

[0048] Optionally, in another possible implementation manner of the third aspect of the present disclosure, the device further includes:

[0049] A second calculation module is configured to perform the step of calculating a first identity loss value according to each of the sample virtual images and each of the converted images;

[0050] The first determining module includes:

[0051] The second determining unit is configured to execute the step of determining the total loss value according to the adversarial loss value, the first CAM loss value, the second CAM loss value, the cycle consistency loss value and the first identity loss value.

[0052] Optionally, in another possible implementation manner of the third aspect of the present disclosure, the device further includes:

[0053] A third calculation module is configured to perform a step of calculating a second identity loss value according to the converted image and the restored image;

[0054] The first determining module includes:

[0055] The third determination unit is configured to execute the step of determining the total loss value based on the adversarial loss value, the first CAM loss value, the second CAM loss value, the cycle consistency loss value, the first identity loss value and the second identity loss value.

[0056] According to a fourth aspect of an embodiment of the present disclosure, a training device for a virtual building detection model is provided, comprising: a second acquisition module, configured to execute the step of acquiring multiple virtual images; an eighth generation module, configured to execute the step of performing style conversion on the virtual images by using a style conversion model trained according to the training method as described above to generate a conversion image corresponding to each of the virtual images; and a second training module, configured to execute the step of training the virtual building detection model according to each of the conversion images.

[0057] Optionally, in a possible implementation manner of the fourth aspect of the present disclosure, the device includes:

[0058] a ninth generating module, configured to execute the step of segmenting the foreground and background of each of the virtual images to generate a segmentation map and a background map of each of the virtual images;

[0059] an extraction module configured to perform a step of segmenting the corresponding conversion image according to the segmentation map of each of the virtual images to extract a foreground image in each of the conversion images; and

[0060] a tenth generating module, configured to execute the step of fusing the foreground image of each of the converted images with the background image of the virtual image to generate a training image corresponding to each virtual image;

[0061] The second training module comprises:

[0062] The first training unit is configured to execute and use each of the training images to train the virtual building detection model.

[0063] Optionally, in another possible implementation manner of the fourth aspect of the present disclosure, the tenth generating module includes:

[0064] an extraction unit configured to perform a step of segmenting the foreground and background of each of the virtual images to extract a foreground image of each of the virtual images;

[0065] a first generating unit configured to execute the step of inputting each of the foreground images into the style transfer model to generate a foreground conversion image; and

[0066] A second generating unit is configured to perform a step of fusing each of the foreground conversion images with a background image of a corresponding virtual image to generate each of the training images;

[0067] The second training module comprises:

[0068] The second training unit is configured to execute the step of training the virtual building detection model using each of the training images.

[0069] Optionally, in another possible implementation manner of the fourth aspect of the present disclosure, the device further includes:

[0070] A selection module configured to execute the step of selecting at least one enhancement method from preset enhancement methods; and

[0071] An eleventh generating module is configured to perform a step of performing data enhancement on each of the training graphs according to a selected enhancement method to generate a plurality of enhanced training graphs corresponding to each of the training graphs;

[0072] The second training module comprises:

[0073] The third training unit is configured to execute the step of training the virtual building detection model using each of the enhanced training images.

[0074] Optionally, in another possible implementation method of the fourth aspect of the present disclosure, the preset enhancement method includes a random rotation enhancement method, a color enhancement method or a noise enhancement method.

[0075] Optionally, in another possible implementation manner of the fourth aspect of the present disclosure, the second acquisition module includes:

[0076] A third generating unit is configured to execute the step of generating a shape of a target virtual object;

[0077] A first acquisition unit is configured to execute the step of acquiring a physical object image corresponding to the target virtual object;

[0078] A second acquisition unit is configured to execute the step of acquiring texture data of the physical object from the physical object image; and

[0079] The fusion unit is configured to execute the step of fusing the texture data of the physical object into the shape of the target virtual object to form a plurality of virtual images of the target virtual object.

[0080] Optionally, in another possible implementation manner of the fourth aspect of the present disclosure, the second acquisition module further includes:

[0081] a fourth generating unit configured to randomly generate shooting parameters; and

[0082] The expansion unit is configured to execute the step of adjusting each virtual image in the virtual image set according to the randomly generated shooting parameters to expand the virtual image of the target virtual object.

[0083] According to a fifth aspect of an embodiment of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing instructions executable by the processor; wherein the processor is configured to execute the instructions to implement the training method of the style transfer model or the training method of the virtual building detection model as described above.

[0084] According to a sixth aspect of an embodiment of the present disclosure, a storage medium is provided. When instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the training method of the style transfer model or the training method of the virtual building detection model as described above.

[0085] According to a fifth aspect of an embodiment of the present disclosure, a computer program product is provided. When the computer program is executed by a processor of an electronic device, the electronic device can execute the training method of the style transfer model or the training method of the virtual building detection model as described above.

[0086] The technical solution provided by the embodiments of the present disclosure brings at least the following beneficial effects: by using the first generator of the style conversion model to perform style conversion on multiple sample virtual images to generate a conversion image of each sample virtual image, and generating an attention heat map corresponding to each sample virtual image and each sample real image in the sample real image set, and using the discriminator to discriminate each conversion image and each sample real image, and then generating an adversarial loss value according to the discrimination result, and introducing CAM loss through each attention heat map output by the first generator and the discriminator respectively, so as to jointly train the style conversion model through multiple loss functions. Therefore, by introducing CAM loss in the model training process, the trained style conversion model pays more attention to the key areas in the image during the image style conversion and discrimination process, thereby improving the virtual image reality effect and enhancing the virtual image reality.

[0087] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0088] The drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute improper limitations on the present disclosure.

[0089] Figure 1 The figure is a flowchart of a method for training a style transfer model according to an exemplary embodiment.

[0090] Figure 2 A schematic diagram of the structure of the first generator of a style transfer model.

[0091] Figure 3 A schematic diagram of the structure of the discriminator of a style transfer model.

[0092] Figure 4 The figure is a flowchart of another method for training a style transfer model according to an exemplary embodiment.

[0093] Figure 5 The present invention is a flowchart of a method for training a virtual building detection model according to an exemplary embodiment.

[0094] Figure 6 The present invention is a flowchart of another method for training a virtual building detection model according to an exemplary embodiment.

[0095] Figure 7 The figure is a flowchart of another method for training a virtual building detection model according to an exemplary embodiment.

[0096] Figure 8 The figure is a flowchart of another method for training a virtual building detection model according to an exemplary embodiment.

[0097] Fig. 9 The present invention is a block diagram of a training device for a style transfer model according to an exemplary embodiment.

[0098] Fig.10 The present invention is a block diagram of a training device for a virtual building detection model according to an exemplary embodiment.

[0099] Fig.11 It is a block diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION

[0100] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings.

[0101] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.

[0102] Figure 1is a flowchart of a method for training a style transfer model according to an exemplary embodiment. Figure 1 As shown, the training method of the style transfer model is used in an electronic device and includes the following steps.

[0103] In step 101, a plurality of sample virtual images and a plurality of sample real images to be converted from the sample virtual images are obtained.

[0104] It should be noted that the training method of the style transfer model of the embodiment of the present disclosure can be applied to the scene of realizing virtual images. For example, in the field of computer vision, a large amount of image data is usually required to form a training data set for training deep learning models. However, in practical applications, it is usually difficult to collect a large number of real images to construct a data set. Therefore, the training method of the style transfer model of the embodiment of the present disclosure can be used to train a style transfer model with a better virtual image reality effect, and the trained style transfer model can be used to perform style transfer and other processing on the virtual image to generate a virtual image close to the real image, so as to solve the problem of lack of data sets.

[0105] The sample virtual image may refer to an image generated by any computer software.

[0106] The sample real image may refer to a real scene image acquired by an image acquisition device.

[0107] It should be noted that, in actual use, the sample real image usually has content relevance with the sample virtual image to ensure the training effect of the style transfer model. Specifically, the image content of the sample virtual image and the sample real image may be related to the actual application scenario. For example, if the current application scenario is to animate a face image, the sample virtual image may include a real face image, and the sample real image may be an image of an animated character; for another example, if the current application scenario is to realistically process a virtual building image, the sample virtual image may be a large number of computer-synthesized or drawn building images, and the sample real image may be a large number of real building images captured by an image acquisition device.

[0108] In the embodiments of the present disclosure, a sample virtual image required for a corresponding scene can be generated by computer software according to a specific application scenario; alternatively, an image generated by the computer software can be synthesized with a real image to generate a sample virtual image; alternatively, a real image can be modified and polished using computer software to generate a sample virtual image.

[0109] Accordingly, according to the specific application scenario, the sample real images required for the corresponding scenario can be collected by an image acquisition device; or a large number of sample real images required for the corresponding scenario can be captured from the network.

[0110] For example, if the application scenario of the embodiment of the present disclosure is a virtual building image reality scenario, computer software can be used to create sample virtual images of various buildings; for another example, computer software can be used to generate images of buildings, and then the generated images of buildings are used as foreground images and merged with the background images of real scenes to generate sample virtual images of various buildings. Correspondingly, image acquisition devices such as cameras can also be used to capture images of various buildings from various shooting angles as sample real images.

[0111] In step 102, each sample virtual image and each sample real image are input into a first generator to generate a conversion image corresponding to each sample virtual image after style conversion to the sample real image, as well as a first attention heat map corresponding to each sample virtual image and a second attention heat map corresponding to each sample real image.

[0112] Among them, the style transfer model can be an image generation model based on an adversarial generative network. It should be noted that the first generator of the style transfer model can convert the input image from the original image domain to the target image domain to generate a corresponding image of the input image in the target image domain. For example, if the original image domain is a real face image and the target image domain is an anime-style image, the first generator can convert the input real face image to generate an anime image corresponding to the real face image; for another example, if the original image domain is a real image and the target image domain is an oil painting-style image, the first generator can convert the input real image to generate an oil painting-style image corresponding to the real image.

[0113] In the disclosed embodiment, the original image domain of the style transfer model may be a virtual image, and the target image domain may be a real image. Thus, after each sample virtual image is input into the first generator of the conversion model, the first generator may perform conversion processing on each sample virtual image to generate a corresponding image of each sample virtual image in the target image domain (i.e., the image domain where the sample real image is located), i.e., a conversion image with a style similar to that of the sample real image.

[0114] As a possible implementation method, CAM and adaptive normalization methods can also be integrated into the training process of the style transfer model to further improve the authenticity of the converted image generated by the style transfer model after training. In a possible implementation form of the embodiment of the present disclosure, after a sample virtual image is input into the first generator, the first generator can downsample the sample virtual image to generate a first downsampled image, and then the first generator performs feature extraction on the first downsampled image to generate multiple first feature maps, and obtains the first category weights corresponding to the multiple first feature maps, and then the first generator can generate a first attention heat map corresponding to the sample virtual image according to the first category weights corresponding to the multiple first feature maps, so as to generate a converted image corresponding to the sample virtual image according to the first attention heat map.

[0115] In the embodiments of the present disclosure, Figure 2 As shown in FIG. 1 , a schematic diagram of the structure of the first generator of a style transfer model is shown. Figure 2 It can be seen that after the sample virtual image is input into the first generator of the conversion model, it first passes through the encoder E of the first generator s The downsampling block (211) in (21) downsamples the sample virtual image to generate a first downsampled image corresponding to the sample virtual image, and passes the encoder E s The residual block (212) of (21) performs feature extraction on the first downsampled image to generate an encoder feature map corresponding to the sample virtual image. , ,……, , n is a positive integer greater than 1, that is, the multiple first feature maps corresponding to the sample virtual image are , ,……, Afterwards, the auxiliary classifier η based on CAM is used s The n first category weights w1, w2, ..., w n , for multiple first feature maps , ,……, Perform full connection processing to generate the attention feature map corresponding to the sample virtual image , ,……, ,Right now a 1. a 2,……, a n , so that when the first generator converts the sample virtual image to the target image domain, it pays more attention to the area in the sample virtual image that is significantly different from the target image domain, further improving the authenticity of the converted image. Afterwards, a fully connected layer (23) can be used to convert a1. a 2,……, a n The first attention heat map corresponding to the sample virtual image is added. Then, the decoder (24) in the first generator outputs the first attention heat map and the parameters γ and β according to the fully connected layer, and the adaptive residual block (241) adaptively selects IN (Instance Normalization) or LN (layer norm) to perform style conversion on the sample virtual image according to the first attention heat map, and then the image generated after the style conversion is upsampled by the upsampling block (242) to generate a converted image with the same size as the sample virtual image.

[0116] It should be noted that before performing full connection processing on multiple first feature maps corresponding to the sample virtual image, GAP (Global Average Pooling) processing can also be performed on each first feature map, that is, the average of all pixels in the first feature map is used to replace the first feature map, so that for n first feature maps, an n-dimensional feature vector can be generated, and then the weights in the auxiliary classifier (22) are multiplied with each element in the n-dimensional feature vector to generate the first attention heat map corresponding to the sample virtual image.

[0117] It should be noted that in order to visualize the first attention heat map, it is also possible to determine the attention feature map corresponding to the sample virtual image. a 1. a 2,……, a n Afterwards, the fully connected layer (23) a 1. a 2,……, a n The results are added and upsampled to restore them to the size of the sample virtual image, and then superimposed with the sample virtual image to generate and output an attention heat map corresponding to the sample virtual image, so as to visualize the focus area of ​​the first generator when converting the sample virtual image.

[0118] In the disclosed embodiment, since the sample real image is a target domain image, there is no need to perform style conversion on it. Therefore, after the sample real image is input into the first generator, the second attention heat map corresponding to the sample real image can be generated by only using the first generator, without performing style conversion on the sample real image. It should be noted that the method of generating the second attention heat map corresponding to the sample real image is the same as the method of generating the first attention heat map corresponding to the sample virtual image. The specific implementation method and principle can refer to the detailed description of the above embodiment, which will not be repeated here.

[0119] In step 103, each conversion image is input into a discriminator to generate a discrimination result and a third attention heat map corresponding to each conversion image.

[0120] In the disclosed embodiment, during the style transfer model training process, the first generator can improve its own performance according to the discrimination result of the discriminator, and the discriminator can also continuously improve its own performance in the process of discriminating the image generated by the first generator, so that after generating the conversion image corresponding to each sample virtual image, each conversion image and each sample real image can be input into the discriminator of the style transfer model, so as to train the style transfer model through the discrimination result of the discriminator.

[0121] As a possible implementation method, after a conversion image is input into the discriminator, the discriminator can downsample the conversion image to generate a second downsampled image, and then the discriminator can perform feature extraction on the second downsampled image to generate multiple second feature maps, and obtain the second category weights corresponding to the multiple second feature maps. Then, the discriminator can generate a third attention heat map corresponding to the conversion image according to the second category weights corresponding to the multiple second feature maps, and generate a discrimination result corresponding to the conversion image according to the third attention heat map, that is, the probability that the conversion image is a non-conversion image.

[0122] In the embodiments of the present disclosure, Figure 3 As shown in Figure 1, it is a schematic diagram of the structure of the discriminator of a style transfer model. Figure 3 It can be seen that the conversion image generated by the first generator can be input into the discriminator to make the discriminator determine whether the conversion image is a real image or a conversion image generated by the first generator. After the conversion image is input into the discriminator of the style transfer model, it first passes through the encoder E of the discriminator. Dt The downsampling block (311) in (31) downsamples the converted image to generate a second downsampled image corresponding to the converted image, and passes the encoder E Dt (31) Perform feature extraction on the second downsampled image to generate an encoder feature map corresponding to the converted image , ,……, , n is a positive integer greater than 1, that is, the multiple second feature maps corresponding to the converted image are , ,……, Afterwards, the auxiliary classifier η based on CAM is used Dt The n first category weights w1, w2, ..., w n , for multiple first feature maps , ,……, Perform full connection processing to generate the attention feature map corresponding to the converted image , ,……, ,Right now a 1. a 2,……, a n , so that when the discriminator discriminates the converted image, it pays more attention to the area in the converted image that is significantly different from the target image domain, further improving the discriminator's discrimination accuracy. Afterwards, a fully connected layer can be used to a 1. a 2,……, a n Add them together to generate the third attention heat map corresponding to the converted image. Then, the classifier C in the discriminator Dt (33) Based on the third attention heat map and the activation function (such as the sigmoid activation function), the discrimination result of the converted image is output, that is, the probability that the converted image is a non-converted image (that is, a real image).

[0123] In step 104, each sample real image is input into the discriminator to generate a discrimination result and a fourth attention heat map corresponding to each sample real image.

[0124] It should be noted that after the sample real image is input into the discriminator, the method of generating the discrimination result and the fourth attention heat map corresponding to each sample real image is the same as the method of generating the discrimination result and the third attention heat map corresponding to the conversion image. The specific implementation process and principles can refer to the detailed description of the above embodiment, and will not be repeated here.

[0125] In step 105, an adversarial loss value is generated according to the discrimination result corresponding to each converted image and the discrimination result corresponding to each sample real image.

[0126] In the disclosed embodiment, since the probability that the converted image output by the discriminator is a non-converted image is smaller, the probability that the output sample real image is a non-converted image is greater, indicating that the accuracy of the discriminator is higher, and the authenticity of the converted image generated by the first generator is lower. Therefore, after a large number of converted images and sample real images are input into the discriminator, the value of the preset generative adversarial loss function, i.e., the generative adversarial loss value, can be determined according to the probability that each converted image output by the discriminator is a non-converted image and the probability that each sample real image is a non-converted image.

[0127] Among them, the preset generative adversarial loss function can be expressed by formula (1).

[0128] (1)

[0129] in, is the preset generation adversarial loss function, is the image set consisting of sample real images, is a set of images consisting of sample virtual images, x is the input image, is the discriminator, is the first generator, s is the original image domain (virtual image domain), and t is the target image domain (real image domain).

[0130] In the embodiment of the present disclosure, after determining the discrimination result corresponding to each converted image and the discrimination result corresponding to each sample real image, the discrimination result corresponding to each converted image and the discrimination result corresponding to each sample real image can be substituted into the preset generative adversarial loss function in formula (1) to determine the adversarial loss value.

[0131] In step 106 , a first CAM loss value is generated according to each first attention heat map and each second attention heat map.

[0132] In the disclosed embodiment, during the training of the style transfer model, CAM loss can also be introduced to improve the model's attention to the area that needs attention, and further improve the performance of the style transfer model. Specifically, the value of the preset first CAM loss function can be determined according to the first attention heat map corresponding to each sample virtual image and the second attention heat map corresponding to each sample real image, that is, the first CAM loss value is generated, so as to improve the first generator's attention to the area that needs attention through the first CAM loss value.

[0133] The preset first CAM loss function can be expressed by formula (2).

[0134] (2)

[0135] in, is the preset first CAM loss function, is the image set consisting of sample virtual images and, is an image set consisting of sample real images, x is the input image, is the auxiliary classifier of the generator, s is the original image domain (virtual image domain), and t is the target image domain (real image domain).

[0136] In the embodiment of the present disclosure, after determining the first attention heat map corresponding to each sample virtual image and the second attention heat map corresponding to each sample real image, the first attention heat map corresponding to each sample virtual image and the second attention heat map corresponding to each sample real image can be substituted into the preset first CAM loss function in formula (2) to generate a first CAM loss value.

[0137] In step 107, a second CAM loss value is generated according to each third attention heat map and each fourth attention heat map.

[0138] In the disclosed embodiment, the value of the preset second CAM loss function can be determined based on the third attention heat map corresponding to each converted image and the fourth attention heat map corresponding to each sample real image, that is, the second CAM loss value is generated, so as to improve the discriminator's attention to the area that needs attention through the second CAM loss value.

[0139] The preset second CAM loss function can be expressed by formula (3).

[0140] (3)

[0141] in, is the preset second CAM loss function, is the image set consisting of sample real images, is a set of images consisting of sample virtual images, x is the input image, is the auxiliary classifier of the discriminator, is the first generator, s is the original image domain (virtual image domain), and t is the target image domain (real image domain).

[0142] In the embodiment of the present disclosure, after determining the third attention heat map corresponding to each conversion image and the fourth attention heat map corresponding to each sample real image, the third attention heat map corresponding to each conversion image and the fourth attention heat map corresponding to each sample real image can be substituted into the preset second CAM loss function in formula (3) to generate a second CAM loss value.

[0143] In step 108, a total loss value is determined based on the adversarial loss value, the first CAM loss value, and the second CAM loss value.

[0144] In the embodiment of the present disclosure, the weights corresponding to the adversarial loss value, the first CAM loss value, and the second CAM loss value can be determined according to actual needs and specific application scenarios, and the weighted sum of the adversarial loss value, the first CAM loss value, and the second CAM loss value can be determined as the total loss value of the style transfer model.

[0145] It should be noted that in actual use, the weights corresponding to the various loss values ​​can be determined according to actual needs and specific application scenarios, and the embodiments of the present disclosure do not limit this. For example, the weight of the generated adversarial loss value can be 1, and the weights of the first CAM loss value and the second CAM loss value can be 1000.

[0146] In step 109, the style transfer model is trained according to the total loss value.

[0147] In the disclosed embodiment, since the total loss value can reflect the performance of the style transfer model from multiple aspects, the style transfer model can be iteratively trained according to the total loss value to generate a style transfer model that meets the performance requirements. Specifically, if it is determined that the total loss value is greater than a preset threshold, it can be determined that the performance of the style transfer model does not meet the requirements, and the parameters of the first generator and the discriminator can be updated according to the total loss value to generate an updated style transfer model; then the above training process is repeated using the updated style transfer model until the total loss value of the updated style transfer model is less than or equal to the preset threshold, then it can be determined that the performance of the updated style transfer model meets the requirements, and the training process of the style transfer model can be ended.

[0148] The virtual image conversion method provided in the embodiment of the present disclosure performs style conversion on multiple sample virtual images by using the first generator of the style conversion model to generate a conversion image of each sample virtual image, and generates a first attention heat map corresponding to each sample virtual image and each sample real image in the sample real image set, and uses a discriminator to discriminate each conversion image and each sample real image, and then generates an adversarial loss value according to the discrimination result, and introduces CAM loss through each attention heat map output by the first generator and the discriminator respectively, so as to jointly train the style conversion model through multiple loss functions. Therefore, by introducing CAM loss in the model training process, the trained style conversion model pays more attention to the key areas in the image during the image style conversion and discrimination process, thereby improving the virtual image reality effect and enhancing the virtual image reality.

[0149] In a possible implementation form of the present disclosure, a cycle consistency loss may be introduced during the training process of the style transfer model to alleviate the model collapse problem; and an identity loss may be introduced to prevent the color distribution difference between the conversion image generated by the first generator and the sample virtual image from being too large, so as to further enhance the realism effect of the style transfer model.

[0150] Figure 4 is a flowchart of another method for converting a virtual image according to an exemplary embodiment. Figure 4 As shown, the training method of the style transfer model is used in an electronic device and includes the following steps.

[0151] In step 401, a plurality of sample virtual images and a plurality of sample real images to be converted from the sample virtual images are obtained.

[0152] In step 402, each sample virtual image and each sample real image are input into a first generator to generate a conversion image corresponding to each sample virtual image after style conversion to the sample real image, as well as a first attention heat map corresponding to each sample virtual image and a second attention heat map corresponding to each sample real image.

[0153] In step 403, each conversion image is input into a discriminator to generate a discrimination result and a third attention heat map corresponding to each conversion image.

[0154] In step 404, each sample real image is input into the discriminator to generate a discrimination result and a fourth attention heat map corresponding to each sample real image.

[0155] In step 405, an adversarial loss value is generated according to the discrimination result corresponding to each converted image and the discrimination result corresponding to each sample real image.

[0156] In step 406, a first CAM loss value is generated according to each first attention heat map and each second attention heat map.

[0157] In step 407, a second CAM loss value is generated according to each third attention heat map and each fourth attention heat map.

[0158] The specific implementation process and principle of the above steps 401-407 can be referred to the detailed description of the above embodiment, which will not be repeated here.

[0159] In step 408, each converted image is input to a second generator to restore the converted image and generate a restored image corresponding to each converted image.

[0160] In the embodiment of the present disclosure, the style transfer model may further include a second generator, wherein the second generator may restore the converted image in the target image domain to generate a restored image corresponding to the converted image in the original image domain. It should be noted that the working principle of the second generator is the same as that of the first generator, and the specific implementation process and principle may refer to the detailed description of the above embodiment, which will not be repeated here.

[0161] As a possible implementation method, the first generator can be used to generate a conversion image corresponding to each sample virtual image, and the second generator can be used to generate a restored image corresponding to each conversion image. Then, based on the outputs of the first generator and the second generator, the cycle consistency loss of the style transfer model can be determined to avoid the generator and the discriminator from reconciling with each other and stagnating after finding a certain balance, thereby alleviating the problem of model collapse.

[0162] In step 409, a cycle consistency loss value is calculated based on each sample virtual image and each restored image.

[0163] In the embodiment of the present disclosure, the value of a preset cycle-consistent loss function, that is, the cycle-consistent loss value, can be determined according to the difference between each sample virtual image and the corresponding restored image.

[0164] Among them, the preset cycle-consistent loss function can be expressed by formula (4).

[0165] (4)

[0166] in, is the cycle-consistent loss function, is a set of images consisting of sample virtual images, x is the input image, is the first generator, is the second generator, s is the original image domain (virtual image domain), and t is the target image domain (real image domain).

[0167] In the embodiment of the present disclosure, after determining the restored image corresponding to each converted image, the value of the preset cycle-consistent loss function in formula (4) can be determined according to the difference between each sample virtual image and the corresponding restored image to generate a cycle-consistent loss value.

[0168] In step 410, a total loss value is determined according to the adversarial loss value, the first CAM loss value, the second CAM loss value, and the cycle consistent loss value.

[0169] In the embodiment of the present disclosure, the weights corresponding to the adversarial loss value, the first CAM loss value, the second CAM loss value and the cycle consistency loss value can be determined according to actual needs and specific application scenarios, and the weighted sum of the adversarial loss value, the first CAM loss value, the second CAM loss value and the cycle consistency loss value can be determined as the total loss value of the style transfer model.

[0170] It should be noted that, in actual use, the weights corresponding to the various loss values ​​can be determined according to actual needs and specific application scenarios, and the embodiments of the present disclosure do not limit this. For example, the weight of the generated adversarial loss value can be 1, the weights of the first CAM loss value and the second CAM loss value can be 1000, and the weight of the cycle-consistent loss value can be 10.

[0171] Furthermore, in order to ensure the consistency of the color distribution of the input image and the output image of the generator, identity loss can be introduced in the style transfer model training process. That is, in a possible implementation form of the embodiment of the present application, before the above step 410, it can also include:

[0172] Calculate a first identity loss value based on each sample virtual image and each transformed image;

[0173] Accordingly, the above step 410 may include:

[0174] A total loss value is determined based on the adversarial loss value, the first CAM loss value, the second CAM loss value, the cycle consistency loss value and the first identity loss value.

[0175] In the embodiment of the present disclosure, for the first generator, the value of the preset first identity loss function can be determined according to the difference between each conversion image generated by the first generator and the corresponding sample virtual image, that is, the first identity loss value can be determined to prevent the color distribution difference between the conversion image generated by the generator and the sample virtual image from being too large.

[0176] Among them, the preset first identity loss function can be expressed by formula (5).

[0177] (5)

[0178] in, is the first identity loss function, is a set of images consisting of sample virtual images, x is the input image, is the first generator, s is the original image domain (virtual image domain), and t is the target image domain (real image domain).

[0179] In the embodiment of the present disclosure, after determining the conversion image corresponding to each sample virtual image, the value of the preset first identity loss function in formula (5) can be determined according to the difference between each sample virtual image and the corresponding conversion image to generate a first identity loss value.

[0180] In the disclosed embodiment, after determining the first identity loss value, the weight corresponding to the first identity loss value can be determined according to actual needs and specific application scenarios, and the weighted sum of the adversarial loss value, the first CAM loss value, the second CAM loss value, the cycle consistency loss value and the first identity loss value can be determined as the total loss value of the style transfer model.

[0181] Furthermore, when the second generator is included in the style transfer model, a second identity loss may be introduced to ensure the consistency of color distribution between the input image and the output image of the second generator. That is, in a possible implementation form of the embodiment of the present application, before the above step 410, the following may also be included:

[0182] Calculate a second identity loss value according to the transformed image and the restored image;

[0183] Accordingly, the above step 410 may include:

[0184] A total loss value is determined based on the adversarial loss value, the first CAM loss value, the second CAM loss value, the cycle consistency loss value, the first identity loss value, and the second identity loss value.

[0185] In the embodiment of the present disclosure, for the second generator, the value of the preset second identity loss function can be determined according to the difference between each restored image generated by the second generator and the corresponding converted image, that is, the second identity loss value can be determined to prevent the color distribution difference between the restored image generated by the second generator and the converted image from being too large.

[0186] Among them, the preset second identity loss function can be expressed by formula (6).

[0187] (6)

[0188] in, is the second identity loss function, is a set of images consisting of sample virtual images, x is the input image, is the first generator, is the second generator, s is the original image domain (virtual image domain), and t is the target image domain (real image domain).

[0189] In the embodiment of the present disclosure, after determining the conversion image corresponding to each sample virtual image and the restored image corresponding to each conversion image, the value of the preset second identity loss function in formula (6) can be determined according to the difference between each conversion image and the corresponding restored image to generate a second identity loss value.

[0190] In the disclosed embodiment, after determining the second identity loss value, the weight corresponding to the second identity loss value can be determined according to actual needs and specific application scenarios, and the weighted sum of the adversarial loss value, the first CAM loss value, the second CAM loss value, the cycle consistency loss value, the first identity loss value and the second identity loss value can be determined as the total loss value of the style transfer model.

[0191] It should be noted that, in actual use, the weights corresponding to the various loss values ​​can be determined according to actual needs and specific application scenarios, and the embodiments of the present disclosure do not limit this. For example, the weight of the generated adversarial loss value can be 1, the weights of the first CAM loss value and the second CAM loss value can be 1000, the weight of the cycle-consistent loss value can be 10, and the weights of the first identity loss value and the second identity loss value can be 10.

[0192] In step 411, the style transfer model is trained according to the total loss value.

[0193] The specific implementation process and principle of the above step 411 can refer to the detailed description of the above embodiment, which will not be repeated here.

[0194] The virtual image conversion method provided by the embodiment of the present disclosure performs style conversion on multiple sample virtual images by using the first generator of the style conversion model to generate a conversion image of each sample virtual image, and performs style conversion on each conversion image by using the second generator to generate a restored image corresponding to each conversion image, and then introduces a cycle-consistent loss according to the difference between each sample virtual image and the corresponding restored image, and introduces an identity loss according to the difference between each sample virtual image and the corresponding conversion image and the difference between each conversion image and the corresponding restored image, so as to jointly train the style conversion model through multiple loss functions. Therefore, by introducing the cycle-consistent loss in the model training process, it is avoided that the generator and the discriminator reconcile and stagnate after finding a certain balance, and the model collapse problem is alleviated, and by introducing the identity loss, it is prevented that the color distribution difference between the conversion image generated by the generator and the sample virtual image is too large, thereby further improving the virtual image reality effect and further improving the virtual image reality.

[0195] Figure 5 is a flow chart of a training method for a virtual building detection model according to an exemplary embodiment. Figure 5 As shown, the training method of the virtual building detection model is used in an electronic device and includes the following steps.

[0196] In step 501, a plurality of virtual images are acquired.

[0197] It should be noted that when training a building detection model, it is usually difficult to collect a large number of real images of buildings to construct a training data set. Therefore, the style transfer model training method of the above-mentioned embodiment can be used to train a style transfer model with better virtual image realization effect, and the trained style transfer model can be used to perform style transfer and other processing on the virtual image to generate a virtual image similar to the real image, so as to solve the problem of scarce data sets.

[0198] Here, the virtual image may refer to a building image generated by any computer software.

[0199] In the embodiments of the present disclosure, computer software can be used to create virtual images of various buildings. For example, computer software can be used to generate images of buildings, and then the generated images of buildings are used as foreground images and merged with background images of real scenes to generate virtual images of various buildings.

[0200] In step 502, style conversion is performed on the virtual images using a style conversion model to generate a conversion image corresponding to each virtual image.

[0201] In the disclosed embodiments, style transfer and other conversion operations may be performed on the virtual image to generate a converted image that is close to the real image, thereby reducing the distance between the virtual image and the real image and improving the authenticity of the virtual image.

[0202] As a possible implementation method, each virtual image can be input into a pre-trained style transfer model respectively, so as to utilize the pre-trained style transfer model to perform conversion processing on each virtual image and generate a conversion image corresponding to each virtual image to improve the authenticity of the virtual image.

[0203] In step 503, a virtual building detection model is trained according to each converted image.

[0204] In the disclosed embodiment, after generating a conversion image close to a real image corresponding to each virtual image, each conversion image can be used to form a training sample set to train the initial building detection model. For example, the initial building plane detection model can be trained to generate a building plane detection model that can effectively detect the plane where the building is located based on the building image.

[0205] It should be noted that, in actual use, the type and training method of the trained building detection model can be determined according to the actual application scenario, and the embodiments of the present application do not limit this.

[0206] The training method of the virtual building detection model provided by the embodiment of the present disclosure generates a plurality of virtual images in advance, and transforms each virtual image using a style conversion model to generate a conversion image close to a real image, and then uses each conversion image to form a training data set to train the virtual building detection model. Thus, by generating virtual images through computer technology, and then performing conversion operations such as style transfer on the virtual images, not only the difficulty of collecting real images and the lack of data sets are effectively alleviated, but also the difference between virtual images and real images is reduced, the authenticity of virtual images is improved, and the training effect of the virtual building detection model is guaranteed.

[0207] In a possible implementation form of the present disclosure, in actual applications, whether using image data for model training or for recognition processing of image data, the focus is usually on the foreground elements of the image. Therefore, the authenticity of the foreground elements included in the converted image is more important than the authenticity of the background elements. Therefore, when generating the converted image, the foreground elements and background elements of the virtual image can be processed in different ways to reduce background noise while ensuring the authenticity of the foreground elements.

[0208] Figure 6 is a flowchart of another method for training a virtual building detection model according to an exemplary embodiment. Figure 6 As shown, the training method of the virtual building detection model is used in an electronic device and includes the following steps.

[0209] In step 601, a plurality of virtual images are acquired.

[0210] In step 602, style conversion is performed on the virtual images using a style conversion model to generate a conversion image corresponding to each virtual image.

[0211] The specific implementation process and principle of the above steps 601-602 can be referred to the detailed description of the above embodiment, which will not be repeated here.

[0212] In step 603, foreground and background of each virtual image are segmented to generate a segmentation map and a background map of each virtual image.

[0213] In the embodiments of the present disclosure, in actual applications, whether using image data for model training or performing recognition processing on image data, the foreground elements of the image are usually the main focus, so the authenticity of the foreground elements included in the generated image is more important than the authenticity of the background elements; or, in the case where the background elements in the virtual image are real scene images, if the virtual image is converted as a whole, it is easy to introduce background noise, resulting in reduced authenticity of the background elements, thereby affecting the overall effect of the virtual image conversion. Therefore, in the embodiments of the present disclosure, the virtual image can be recognized, and the virtual foreground image and the virtual background image in the virtual image can be extracted to perform different processing on the virtual foreground image and the virtual background image.

[0214] As a possible implementation method, a foreground extraction algorithm can be used to identify a virtual image to determine a foreground mask corresponding to the virtual image, and then the virtual image is segmented according to the foreground mask corresponding to the virtual image, and then the image area corresponding to the foreground mask is determined as a segmentation map of the virtual image (i.e., the foreground map of the virtual image), and other areas in the virtual image are determined as the background map of the virtual image.

[0215] It should be noted that, in actual use, any cutout algorithm can be used to extract the foreground and background of the virtual image, and the embodiments of the present disclosure do not limit this. For example, the Bayesian cutout algorithm, the closed cutout algorithm, the K nearest neighbor cutout algorithm, the global sampling cutout algorithm, the cutout algorithm based on the convolutional neural network, and so on.

[0216] In step 604, the corresponding conversion image is segmented according to the segmentation map of each virtual image to extract the foreground image in each conversion image.

[0217] In the embodiment of the present disclosure, since the size of the virtual image and its corresponding conversion image are the same, the virtual image and its corresponding conversion image can be aligned to determine the corresponding area of ​​the segmentation map of the virtual image in the conversion image as the foreground image in the conversion image.

[0218] In step 605, the foreground image of each converted image and the background image of the virtual image are fused to generate a training image corresponding to each virtual image.

[0219] In the disclosed embodiment, since the conversion image corresponding to the virtual image is converted and generated by the style conversion model, the foreground image of the conversion image is close to the real image, so the foreground image in the conversion image can be combined with the background image of the virtual image according to the position of the segmentation image in the virtual image to generate a training image close to the real image. Moreover, since the foreground in the training image is the foreground image of the conversion image and the background is the original background in the virtual image, the background noise introduced in the conversion process is reduced, and the authenticity of the training image is further guaranteed.

[0220] In step 606, each training image is used to train the virtual building detection model.

[0221] In the embodiment of the present disclosure, after generating a training image close to a real image corresponding to each virtual image, each training image can be used to form a training sample set to train the building detection model.

[0222] Furthermore, in order to improve the diversity of training data, data enhancement may be performed on the training graph. That is, in a possible implementation form of the embodiment of the present application, before the above step 606, the following may also be included:

[0223] Select at least one enhancement method from among the preset enhancement methods; and

[0224] Performing data augmentation on each training graph according to the selected augmentation method to generate multiple augmented training graphs corresponding to each training graph;

[0225] Accordingly, the above step 606 may further include:

[0226] The virtual building detection model is trained using each augmented training graph.

[0227] Among them, the preset enhancement method may include at least one of a random rotation enhancement method, a color enhancement method or a noise enhancement method.

[0228] In the disclosed embodiment, after the training images are generated, data enhancement can be performed on each training image by one or more preset enhancement methods to improve the distribution diversity of the training data, thereby achieving the purpose of improving the training effect of the virtual building detection model.

[0229] For example, a random rotation enhancement method can be used to randomly rotate the training image to generate multiple enhanced training images of the training image at different angles; or, a color enhancement method can be used to adjust the color distribution of the training image to generate multiple enhanced training images with different color distributions corresponding to the training image; or, a noise enhancement method can be used to add noise such as clouds and fog to the training image to generate multiple enhanced training images with different noise levels corresponding to the training image; or, a combination of multiple enhancement methods can be used to perform data enhancement on the training image, which is not limited to the embodiments of the present disclosure.

[0230] In the embodiment of the present disclosure, after generating the enhanced training graph corresponding to each training graph, each enhanced training graph can be used to form a training sample set to train the building detection model.

[0231] The training method of the virtual building detection model provided by the embodiment of the present disclosure generates multiple virtual images in advance, and uses the style conversion model to convert each virtual image to generate a conversion image close to the real image, and fuses the foreground image in the conversion image with the background image in the corresponding virtual image to generate a training image corresponding to each virtual image, and then uses each training image to form a training data set to train the virtual building detection model. Therefore, when generating the conversion image, the foreground elements and background elements of the virtual image can be processed in different ways, which not only further improves the authenticity of the foreground elements, but also reduces the background noise introduced in the conversion process, thereby further improving the training effect of the virtual building detection model.

[0232] In a possible implementation form of the present disclosure, the style conversion model may be used to perform style conversion only on the foreground elements of the virtual image, so as to reduce background noise introduced in the style conversion process.

[0233] Figure 7 is a flowchart of another method for training a virtual building detection model according to an exemplary embodiment. Figure 7 As shown, the training method of the virtual building detection model is used in an electronic device and includes the following steps.

[0234] In step 701, a plurality of virtual images are acquired.

[0235] The specific implementation process and principle of the above step 701 can be referred to the detailed description of the above embodiment, which will not be repeated here.

[0236] In step 702, foreground and background of each virtual image are segmented to extract a foreground image of each virtual image.

[0237] In the embodiments of the present disclosure, in actual applications, whether using image data for model training or performing recognition processing on image data, the foreground elements of the image are usually the main focus, so the authenticity of the foreground elements included in the generated image is more important than the authenticity of the background elements; or, in the case where the background elements in the virtual image are real scene images, if the virtual image is converted as a whole, it is easy to introduce background noise, resulting in reduced authenticity of the background elements, thereby affecting the overall effect of the virtual image conversion. Therefore, in the embodiments of the present disclosure, the virtual image can be recognized, and the foreground image and background image in the virtual image can be extracted to perform different processing on the foreground image and background image of the virtual image.

[0238] As a possible implementation method, a foreground extraction algorithm can be used to identify a virtual image to determine a foreground mask corresponding to the virtual image, and then the virtual image is segmented according to the foreground mask corresponding to the virtual image, and then the image area corresponding to the foreground mask is determined as the foreground image of the virtual image, and other areas in the virtual image are determined as the background image of the virtual image.

[0239] It should be noted that, in actual use, any cutout algorithm can be used to extract the foreground image and background image of the virtual image, and the disclosed embodiment does not limit this. For example, Bayesian cutout algorithm, closed cutout algorithm, K nearest neighbor cutout algorithm, global sampling cutout algorithm, cutout algorithm based on convolutional neural network, etc.

[0240] In step 703, each foreground image is input into a style transfer model to generate a foreground converted image.

[0241] In the disclosed embodiment, after extracting the foreground image from the virtual image, the foreground image of the virtual image can be input into a trained style transfer model to perform style transfer and other conversion operations on the foreground image of the virtual image to generate a foreground conversion image that is close to the real image, thereby reducing the distance between the foreground image of the virtual image and the real image and improving the authenticity of the generated foreground conversion image.

[0242] In step 704, each foreground conversion image is fused with the background image of the corresponding virtual image to generate each training image.

[0243] In the disclosed embodiment, since the foreground image of the virtual image is converted, the generated foreground conversion image is close to the real image, so the foreground conversion image can be combined with the background image of the virtual image according to the position of the foreground image in the virtual image to generate a training image close to the real image. Moreover, since only the foreground image of the virtual image is converted, the background noise introduced in the conversion process is reduced, and the authenticity of the training image is further guaranteed.

[0244] In step 705, each training image is used to train the virtual building detection model.

[0245] The specific implementation process and principle of the above step 705 can refer to the detailed description of the above embodiment, which will not be repeated here.

[0246] It should be noted that in the embodiments of the present disclosure, after the training images are generated, data enhancement may be performed on the training images in the same manner as in the above embodiments to generate multiple enhanced training images corresponding to each training image, and the enhanced training images may be used to train the virtual building detection model. The specific implementation process and principles may refer to the detailed description of the above embodiments, which will not be repeated here.

[0247] The training method of the virtual building detection model provided by the embodiment of the present disclosure generates a plurality of virtual images in advance, and uses a style conversion model to convert the foreground image in the virtual image to generate a foreground conversion image similar to the real image, and then combines the foreground conversion image with the background image in the virtual image to generate a training image similar to the real image, and then uses each training image to form a training data set to train the virtual building detection model. Therefore, when generating the conversion image, the foreground elements and background elements of the virtual image can be processed in different ways, which not only further improves the authenticity of the foreground elements, but also reduces the background noise introduced in the conversion process, thereby further improving the training effect of the virtual building detection model.

[0248] In a possible implementation form of the present disclosure, a virtual image may be generated by computer technology, and various shooting parameters may be simulated by computer technology to adjust the virtual image, so as to improve the diversity of the generated virtual image.

[0249] Figure 8 is a flowchart of another method for training a virtual building detection model according to an exemplary embodiment. Figure 8 As shown, the training method of the virtual building detection model is used in an electronic device and includes the following steps.

[0250] In step 801 , the shape of a target virtual object is generated.

[0251] The target virtual object may be any type of object determined according to actual needs. For example, if the application scenario of the embodiment of the present disclosure is a building detection model training scenario, the target virtual object may be a building.

[0252] In the embodiments of the present disclosure, the shape image of the target virtual object required for the corresponding scene can be generated by computer software according to the specific application scene. For example, if the application scene of the embodiment of the present disclosure is a building detection model training scene, the computer software can be used to produce the architecture of various buildings, that is, to produce the outline of various buildings, excluding the texture information such as windows and decorations included in the building.

[0253] In step 802, a physical object image corresponding to the target virtual object is obtained.

[0254] The physical object may refer to a real object of the same type as the target virtual object. For example, if the target virtual object is a building, the physical object may be some buildings that actually exist in reality and are similar in shape to the target virtual object.

[0255] In the disclosed embodiment, in order to ensure that the generated virtual image has a certain degree of authenticity, the shape of the generated target virtual object can be filled with the texture data of the real physical object image. Therefore, some physical object images corresponding to the target virtual object can be taken in advance, or the physical object images corresponding to the target virtual object can be obtained from the network.

[0256] In step 803, texture data of the physical object is obtained from the physical object image.

[0257] In the embodiment of the present disclosure, the physical object image can be first processed by a foreground extraction algorithm to extract the area corresponding to the physical object included in the physical object image, and then the texture data of the area corresponding to the physical object can be extracted by using a texture information extraction algorithm to obtain the texture data of the physical object.

[0258] It should be noted that in actual use, a suitable texture information extraction algorithm can be selected according to actual needs and specific application scenarios to extract texture data of physical objects, and the embodiments of the present disclosure do not limit this. For example, a texture extraction algorithm based on a gray level co-occurrence matrix, an autoregressive texture model, a texture extraction algorithm based on a wavelet transform, and so on.

[0259] In step 804 , the texture data of the physical object is merged into the shape of the target virtual object to form a plurality of virtual images of the target virtual object.

[0260] In the disclosed embodiment, after the texture data of the physical object is acquired, the texture data of the physical object can be fused into the shape of the corresponding target virtual object to generate multiple virtual images of the target virtual object containing real texture information. For example, after the texture data of the physical object is fused into the shape of the target virtual object, the generated virtual image can include real detail information such as windows, decorations, billboards, etc. of the target virtual object.

[0261] Furthermore, since the number of virtual images generated by fusing real texture data may be small, or the postures or types of target virtual objects in the virtual images are not rich enough, the generated virtual images can be adjusted by using a computer to simulate various shooting parameters during actual shooting to improve the diversity of the generated virtual images. That is, in a possible implementation form of the embodiment of the present disclosure, after the above step 804, the following may also be included:

[0262] Randomly generate shooting parameters; and

[0263] Each virtual image in the virtual image set is adjusted according to the randomly generated shooting parameters to expand the virtual image of the target virtual object.

[0264] Among them, the shooting parameters may include one or more of the shooting angle, camera field of view, shooting distance, light intensity, and lighting angle. It should be noted that the shooting parameters may include but are not limited to the situations listed above. In actual use, the specific shooting parameters can be determined according to actual needs and specific application scenarios, and the embodiments of the present disclosure do not limit this.

[0265] The shooting angle may include horizontal, downward, upward, etc., or the shooting angle value range and angle step may be preset. For example, the shooting angle value range may be [-90°, 90°], and the angle step is 10°.

[0266] The camera field of view angle can be determined based on the maximum field of view angle that the camera can reach. For example, in a real scene, the field of view angle range of the camera is [32°, 96°], so the value range of the camera field of view angle can be determined as [32°, 96°].

[0267] The shooting distance can be determined according to the distance between the building and the camera when shooting the building in a real scene. For example, in a real shooting scene, in order to ensure that the whole building is captured, the shooting distance is usually 400-1000 meters, so the shooting distance value range can be determined as [400m, 1000m].

[0268] The light intensity may have a value range determined according to the light intensity in various weather conditions and at various times in real scenes.

[0269] The illumination angle may be determined in a range of values ​​according to the illumination angle range of real sunlight. For example, the illumination angle may be randomly distributed in the entire viewing angle of the upper hemisphere to simulate real sunlight.

[0270] In the disclosed embodiment, after determining the parameters included in the shooting parameters and the value range and / or step size corresponding to each parameter according to the shooting conditions of the real scene, each parameter can be randomly changed within its corresponding value range with a certain step size to randomly generate multiple sets of shooting parameters, and each set of shooting parameters is used to adjust the virtual images in the generated virtual image set to generate virtual images corresponding to each set of shooting parameters to simulate the images generated by shooting the target virtual object with each set of shooting parameters, thereby achieving the expansion of the virtual image of the target virtual object and improving the diversity of the virtual image.

[0271] It should be noted that by randomly generating shooting parameters by computer and expanding virtual images, not only the diversity of virtual images can be improved, but also the distribution of virtual images can be made more comprehensive than the distribution of real images actually collected, thereby generating a superset of real images.

[0272] In step 805, style conversion is performed on the virtual images using a style conversion model to generate a conversion image corresponding to each virtual image.

[0273] In step 806, a virtual building detection model is trained according to each converted image.

[0274] The specific implementation process and principle of the above steps 805-806 can refer to the detailed description of the above embodiment, which will not be repeated here.

[0275] The training method of the virtual building detection model provided by the embodiment of the present disclosure combines the shape of the target virtual object generated by computer technology with the texture data of the physical object to generate a virtual image with a certain degree of authenticity, and uses a computer to simulate the shooting process of the real scene, randomly generates shooting parameters, and then adjusts the generated virtual image according to the randomly generated shooting parameters to expand the virtual image of the target virtual object, and then uses the style conversion model to convert the virtual image to generate a conversion image close to the real image, and uses the conversion image to form a training data set to train the building detection model. Thus, the virtual image of the target virtual object is generated by computer technology, and the virtual image is expanded, and then the virtual image is converted by the conversion model. The conversion operation such as style transfer is performed on the virtual image, which not only effectively alleviates the difficulty of collecting real images and the problem of lack of data sets, improves the authenticity of virtual image conversion, but also further improves the diversity of virtual images, thereby further improving the training effect of the building detection model.

[0276] Fig. 9 is a block diagram of a training device for a style transfer model according to an exemplary embodiment. Fig. 9 The device 90 includes a first acquisition module 91, a first generation module 92, a second generation module 93, a third generation module 94, a fourth generation module 95, a fifth generation module 96, a sixth generation module 97, a first determination module 98 and a first training module 99.

[0277] The first acquisition module 91 is configured to execute the steps of acquiring a plurality of sample virtual images and a plurality of sample real images to be converted from the sample virtual images;

[0278] The first generation module 92 is configured to execute the steps of inputting each sample virtual image and each sample real image into the first generator to generate a conversion image corresponding to each sample virtual image after style conversion to the sample real image, and a first attention heat map corresponding to each sample virtual image and a second attention heat map corresponding to each sample real image.

[0279] The second generating module 93 is configured to execute the step of inputting each conversion image into the discriminator to generate a discrimination result and a third attention heat map corresponding to each conversion image;

[0280] The third generating module 94 is configured to execute the step of inputting each sample real image into the discriminator to generate a discrimination result and a fourth attention heat map corresponding to each sample real image;

[0281] The fourth generating module 95 is configured to execute the step of generating an adversarial loss value according to the discrimination result corresponding to each converted image and the discrimination result corresponding to each sample real image;

[0282] The fifth generating module 96 is configured to execute the step of generating a first CAM loss value according to each first attention heat map and each second attention heat map;

[0283] The sixth generating module 97 is configured to execute the step of generating a second CAM loss value according to each third attention heat map and each fourth attention heat map;

[0284] The first determination module 98 is configured to execute the step of determining the total loss value according to the adversarial loss value, the first CAM loss value and the second CAM loss value; and

[0285] The first training module 99 is configured to execute the step of training the style transfer model according to the total loss value.

[0286] In actual use, the style transfer model training device provided in the embodiments of the present disclosure can be configured in any electronic device to execute the aforementioned style transfer model training method.

[0287] The training device of the style transfer model provided by the embodiment of the present disclosure performs style transfer on multiple sample virtual images by using the first generator of the style transfer model to generate a conversion image of each sample virtual image, and generates a first attention heat map corresponding to each sample virtual image and each sample real image in the sample real image set, and uses a discriminator to discriminate each conversion image and each sample real image, and then generates an adversarial loss value according to the discrimination result, and introduces CAM loss through each attention heat map output by the first generator and the discriminator respectively, so as to jointly train the style transfer model through multiple loss functions. Therefore, by introducing CAM loss in the model training process, the trained style transfer model pays more attention to the key areas in the image during the image style conversion and discrimination process, thereby improving the virtual image reality effect and enhancing the virtual image reality.

[0288] In a possible implementation form of the present disclosure, the style conversion model further includes a second generator, and the training device 90 of the style conversion model further includes:

[0289] a seventh generating module, configured to execute the step of inputting each converted image into the second generator to restore the converted image and generate a restored image corresponding to each converted image;

[0290] A first calculation module is configured to calculate a cycle consistency loss value according to each sample virtual image and each restored image;

[0291] Accordingly, the first determining module 98 includes:

[0292] The first determining unit is configured to execute the step of determining the total loss value according to the adversarial loss value, the first CAM loss value, the second CAM loss value and the cycle consistent loss value.

[0293] Furthermore, in another possible implementation form of the present disclosure, the above-mentioned style transfer model training device 90 further includes:

[0294] A second calculation module is configured to perform the step of calculating a first identity loss value based on each sample virtual image and each converted image;

[0295] Accordingly, the first determining module 98 includes:

[0296] The second determining unit is configured to execute the step of determining the total loss value according to the adversarial loss value, the first CAM loss value, the second CAM loss value, the cycle consistent loss value and the first identity loss value.

[0297] Furthermore, in another possible implementation form of the present disclosure, the style transfer model training device 90 further includes:

[0298] A third calculation module is configured to perform a step of calculating a second identity loss value based on the converted image and the restored image;

[0299] Accordingly, the first determining module 98 includes:

[0300] The third determining unit is configured to execute the step of determining the total loss value according to the adversarial loss value, the first CAM loss value, the second CAM loss value, the cycle consistent loss value, the first identity loss value and the second identity loss value.

[0301] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0302] The training device of the style transfer model provided by the embodiment of the present disclosure performs style transfer on multiple sample virtual images by using the first generator of the style transfer model to generate a conversion image of each sample virtual image, and performs style transfer on each conversion image by using the second generator to generate a restored image of each conversion image, and then introduces a cycle-consistent loss according to the difference between each sample virtual image and the corresponding restored image, and introduces an identity loss according to the difference between each sample virtual image and the corresponding conversion image and the difference between each conversion image and the corresponding restored image, so as to jointly train the style transfer model through multiple loss functions. Therefore, by introducing the cycle-consistent loss in the model training process, it is avoided that the generator and the discriminator reconcile and stagnate after finding a certain balance, and the model collapse problem is alleviated, and by introducing the identity loss, it is prevented that the color distribution difference between the conversion image generated by the generator and the sample virtual image is too large, thereby further improving the effect of virtual image realization and further improving the realism of the virtual image.

[0303] Fig.10 FIG. 1 is a block diagram of a training device for a virtual building detection model according to an exemplary embodiment. Fig.10 The device 100 includes a second acquisition module 1001, an eighth generation module 1002 and a second training module 1003.

[0304] The second acquisition module 1001 is configured to execute the step of acquiring a plurality of virtual images;

[0305] The eighth generating module 1002 is configured to execute the step of performing style conversion on the virtual image by using the style conversion model trained according to the training method as described above to generate a conversion image corresponding to each virtual image; and

[0306] The second training module 1003 is configured to execute the step of training the virtual building detection model according to each conversion image.

[0307] In actual use, the training device for the virtual building detection model provided by the embodiment of the present disclosure can be configured in any electronic device to execute the aforementioned training method for the virtual building detection model.

[0308] The training device for the virtual building detection model provided by the embodiment of the present disclosure generates a plurality of virtual images in advance, and transforms each virtual image using a style conversion model to generate a conversion image close to a real image, and then uses each conversion image to form a training data set to train the virtual building detection model. Thus, by generating virtual images through computer technology, and then performing conversion operations such as style transfer on the virtual images, not only the difficulty in collecting real images and the lack of data sets are effectively alleviated, but also the difference between virtual images and real images is reduced, the authenticity of virtual images is improved, and the training effect of the virtual building detection model is guaranteed.

[0309] In a possible implementation form of the present disclosure, the training device 100 for the virtual building detection model further includes:

[0310] A ninth generating module is configured to perform a step of segmenting the foreground and background of each virtual image to generate a segmentation map and a background map of each virtual image;

[0311] an extraction module configured to perform a step of segmenting the corresponding conversion image according to the segmentation map of each virtual image to extract a foreground image in each conversion image; and

[0312] a tenth generating module, configured to execute the step of fusing the foreground image of each conversion image with the background image of the virtual image to generate a training image corresponding to each virtual image;

[0313] Accordingly, the second training module 1003 includes:

[0314] The first training unit is configured to execute the step of training the virtual building detection model using each training image.

[0315] Furthermore, in another possible implementation form of the present disclosure, the tenth generating module 1002 includes:

[0316] an extraction unit configured to perform a step of segmenting the foreground and background of each virtual image to extract a foreground image of each virtual image;

[0317] A first generating unit configured to perform the step of inputting each foreground image into a style transfer model to generate a foreground conversion image; and

[0318] A second generating unit is configured to perform the step of fusing each foreground conversion image with the background image of the corresponding virtual image to generate each training image;

[0319] Accordingly, the second training module 1003 includes:

[0320] The second training unit is configured to execute the step of training the virtual building detection model using each training image.

[0321] Furthermore, in another possible implementation form of the present disclosure, the training device 100 for the virtual building detection model further includes:

[0322] A selection module configured to execute the step of selecting at least one enhancement method from preset enhancement methods; and

[0323] an eleventh generating module, configured to perform a step of performing data enhancement on each training graph according to the selected enhancement method to generate a plurality of enhanced training graphs corresponding to each training graph;

[0324] Accordingly, the second training module 1003 includes:

[0325] The third training unit is configured to execute the step of training the virtual building detection model using each enhanced training image.

[0326] Furthermore, in another possible implementation form of the present disclosure, the preset enhancement method includes a random rotation enhancement method, a color enhancement method or a noise enhancement method.

[0327] Furthermore, in another possible implementation form of the present disclosure, the second acquisition module 1001 includes:

[0328] A third generating unit is configured to execute the step of generating a shape of a target virtual object;

[0329] A first acquisition unit is configured to execute the step of acquiring a physical object image corresponding to a target virtual object;

[0330] A second acquisition unit is configured to execute the step of acquiring texture data of the physical object from the physical object image; and

[0331] The fusion unit is configured to perform the step of fusing the texture data of the physical object into the shape of the target virtual object to form a plurality of virtual images of the target virtual object.

[0332] Furthermore, in another possible implementation form of the present disclosure, the second acquisition module 1001 further includes:

[0333] a fourth generating unit configured to randomly generate shooting parameters; and

[0334] The expansion unit is configured to execute the step of adjusting each virtual image in the virtual image set according to the randomly generated shooting parameters to expand the virtual image of the target virtual object.

[0335] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0336] The training device for the virtual building detection model provided by the embodiment of the present disclosure generates a plurality of virtual images in advance, and uses a style conversion model to convert the foreground image in the virtual image to generate a foreground conversion image similar to the real image, and then combines the foreground conversion image with the background image in the virtual image to generate a training image similar to the real image, and then uses each training image to form a training data set to train the virtual building detection model. Therefore, when generating the conversion image, the foreground elements and background elements of the virtual image can be processed in different ways, which not only further improves the authenticity of the foreground elements, but also reduces the background noise introduced in the conversion process, thereby further improving the training effect of the virtual building detection model.

[0337] Fig.11 It is a block diagram of an electronic device 200 for training a style conversion model and a virtual building detection model according to an exemplary embodiment.

[0338] like Fig.11 As shown, the electronic device 200 includes:

[0339] The memory 210 and the processor 220, and the bus 230 connecting different components (including the memory 210 and the processor 220), the memory 210 stores a computer program, and when the processor 220 executes the program, the style conversion model training method or the virtual building detection model training method described in the embodiments of the present disclosure is implemented.

[0340] Bus 230 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor or a local bus using any of a variety of bus architectures. For example, these architectures include but are not limited to Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MAC) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus and Peripheral Component Interconnect (PCI) bus.

[0341] The electronic device 200 typically includes a variety of electronic device readable media. These media can be any available media that can be accessed by the electronic device 200, including volatile and non-volatile media, removable and non-removable media.

[0342] The memory 210 may also include computer system readable media in the form of volatile memory, such as random access memory (RAM) 240 and / or cache memory 250. The electronic device 200 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 260 may be used to read and write non-removable, non-volatile magnetic media ( Fig.11 not shown, usually called a "hard drive"). Although Fig.11 Not shown in the figure, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, a DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to the bus 230 via one or more data medium interfaces. The memory 210 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the various embodiments of the present disclosure.

[0343] A program / utility 280 having a set (at least one) of program modules 270 may be stored, for example, in the memory 210, such program modules 270 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which or some combination thereof may include an implementation of a network environment. The program modules 270 generally perform the functions and / or methods of the embodiments described in the present disclosure.

[0344] The electronic device 200 can also communicate with one or more external devices 290 (e.g., keyboard, pointing device, display 291, etc.), and can also communicate with one or more devices that enable users to interact with the electronic device 200, and / or communicate with any device that enables the electronic device 200 to communicate with one or more other computing devices (e.g., network card, modem, etc.). This communication can be carried out through an input / output (I / O) interface 292. In addition, the electronic device 200 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN) and / or public network, such as the Internet) through a network adapter 293. As shown in the figure, the network adapter 293 communicates with other modules of the electronic device 200 through a bus 230. It should be understood that, although not shown in the figure, other hardware and / or software modules can be used in conjunction with the electronic device 200, including but not limited to: microcode, device driver, redundant processing unit, external disk drive array, RAID system, tape drive, and data backup storage system, etc.

[0345] The processor 220 executes various functional applications and data processing by running the programs stored in the memory 210 .

[0346] It should be noted that the implementation process and technical principles of the electronic device of this embodiment refer to the aforementioned explanation of the style conversion model training method or the virtual building detection model training method of the embodiment of the present disclosure, and will not be repeated here.

[0347] The electronic device provided by the embodiment of the present disclosure can execute the style conversion model training method or the virtual building detection model training method as described above, by using the first generator of the style conversion model to perform style conversion on multiple sample virtual images to generate a conversion image of each sample virtual image, and generate a first attention heat map corresponding to each sample virtual image and each sample real image in the sample real image set, and use a discriminator to discriminate each conversion image and each sample real image, and then generate an adversarial loss value according to the discrimination result, and introduce CAM loss through each attention heat map output by the first generator and the discriminator respectively, so as to jointly train the style conversion model through multiple loss functions. Therefore, by introducing CAM loss in the model training process, the trained style conversion model pays more attention to the key areas in the image during the image style conversion and discrimination process, thereby improving the virtual image reality effect and enhancing the virtual image reality.

[0348] In order to implement the above embodiments, the present disclosure also proposes a storage medium.

[0349] When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the style conversion model training method or the virtual building detection model training method as described above.

[0350] In order to implement the above embodiments, the present disclosure also provides a computer program product. When the computer program is executed by a processor of an electronic device, the electronic device can execute the style conversion model training method or the virtual building detection model training method as described above.

[0351] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be considered exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.

[0352] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims

1. A training method for a style transfer model, characterized in that: The style conversion model includes a first generator and a discriminator, and the method includes: Acquire a plurality of sample virtual images and a plurality of sample real images to be converted from the sample virtual images; Inputting each of the sample virtual images and each of the sample real images into the first generator to generate a conversion image corresponding to each of the sample virtual images after style conversion to the sample real image, as well as a first attention heat map corresponding to each of the sample virtual images and a second attention heat map corresponding to each of the sample real images; Inputting each of the conversion images into the discriminator to generate a discrimination result and a third attention heat map corresponding to each of the conversion images; Inputting each of the sample real images into the discriminator to generate a discrimination result and a fourth attention heat map corresponding to each of the sample real images; Generate an adversarial loss value according to the discrimination result corresponding to each of the converted images and the discrimination result corresponding to each of the sample real images; Generate a first type activation map loss value according to each of the first attention heat maps and each of the second attention heat maps; Generating a second type of activation mapping loss value according to each of the third attention heat maps and each of the fourth attention heat maps; Determining a total loss value based on the adversarial loss value, the first type activation map loss value, and the second type activation map loss value; and The style transfer model is trained according to the total loss value.

2. The method for training a style transfer model according to claim 1, wherein: The style conversion model further includes a second generator, and before determining the total loss value, further includes: Inputting each of the converted images into a second generator to restore the converted image and generate a restored image corresponding to each of the converted images; Calculating a cycle consistency loss value according to each of the sample virtual images and each of the restored images; The determining a total loss value according to the adversarial loss value, the first type activation mapping loss value, and the second type activation mapping loss value includes: The total loss value is determined according to the adversarial loss value, the first type activation mapping loss value, the second type activation mapping loss value and the cycle consistency loss value.

3. The method for training a style transfer model according to claim 2, wherein: Before determining the total loss value, the method further includes: Calculating a first identity loss value according to each of the sample virtual images and each of the transformed images; The determining a total loss value according to the adversarial loss value, the first type activation mapping loss value, and the second type activation mapping loss value comprises: The total loss value is determined according to the adversarial loss value, the first type activation mapping loss value, the second type activation mapping loss value, the cycle consistency loss value and the first identity loss value.

4. The method for training a style transfer model according to claim 3, wherein: Before determining the total loss value, the method further includes: Calculating a second identity loss value according to the converted image and the restored image; The determining a total loss value according to the adversarial loss value, the first type activation mapping loss value, and the second type activation mapping loss value comprises: The total loss value is determined according to the adversarial loss value, the first type activation mapping loss value, the second type activation mapping loss value, the cycle consistency loss value, the first identity loss value and the second identity loss value.

5. A training method for a virtual building detection model, characterized in that: The following steps are involved: acquiring a plurality of virtual images; Performing style conversion on the virtual images by using a style conversion model trained according to any one of the training methods of claims 1 to 4, so as to generate a conversion image corresponding to each of the virtual images; as well as The virtual building detection model is trained according to each of the converted images.

6. The training method of a virtual building detection model according to claim 5, characterized in that: After performing style conversion on the virtual image by using the style conversion model trained according to any one of the training methods of claims 1 to 4 to generate a conversion image, the method further includes: Segmenting the foreground and background of each virtual image to generate a segmentation map and a background map of each virtual image; Segmenting the corresponding conversion image according to the segmentation map of each of the virtual images to extract a foreground image in each of the conversion images; and Fusing the foreground image of each of the converted images with the background image of the virtual image to generate a training image corresponding to each virtual image; The training of the virtual building detection model comprises: The virtual building detection model is trained using each of the training images.

7. The training method of a virtual building detection model according to claim 6, characterized in that: The method of performing style conversion on the virtual image to generate a converted image by using a style conversion model trained according to any one of the training methods of claims 1 to 4 comprises: Segmenting the foreground and background of each virtual image to extract the foreground image of each virtual image; Inputting each of the foreground images into the style transfer model to generate a foreground converted image; and Fusing each of the foreground conversion images with the background image of the corresponding virtual image to generate each of the training images; The training of the virtual building detection model comprises: The virtual building detection model is trained using each of the training images.

8. The training method for a virtual building detection model according to claim 6 or 7, characterized in that: Before using each of the training graphs to train the virtual building detection model, the method further includes: Select at least one enhancement method from among the preset enhancement methods; and Performing data enhancement on each of the training graphs according to the selected enhancement method to generate a plurality of enhanced training graphs corresponding to each of the training graphs; The training of the virtual building detection model comprises: The virtual building detection model is trained using each of the enhanced training images.

9. The training method of a virtual building detection model according to claim 8, characterized in that: The preset enhancement mode includes a random rotation enhancement mode, a color enhancement mode or a noise enhancement mode.

10. The training method of a virtual building detection model according to claim 5, characterized in that: The obtaining of multiple virtual images comprises: Generate the shape of the target virtual object; Acquire a physical object image corresponding to the target virtual object; Acquiring texture data of the physical object from the physical object image; and The texture data of the physical object is merged into the shape of the target virtual object to form a plurality of virtual images of the target virtual object.

11. The training method for a virtual building detection model according to claim 10, characterized in that: After fusing the texture data of the physical object into the shape of the target virtual object to form a plurality of virtual images of the target virtual object, the method further includes: Randomly generate shooting parameters; and Each virtual image in the virtual image set is adjusted according to the randomly generated shooting parameters to expand the virtual image of the target virtual object.

12. A training device for a style transfer model, characterized in that: The style conversion model includes a first generator and a discriminator, and the device includes: A first acquisition module is configured to execute the steps of acquiring a plurality of sample virtual images and a plurality of sample real images to be converted from the sample virtual images; A first generating module is configured to execute the step of inputting each of the sample virtual images and each of the sample real images into the first generator to generate a conversion image corresponding to each of the sample virtual images after style conversion is performed on the sample real image, and a first attention heat map corresponding to each of the sample virtual images and a second attention heat map corresponding to each of the sample real images; A second generating module is configured to execute the step of inputting each of the conversion images into the discriminator to generate a discrimination result and a third attention heat map corresponding to each of the conversion images; A third generating module is configured to execute the step of inputting each of the sample real images into the discriminator to generate a discrimination result and a fourth attention heat map corresponding to each of the sample real images; A fourth generating module is configured to execute the step of generating an adversarial loss value according to a discrimination result corresponding to each of the converted images and a discrimination result corresponding to each of the sample real images; a fifth generating module, configured to execute the step of generating a first type of activation map loss value according to each of the first attention heat maps and each of the second attention heat maps; a sixth generating module, configured to execute the step of generating a second type of activation map loss value according to each of the third attention heat maps and each of the fourth attention heat maps; A first determining module is configured to perform a step of determining a total loss value according to the adversarial loss value, the first type activation mapping loss value, and the second type activation mapping loss value; and The first training module is configured to execute the step of training the style transfer model according to the total loss value.

13. The training device for a style transfer model according to claim 12, wherein: The style conversion model further includes a second generator, and the device further includes: a seventh generating module, configured to execute the step of inputting each of the converted images into a second generator to restore the converted image and generate a restored image corresponding to each of the converted images; A first calculation module is configured to calculate a cycle consistency loss value according to each of the sample virtual images and each of the restored images; The first determining module includes: The first determining unit is configured to execute the step of determining the total loss value according to the adversarial loss value, the first type activation mapping loss value, the second type activation mapping loss value and the cycle consistency loss value.

14. The training device for a style transfer model according to claim 13, wherein: Also includes: A second calculation module is configured to perform the step of calculating a first identity loss value according to each of the sample virtual images and each of the converted images; The first determining module includes: The second determining unit is configured to execute the step of determining the total loss value according to the adversarial loss value, the first type activation mapping loss value, the second type activation mapping loss value, the cycle consistency loss value and the first identity loss value.

15. The training device for a style transfer model according to claim 14, characterized in that: Also includes: A third calculation module is configured to perform a step of calculating a second identity loss value according to the converted image and the restored image; The first determining module includes: The third determination unit is configured to execute the step of determining the total loss value based on the adversarial loss value, the first type activation mapping loss value, the second type activation mapping loss value, the cycle consistency loss value, the first identity loss value and the second identity loss value.

16. A training device for a virtual building inspection model, characterized in that: include: A second acquisition module is configured to execute the step of acquiring a plurality of virtual images; an eighth generating module, configured to execute the step of performing style conversion on the virtual image by using the style conversion model trained according to any one of the training methods of claims 1 to 4, so as to generate a conversion image corresponding to each of the virtual images; as well as The second training module is configured to execute the step of training the virtual building detection model according to each of the converted images.

17. The training device for a virtual building detection model according to claim 16, characterized in that: Also includes: a ninth generating module, configured to execute the step of segmenting the foreground and background of each of the virtual images to generate a segmentation map and a background map of each of the virtual images; An extraction module is configured to perform a step of segmenting the corresponding conversion image according to the segmentation map of each of the virtual images to extract a foreground image in each of the conversion images; as well as a tenth generating module, configured to execute the step of fusing the foreground image of each of the converted images with the background image of the virtual image to generate a training image corresponding to each virtual image; The second training module comprises: The first training unit is configured to execute the step of training the virtual building detection model using each of the training images.

18. The training device for a virtual building detection model according to claim 17, characterized in that: The tenth generation module comprises: an extraction unit configured to perform a step of segmenting the foreground and background of each of the virtual images to extract a foreground image of each of the virtual images; a first generating unit configured to execute the step of inputting each of the foreground images into the style transfer model to generate a foreground conversion image; and A second generating unit is configured to perform a step of fusing each of the foreground conversion images with a background image of a corresponding virtual image to generate each of the training images; The second training module comprises: The second training unit is configured to execute the step of training the virtual building detection model using each of the training images.

19. The training device for a virtual building inspection model according to claim 17 or 18, characterized in that: Also includes: A selection module is configured to execute the step of selecting at least one enhancement method from preset enhancement methods; as well as An eleventh generating module is configured to perform a step of performing data enhancement on each of the training graphs according to a selected enhancement method to generate a plurality of enhanced training graphs corresponding to each of the training graphs; The second training module comprises: The third training unit is configured to execute the step of training the virtual building detection model using each of the enhanced training images.

20. The training device for a virtual building detection model according to claim 19, characterized in that: The preset enhancement mode includes a random rotation enhancement mode, a color enhancement mode or a noise enhancement mode.

21. The training device for a virtual building inspection model according to claim 16, characterized in that: The second acquisition module includes: A third generating unit is configured to execute the step of generating a shape of a target virtual object; A first acquisition unit is configured to execute the step of acquiring a physical object image corresponding to the target virtual object; A second acquisition unit is configured to execute the step of acquiring texture data of the physical object from the physical object image; and The fusion unit is configured to execute the step of fusing the texture data of the physical object into the shape of the target virtual object to form a plurality of virtual images of the target virtual object.

22. The training device for a virtual building detection model according to claim 21, characterized in that: The second acquisition module further includes: a fourth generating unit configured to randomly generate shooting parameters; and The expansion unit is configured to execute the step of adjusting each virtual image in the virtual image set according to the randomly generated shooting parameters to expand the virtual image of the target virtual object.

23. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the training method of the style conversion model as described in any one of claims 1-4 or the training method of the virtual building detection model as described in any one of claims 5-11.

24. A storage medium, when the instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to execute the training method of the style transfer model as described in any one of claims 1 to 4 or the training method of the virtual building detection model as described in any one of claims 5 to 11.