anishathalye / neural-style

Neural style in TensorFlow! 🎨
https://anishathalye.com/an-ai-that-can-mimic-any-artist/
GNU General Public License v3.0
5.54k stars 1.52k forks source link

Add write and plot options for progress data (loss values) #130

Closed elcorto closed 5 years ago

elcorto commented 5 years ago

Here is another one. This one is bigger and changes the API of stylize.stylize in order to optionally store and/or plot loss values for convergence monitoring:

Add --progress-write and --progress-plot to save and/or plot loss values at every print_iterations step.

For that, we need to modify the behavior of the stylize() function. This function now yields tuples (iteration, image, loss_vals) at every iteration, not every checkpoint_iterations and at the last step as before. Also, stylize() does not set iteration to None at the last step. image and loss_vals are None by default. Each checkpoint_iterations, image is not None. Each print_iterations, loss_vals is not None, i.e we can save images and store the loss at different frequencies.

loss_vals is a dict with loss values for the current iteration, e.g. {'content': 1.23, 'style': 4.56, 'tv': 7.89, 'total': 13.68}.

neural_style.py was adapted accordingly. The default CLI behavior of neural_style.py is unchanged.

anishathalye commented 5 years ago

Looks good! Thank you for the contribution.