# Fast Fourier Asymmetric Context Aggregation Network:
## 3 Proposed Method
### Loss Functions  
Due to the complexity of apparel content, training the generative model presents certain challenges. Based on [56; 58; 61], we employ adversarial loss \(\mathcal{L}_{a}\) based on PatchGAN [67], perceptual loss \(\mathcal{L}_{p}\) based on VGG [68], style loss \(\mathcal{L}_{s}\) based on Gram matrices [69], and pixel-level loss \(\mathcal{L}_{m}\) to jointly train FCAN. The pixel-level loss \(\mathcal{L}_{m}\) guides the network to learn the underlying data distribution, enabling it to acquire fundamental image synthesis capabilities. Its specific computation is given by  
\[\mathcal{L}_{m}=\big{|}C_{ori}-C_{gen}\big{|}, \tag{18}\]  
where \(C_{\text{ori}}\) and \(C_{gen}\) represent the real image and the generated image, respectively. The pixel-level reconstruction loss based on Absolute Value Error cannot accurately guide the network to reconstruct apparel content as the style information provided by texture patches is limited. Thus, relying solely on \(\mathcal{L}_{m}\) may lead the network to generate unrealistic content in challenging regions of the garment. It is important to note that the goal of our task is not to fully replicate the exact apparel content but rather to generate apparel images that are semantically consistent with the guiding information and contextually reasonable. To achieve this, we employ perceptual loss based on the pre-trained VGG network and style loss based on Gram matrices to help the network produce semantically consistent apparel content. The perceptual loss calculates the differences between images through a pre-trained neural network. Compared to Absolute Value Error, perceptual loss aligns more closely with human perception of images. We calculate the perceptual loss \(\mathcal{L}_{p}\) using a pre-trained VGG network as follows:  
\[\mathcal{L}_{p}=\sum_{i}\frac{1}{U_{i}}\big{|}\phi_{i}(C_{ori})-\phi_{i}\big{(} C_{gen}\big{)}\big{|}, \tag{19}\]  
where \(\phi_{i}(C_{\text{ori}})\) and \(\phi_{i}(C_{\text{gen}})\) represent the features extracted from the \(i\)-th layer of VGG for the real image and the generated image, respectively, and \(U\) denotes the total number of layers in the VGG network. The style loss is used to ensure that the generated images have a consistent overall style with the real images, avoiding generating plausible but seriously misaligned results in terms of style semantics. First, the pre-trained VGG is used to calculate the Gram matrix:  
\[G_{\phi_{i}}(C)=\frac{1}{U_{l}Y_{l}}\sum_{i=1}^{U_{l}}\sum_{j=1}^{Y_{l}}\phi_{ l}(C)_{i,j}\cdot\phi_{l}(C)_{j,i}, \tag{20}\]  
where \(U_{l}\) and \(Y_{l}\) are the number of channels and spatial dimensions of the features, respectively. \(C\) is the input image. The style loss can be expressed as  
\[\mathcal{L}_{s}=\sum_{l}\big{|}G_{\phi_{l}}(C_{ori})-G_{\phi_{l}}\big{(}C_{gen }\big{)}\big{|}. \tag{21}\]  
In order to improve the quality of the generated image, avoid blur in the generated image, and simplify the design details of the loss function, we introduced PatchGAN-based adversarial loss for adversarial training. PatchGAN divides the image into several small local patches and discriminates the truth and falsity of each local patch to help the generation network improve the quality of local texture generation. The discriminator loss based on PatchGAN is  
\[ \begin{split}\mathcal{L}_{D}=-\mathbb{E}_{\kappa\sim p_{\text{ data}}}(C_{ori})\left[\sum_{i,j}\log D_{i,j}(C_{\text{ori}})\right]\\ -\mathbb{E}_{\kappa\sim p_{\kappa}(\kappa)}\Bigg{[}\sum_{i,j} \log\big{(}1-D_{i,j}\big{(}C_{gen}\big{)}\big{)}\Bigg{]},\end{split}  \tag{22}\]where \(D_{i,j}(C_{ori})\) is the output of the discriminator on the real sample on patch \((i,j)\), and \(D_{i,j}(C_{gen})\) is the output of the discriminator on the generated sample on patch \((i,j)\). The goal of the generative network is to fool the discriminator on as many patches as possible.