4.2. Training Model
Combining real imaging log images from a total of eight horizontal wells in the Daqing and Dagang Oilfields, a dataset of imaging log images with mask regions and corresponding mask binary images was created after data pre-processing. The dataset was divided into a training set (20,000 images), a validation set (2500 images), and a test set (2500 images) according to a ratio of 8:1:1.
The improved GAN network model for imaging logging image restoration experiments was implemented using a 64-bit Windows 10 operating system, the Python 3.7 programming language, torch 1.9 (cuda11) and torchvision 0.10.0, and a 16G NVIDIA GeForce GTX 1650Ti graphics card (NVIDIA, Santa Clara, CA, USA) to speed up the training process. The initial learning rate of the repair network was set to 0.0005, the initial learning rate of the discriminative network was set to 0.00001, and the number of training rounds was set to 200 epochs. The training flow of the improved GAN model algorithm is shown in Algorithm 2.
Algorithm 2: Improved GAN model algorithm training process |
1. set the number of training rounds e, the total amount of training data n and batc size b |
2. for i = 1 to e do: |
3. for j = 1 to n/b do: |
4. inputting a single batch of b defective images and the corresponding mask images into the generative network |
5. training of generative networks: |
6. calculation of content loss Lv and Lh, perceptual loss Lprep, windage loss Ls; |
7. updating the G-weight parameters of the generating network using the four loss functions Lh, Lv, Lprep and Ls training |
8. training discriminative networks |
9. input of the restored b images and the original images into the discriminatory network; |
10. comparing the restored image with the real image and calculating the adversarial loss Ladv; |
11. update the weight parameters of the global discriminant network Dg and the local discriminant network Dl with Ladv |
12. improved overall GAN |
13. joint training of the generative and discriminative networks using the total loss function L |
14. end |
15. end |
During the training of the model, the generative network is trained to repair the image to fool the discriminator network, and the global and local discriminators are trained to identify whether the input image is repaired by the generative network or is the real one. First, the pre-processing stage generates a defective image and corresponding mask image that matches the real imaging logging image defect; it sets the number of training rounds e, the total training data volume n, and the batch processing volume b; then the model iterates through round e, updating the parameters in each round with n/b cycles. In each cycle, the training is optimised in three steps. (I) Calculate content loss Lh and Lv, perceptual loss Lprep, and style loss Lstyle, and use them to update the weight parameters of the generative network through back-propagation training. (II) Fix the parameters of the generative network, obtain the adversarial loss based on the error between the restored image and the original image, and update the weight parameters of the global and local discriminative networks by training with the adversarial loss alone. (III) Train the overall model built in this paper using the total loss function. This is conducted for several iterations of updates until the network stabilises and the final model is obtained.
4.3. Loss Function
The overall performance of the imaging logging image restoration model is not only dependent on the network structure, but the selection of the loss function is also critical. During model training, the aim is to use the loss function values as feedback to drive the model to convergence, so the model training goal is to minimise the loss function values. In order to better restore the texture details and semantic structure of the imaging logging images, this paper uses a combination of content loss, perceptual loss, style loss, and adversarial loss to train an improved GAN model.
In this paper, we use a combination of content loss, perceptual loss, stylistic loss, and adversarial loss as a loss function for image restoration, mainly to combine different types of information in order to improve the effectiveness of image restoration. For this, a pixel-level difference metric is used to measure the similarity between the restored image and the original image. By minimising content loss, the restored image can more closely resemble the original image, retaining more of the original detail and structure. Perceptual loss uses a pre-trained deep learning model (VGG network) to extract high-level features of the image, which are used to compare the perceptual differences between the restored image and the original image. Perceptual loss can help ensure that the restored image is more perceptually realistic and avoids generating false details. Style loss is used to compare the restored image with the original image in terms of style. By minimising style loss, the restored image retains the texture and style of the original image, increasing visual consistency. Adversarial loss introduces the concept of an adversarial generative network in which the generator tries to deceive the discriminator, which in turn tries to distinguish between the real image and the generated image. By minimising adversarial loss, the restored image can be more realistic and have higher visual quality. Combining these different types of loss functions can enable image restoration models to produce more realistic and natural-looking restoration results while maintaining structural and content realism. Each loss function is described below.
Content loss: Content loss consists of the loss of intact regions
Lv and the loss of missing regions
Lh. Since
L1 loss ignores the structural correlation between missing and undamaged regions, multi-scale structural similarity MS-SSIM [
23] is used to better preserve the contrast of information in high frequency regions of the image. The content loss consists of
L1 loss and MS-SSIM, which is calculated as shown in the equation below:
where
Min represents the mask region, ⊙ denotes the Hadamad product,
MSM denotes MS-SSIM (the formula can be found in Equation (16)),
Ig denotes the image generated by the generative network,
It denotes the real image, and the constant
a is used to balance the MS-SSIM loss and the
L1 loss, with a value defined empirically as 0.5 in the model.
Perceptual loss: Perceptual loss is introduced in order to give the generated image a higher level of structural similarity to the real image, rather than just making the generated image a pixel match to the real image. Perceptual loss can be used to obtain a higher level of structural information using convolutional layers to perceive images from higher latitudes closer to the level of human visual effects. This paper introduces the perceptual loss defined on a VGG16 network pre-trained on ImageNet, which is calculated as follows:
where
N denotes the image size and
Fi(·) denotes the feature map of the ith pooling layer.
Style loss: Style loss is a loss function that measures the similarity in style between two images and is used to guide the learning of image restoration so that the generated content has a detailed local texture [
24]. The style loss pass is calculated based on the Gram Matrix between the features of the image at different levels in the feature extractor, which measures the difference between the original image and the restored image at different levels of features. An analysis of the feature map shows that the values at each position on the feature map are calculated using the convolution layer for a fixed position on the image, while for the positions in the Gram Matrix, the values are obtained by inner-producing the two feature maps. The Gram Matrix therefore provides a good representation of the style of the image by showing the correlation between two features, such as which two features appear at the same time and which two features are swapped. Assuming that the size of the Fi feature map is
Hi ×
Wi ×
Ci, the style loss can be defined as the following equation.
Adversarial loss: Adversarial loss has been widely used in image generation and low-level vision to improve the visual quality of generated images. Therefore, in order to better learn the data distribution of real images, the parameters of the generative and discriminative networks are continuously iteratively updated through adversarial training between the generative network and the global and local discriminative networks to improve the visual performance of the restored images. The adversarial loss in this paper sets the adversarial loss
Lglobal for the global discriminant network and
Llocal for the local discriminant network, and weighs the bias of the two using a constant factor. The calculation formula is shown below:
where the global adversarial loss
Lglobal and the local adversarial loss
Llocal are calculated as shown below.
In the above equation, the image to be repaired is represented by the Iin, the Dg represents the complete image input into the global discriminative network, and the Dm represents the image with missing regions input into the local discriminative network.
Total loss: Based on the above loss function, the total loss function of the model can be expressed by the following equation.
In the above equation, the parameters λ1, λ2, λ3, λ4, and λ5 are not fixed values and need to be determined based on experimental tests. This paper sets them empirically as follows: λ1 = 1.0, λ2 = 3.0, λ3 = 0.02, λ4 = 120, and λ5 = 0.1.
In this paper, we design a model of an imaging logging image restoration algorithm based on improved GAN and introduce different types of loss functions to guide the model training. Among them, λ4 = 120 is the weight used for style loss, while other loss functions (e.g., content loss, perceptual loss, and adversarial loss) are set with relatively small weights. Such a setting is the result of several experimental validations and aims to better balance the impact of different loss functions in model training. The larger weight of λ4 = 120 is set out to emphasise the importance of the style loss. In the imaging logging image restoration task, texture details play a key role in image quality. By setting λ4 to a larger value, the model pays more attention to maintaining the style of the image during the training process, which makes the restored image closer to the real image in terms of texture, and thus improves the fidelity and visual quality of the restoration effect. The weights of the other loss functions are set smaller, but they still play a key role in the model. Content loss and perceptual loss help maintain the consistency of the generated image with the real image in terms of content and structure, while adversarial loss promotes the model to generate more realistic images. By appropriately balancing the weights of these loss functions, we ensure that the whole model is able to synthesise different types of information and achieve better performance in the restoration task.
In summary, the setting of λ4 = 120 is to emphasise the importance of style loss in image restoration, while the smaller weights of the other loss functions help to maintain the balance and stability of the model. With such a loss function weight setting, the model achieves satisfactory results in the imaging logging image restoration task.