# STGAN: Swin Transformer-Based GAN to Achieve Remote Sensing Image Super-Resolution Reconstruction
## 3 Method
### Loss Function  
In order to generate high-quality images, multiple loss functions are usually combined to train the model. These loss functions include: reconstruction loss (L\({}_{\text{rec}}\)) [9], adversarial loss (L\({}_{\text{adv}}\)) [49], and perceptual loss (L\({}_{\text{per}}\)) [50]. Due to the incorporation of gradient features, gradient losses are also used, including gradient reconstruction loss (L\({}_{\text{g.-rec}}\)) and gradient adversarial loss (L\({}_{\text{g.-adv}}\)). The total loss is:  
\[\mathcal{L}_{\text{total}}=\mathcal{L}_{\text{rec}}+\alpha\mathcal{L}_{\text{ per}}+\beta\mathcal{L}_{\text{adv}}+\gamma\mathcal{L}_{\text{g.-rec}}+\delta \mathcal{L}_{\text{g.-adv}} \tag{5}\]  
1. Reconstruction Loss: It is used to measure the similarity between the reconstructed image and the high-resolution image to ensure that the reconstructed image is close  
Figure 6: The input image size is 4 \(\times\) 4 and 4 feature maps are generated after CNN convolution. The magnification is r = 2, i.e., the resolution is increased by two times and the final output image size is 8 \(\times\) 8.  
to the target high-resolution image at the pixel level. The reconstruction loss Lrec is defined as:  
\[\mathcal{L}_{\text{rec}}=\left\|I^{\text{HR}}-I^{\text{SR}}\right\| \tag{6}\]  
where IHR denotes the HR image, ISR denotes the SR image, ISR = G(ILR), G(\(\cdot\)) denotes the generator, and ILR denotes the LR image.
2. Adversarial Loss: The discriminator in the generative adversarial network is used to generate more realistic images, and the generative ability of the model is enhanced by adversarial training. The optimization between generator G and discriminator D1 is as follows:  
\[\mathcal{L}_{\text{adv}}=-\log\Bigl{(}D_{1}(G(I^{\text{LR}}))\Bigr{)} \tag{7}\]  
\[\mathcal{L}_{\text{D1}}=-\log\Bigl{(}D_{1}(I^{\text{HR}})\Bigr{)}-\log\Bigl{(}1 -D_{1}(I^{\text{SR}})\Bigr{)} \tag{8}\]  
where D1 aims to distinguish between the real IHR and generated ISR.
3. Perceptual Loss: By mimicking the properties of the human visual system, a pre-trained network is used to measure the difference in perceptual space between the reconstructed image and the high-resolution image. The perceptual loss Lper is defined as: \[\mathcal{L}_{\text{per}}=\left\|\phi_{i}(I^{\text{HR}})-\phi_{i}(I^{\text{SR} })\right\|\] (9) where \(\phi_{i}(\cdot)\) denotes the layer i output of ResNet-50.
4. Gradient Loss: It is a key component used to maintain the image geometry in super-resolution tasks and ensures the sharpness of image edges and structures by limiting the second-order relationship between neighboring pixels. In the computation process, the gradient loss is obtained by comparing the gradient of a super-resolution image (ISR) with that of a high-resolution image (IHR), i.e., by solving for the difference between neighboring pixels. This includes the gradient reconstruction loss (Lg.rec) and the gradient adversarial loss (Lg.adv), defined as: \[\mathcal{L}_{\text{g\_rec}}=\left\|M(I^{\text{HR}})-M(I^{\text{SR}})\right\|\] (10)  
\[\mathcal{L}_{\text{g\_adv}}=-\log\Bigl{(}D_{2}(G(M(I^{\text{LR}})))\Bigr{)} \tag{11}\]  
\[\mathcal{L}_{D_{2}}=-\log\Bigl{(}D_{2}(M(I^{\text{HR}}))\Bigr{)}-\log\Bigl{(}1 -D_{2}(M(I^{\text{SR}}))\Bigr{)} \tag{12}\]  
where M(\(\cdot\)) denotes the gradient operation and D2 aims to distinguish between the real M (IHR) and generated M (ISR).