# Feature-Level Camera Style Transfer for Person Re-Identification
## 3 Feature-Level Camera Style Transfer
### Adversarial Camera Style Feature-to-Feature Translation  
The generative model aims to make camera style transfer while preserving input features' identity information. Thus, the goal of the generative model can be divided into two parts: judging the authenticity of generated features and determining whether generated features complete the camera style transfer. The objective functions of the generative model are designed based on these two goals.  
**GAN Designing.** To determine whether generated features are real or not, a discriminator \(D\) is introduced into the generative model to calculate adversarial losses. Paired with the generator \(G\), the whole generative model plays a min-max game to improve the authenticity of generated features:  
\[\begin{split}\underset{\theta_{G}}{\text{\emph{min}}}\underset{ \theta_{D}}{\text{\emph{max}}}\mathcal{L}_{adv}&=\mathbb{E}_{f^{l }\sim\mathcal{P}_{G}}[\log(1-D(G(f_{i}^{l},f_{j}^{C})|y_{i},c_{j}))]\\ +\mathbb{E}_{f_{i}^{l}\sim\mathcal{P}_{I}}[\log D(f_{i}^{l}|y_{i},c_{i})]\end{split} \tag{2}\]where \(\theta_{G},\theta_{D}\) represents the parameters of generator \(G\) and discriminator \(D\). \(f_{i}^{I}\) is the real source feature with identity label \(y_{i}\) and camera label \(c_{i}\), while \(f^{{}^{\prime}}=G(f_{i}^{I},f_{j}^{C})\) is the generated feature with the same identity label \(y_{i}\) and different camera label \(c_{i}\). \(\mathcal{P}_{G}\) and \(\mathcal{P}_{I}\) denote the distributions of generated features and real features, respectively. Furthermore, WGAN-GP [28] is selected to play the role of adversarial loss, since the authors found its relatively stable performance in the generation objectives. Therefore, a gradient penalty loss is added to confirm the Lipschitz constraint of the entire loss function:  
\[\mathcal{L}_{gp}=\mathbb{E}_{j\sim\mathcal{P}_{j}}[(||\
abla_{j}D(\hat{f})||_{ 2}-1)^{2}] \tag{3}\]  
where \(\mathcal{P}_{j}\) corresponds to the distribution that samples uniformly along the straight line between \(\mathcal{P}_{G}\) and \(\mathcal{P}_{I}\), \(||\cdot||_{2}\) indicates _L2-norm_.  
**Camera Classification Loss.** To ensure that the generator makes accurate camera style transfer toward target features, camera labels can be utilized as supervisory information in the GAN training. To be more specific, the real feature \(f_{i}^{I}\) should preserve its camera label \(c_{i}\) and the generated feature \(f^{\prime}\) has transferred camera label \(c_{j}\). Following the practice of StarGAN [18], this objective can be decomposed into two parts. One is camera domain classification loss for real features \(\mathcal{L}_{cam}^{r}\), and the other is camera domain classification loss for generated features \(\mathcal{L}_{cam}^{f}\):  
\[\mathcal{L}_{cam}^{r}=\mathbb{E}_{f_{i}^{I}\sim\mathcal{P}_{I}}[-\log D_{cam} (f_{i}^{I}|c_{i})] \tag{4}\]  
\[\mathcal{L}_{cam}^{f}=\mathbb{E}_{f^{{}^{\prime}}\sim\mathcal{P}_{G}}[-\log D _{cam}(G(f_{i}^{I},f_{j}^{C})|c_{j})] \tag{5}\]  
where \(D_{cam}\) is the camera discriminator, and the definitions of the other symbols are the same as shown in Equation (2).  
**Overall Objective Function.** The loss functions mentioned before are combined to formulate total loss function for \(D\) and \(G\), respectively:  
\[\mathcal{L}_{D}=-\mathcal{L}_{adv}+\lambda_{cam}(\mathcal{L}_{cam}^{r}+L_{cam }^{f})+\lambda_{gp}\mathcal{L}_{gp} \tag{6}\]  
\[\mathcal{L}_{G}=\mathcal{L}_{adv}+\lambda_{cam}\mathcal{L}_{cam}^{f}+\lambda_ {gp}\mathcal{L}_{gp} \tag{7}\]  
where \(\lambda_{cam}\) and \(\lambda_{gp}\) are hyper-parameters to control the contribution of different parts to the overall loss function. The impact of these hyper-parameters is studied in Section 5.3.