          #TODO check "Tips for mask refinement (optional after >15k iters)" => https://render.githubusercontent.com/view/ipynb?commit=87d6e7a28ce754acd38d885367b6ceb0be92ec54&enc_url=68747470733a2f2f7261772e67697468756275736572636f6e74656e742e636f6d2f7368616f616e6c752f66616365737761702d47414e2f383764366537613238636537353461636433386438383533363762366365623062653932656335342f46616365537761705f47414e5f76325f737a3132385f747261696e2e6970796e62&nwo=shaoanlu%2Ffaceswap-GAN&path=FaceSwap_GAN_v2_sz128_train.ipynb&repository_id=115182783&repository_type=Repository#Tips-for-mask-refinement-(optional-after-%3E15k-iters)
          loss_DA, loss_GA = self.define_loss(self.model.netDA, real_A, fake_A, fake_sz64_A, distorted_A, vggface_feat)
          loss_DB, loss_GB = self.define_loss(self.model.netDB, real_B, fake_B, fake_sz64_B, distorted_B, vggface_feat)
  
          loss_GA += 3e-3 * K.mean(K.abs(mask_A))
          loss_GB += 3e-3 * K.mean(K.abs(mask_B))
  
          w_fo = 0.01
          loss_GA += w_fo * K.mean(self.first_order(mask_A, axis=1))
          loss_GA += w_fo * K.mean(self.first_order(mask_A, axis=2))
          loss_GB += w_fo * K.mean(self.first_order(mask_B, axis=1))
 
</s> remove         #TODO check "Tips for mask refinement (optional after >15k iters)" => https://render.githubusercontent.com/view/ipynb?commit=87d6e7a28ce754acd38d885367b6ceb0be92ec54&enc_url=68747470733a2f2f7261772e67697468756275736572636f6e74656e742e636f6d2f7368616f616e6c752f66616365737761702d47414e2f383764366537613238636537353461636433386438383533363762366365623062653932656335342f46616365537761705f47414e5f76325f737a3132385f747261696e2e6970796e62&nwo=shaoanlu%2Ffaceswap-GAN&path=FaceSwap_GAN_v2_sz128_train.ipynb&repository_id=115182783&repository_type=Repository#Tips-for-mask-refinement-(optional-after-%3E15k-iters)
 </s> add  </s> remove         loss_G += K.mean(K.abs(fake_rgb - real))
 </s> add         if self.use_mask_refinement:
            loss_G += K.mean(K.abs(fake - real))
        else:
            loss_G += K.mean(K.abs(fake_rgb - real))
 </s> remove             fake_sz224 = tf.image.resize_images(fake_rgb, [224, 224])
 </s> add             if self.use_mask_refinement:
                fake_sz224 = tf.image.resize_images(fake, [224, 224])
            else:
                fake_sz224 = tf.image.resize_images(fake_rgb, [224, 224])

        if self.use_mask_refinement:
            loss_GA += 1e-3 * K.mean(K.square(mask_A))
            loss_GB += 1e-3 * K.mean(K.square(mask_B))
        else:
            loss_GA += 3e-3 * K.mean(K.abs(mask_A))
            loss_GB += 3e-3 * K.mean(K.abs(mask_B))

          #TODO check "Tips for mask refinement (optional after >15k iters)" => https://render.githubusercontent.com/view/ipynb?commit=87d6e7a28ce754acd38d885367b6ceb0be92ec54&enc_url=68747470733a2f2f7261772e67697468756275736572636f6e74656e742e636f6d2f7368616f616e6c752f66616365737761702d47414e2f383764366537613238636537353461636433386438383533363762366365623062653932656335342f46616365537761705f47414e5f76325f737a3132385f747261696e2e6970796e62&nwo=shaoanlu%2Ffaceswap-GAN&path=FaceSwap_GAN_v2_sz128_train.ipynb&repository_id=115182783&repository_type=Repository#Tips-for-mask-refinement-(optional-after-%3E15k-iters)
          loss_DA, loss_GA = self.define_loss(self.model.netDA, real_A, fake_A, fake_sz64_A, distorted_A, vggface_feat)
          loss_DB, loss_GB = self.define_loss(self.model.netDB, real_B, fake_B, fake_sz64_B, distorted_B, vggface_feat)
  
        if self.use_mask_refinement:
            loss_GA += 1e-3 * K.mean(K.square(mask_A))
            loss_GB += 1e-3 * K.mean(K.square(mask_B))
        else:
            loss_GA += 3e-3 * K.mean(K.abs(mask_A))
            loss_GB += 3e-3 * K.mean(K.abs(mask_B))
        if self.use_mask_refinement:
            loss_GA += 1e-3 * K.mean(K.square(mask_A))
            loss_GB += 1e-3 * K.mean(K.square(mask_B))
        else:
            loss_GA += 3e-3 * K.mean(K.abs(mask_A))
            loss_GB += 3e-3 * K.mean(K.abs(mask_B))
  
          w_fo = 0.01
          loss_GA += w_fo * K.mean(self.first_order(mask_A, axis=1))
          loss_GA += w_fo * K.mean(self.first_order(mask_A, axis=2))
          loss_GB += w_fo * K.mean(self.first_order(mask_B, axis=1))
keep keep keep keep replace replace keep keep keep keep keep
 Mask refinement option for GAN128 (#308)

I was experimenting on GAN128 and saw that mask refinement option was missing so i added that.
Its default value is False and its optional after 15k iterations.

Based on this: https://render.githubusercontent.com/view/ipynb?commit=87d6e7a28ce754acd38d885367b6ceb0be92ec54&enc_url=68747470733a2f2f7261772e67697468756275736572636f6e74656e742e636f6d2f7368616f616e6c752f66616365737761702d47414e2f383764366537613238636537353461636433386438383533363762366365623062653932656335342f46616365537761705f47414e5f76325f737a3132385f747261696e2e6970796e62&nwo=shaoanlu%2Ffaceswap-GAN&path=FaceSwap_GAN_v2_sz128_train.ipynb&repository_id=115182783&repository_type=Repository#Tips-for-mask-refinement-(optional-after-%3E15k-iters) 
plugins/Model_GAN128/Trainer.py