mahmoudnafifi / HistoGAN

Reference code for the paper HistoGAN: Controlling Colors of GAN-Generated and Real Images via Color Histograms (CVPR 2021).
MIT License
267 stars 27 forks source link

Histogram block refactoring test #24

Open patlevin opened 2 years ago

patlevin commented 2 years ago

Histogram Refactoring

Content: a notebook that uses refactored versions of the histogram losses, validates them using A-B testing and performs benchmark tests to compare original and refactored versions using their default parameters.

Motivation

First of all, thanks for the great work and for publishing your codešŸ™. I found it very useful in my own experiments.

However, I ran into performance issues when using histogram loss in my own models and decided to take a closer look at the code. The notebook in this commit contains the results of my findings and provides some reproducible data for testing and validation as well as benchmarks to test for performance improvements if any.

Changes

I kept the public interface of the histogram blocks as-is and only sprinkled in a few type hints here and there (mainly for my own convenience as auto-complete and syntax highlighting work much better with type hints in place). The actual changes are documented within the notebook itself.

Final Thoughts

Merging this PR first is purely optional, but I thought it maybe a convenient way to test and validate the refactoring present in my other PR before merging that. The notebook is present in the other branch as well, but separated the change to make it more convenient for you to take a look at the changes first.

Sample Benchmark Plot (Google Colab)

Benchmark Plot Colab