Merge pull request #134 from faceshiftlabs/fix/background-power

Fixes bug when using both ms-ssim and background power
This commit is contained in:
Jeremy Hummel 2021-03-25 15:21:22 -07:00 committed by GitHub
commit b4ea90d659
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 3 deletions

View file

@ -8,6 +8,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### In Progress
- [Freezeable layers (encoder/decoder/etc.)](https://github.com/faceshiftlabs/DeepFaceLab/tree/feature/freezable-weights)
## [1.4.1] - 2020-03-24
### Fixed
- When both Background Power and MS-SSIM were enabled, the src and dst losses were being overwritten with the
"background power" losses. Fixed so "background power" losses are properly added with the total losses.
- *Note: since all the other losses were being skipped when ms-ssim and background loss were being enabled, this had
the side-effect of lowering the memory requirements (and raising the max batch size). With this fix, you may
experience an OOM error on models ran with both these features enabled. I may revisit this in another feature,
allowing you to manually disable certain loss calculations, for similar performance benefits.*
## [1.4.0] - 2020-03-24
### Added
- [MS-SSIM loss training option](doc/features/ms-ssim)
@ -60,7 +69,8 @@ This should help with rough areas directly next to the mask
- Reset stale master branch to [seranus/DeepFaceLab](https://github.com/seranus/DeepFaceLab),
21 commits ahead of [iperov/DeepFaceLab](https://github.com/iperov/DeepFaceLab) ([compare](https://github.com/iperov/DeepFaceLab/compare/4818183...seranus:3f5ae05))
[Unreleased]: https://github.com/olivierlacan/keep-a-changelog/compare/v1.4.0...HEAD
[Unreleased]: https://github.com/olivierlacan/keep-a-changelog/compare/v1.4.1...HEAD
[1.4.1]: https://github.com/faceshiftlabs/DeepFaceLab/compare/v1.4.0...v1.4.1
[1.4.0]: https://github.com/faceshiftlabs/DeepFaceLab/compare/v1.3.0...v1.4.0
[1.3.0]: https://github.com/faceshiftlabs/DeepFaceLab/compare/v1.2.1...v1.3.0
[1.2.1]: https://github.com/faceshiftlabs/DeepFaceLab/compare/v1.2.0...v1.2.1

View file

@ -476,7 +476,7 @@ Examples: df, liae, df-d, df-ud, liae-ud, ...
if self.options['background_power'] > 0:
bg_factor = self.options['background_power']
if self.options['ms_ssim_loss']:
gpu_src_loss = 10 * nn.MsSsim(resolution)(gpu_target_src, gpu_pred_src_src, max_val=1.0)
gpu_src_loss += bg_factor * 10 * nn.MsSsim(resolution)(gpu_target_src, gpu_pred_src_src, max_val=1.0)
else:
if resolution < 256:
gpu_src_loss += bg_factor * tf.reduce_mean ( 10*nn.dssim(gpu_target_src, gpu_pred_src_src, max_val=1.0, filter_size=int(resolution/11.6)), axis=[1])
@ -518,7 +518,7 @@ Examples: df, liae, df-d, df-ud, liae-ud, ...
if self.options['background_power'] > 0:
bg_factor = self.options['background_power']
if self.options['ms_ssim_loss']:
gpu_src_loss = 10 * nn.MsSsim(resolution)(gpu_target_dst, gpu_pred_dst_dst, max_val=1.0)
gpu_src_loss += bg_factor * 10 * nn.MsSsim(resolution)(gpu_target_dst, gpu_pred_dst_dst, max_val=1.0)
else:
if resolution < 256:
gpu_dst_loss += bg_factor * tf.reduce_mean ( 10*nn.dssim(gpu_target_dst, gpu_pred_dst_dst, max_val=1.0, filter_size=int(resolution/11.6)), axis=[1])