f-dangel / cockpit

Cockpit: A Practical Debugging Tool for Training Deep Neural Networks
MIT License
474 stars 24 forks source link

Saving the plots as a gif or a video #22

Open binarycache opened 2 years ago

binarycache commented 2 years ago

Can you please add saving the plots as a gif or a video as it will make it easier to just take a look and understand things once the training ends?

fsschneider commented 2 years ago

Hi,

you could take a look at our experiment repository, which contains all the code to re-create the experiments shown in the paper, including the animated showcase.

More specifically, the method animate might be what you are looking for:

https://github.com/fsschneider/cockpit-experiments/blob/a9eaf3dc5da5a58356ac0eef25a11235bf0891c4/experiments/10_showcase/shared.py#L99-L139

It lets you build and save an animation from the logged .json file.

@f-dangel and I can discuss if and how this is a functionality we want to integrate into the main cockpit library.

For now, I hope that this code snippet is helpful for you to create the gifs that you want. Let me know if that works for you.

binarycache commented 2 years ago

Hi @fsschneider,

Thank you for the reply. I managed to use the animate function and generate the corresponding gif.

In the process, I found that the plotter class already has a function called build_animation() here

However, I think this function calls _animate() and the pattern used in the animate function perhaps needs some modifications. For example pattern = os.path.splitext(logpath)[0] + f"{screen}epoch__*.png"

I think here it should be {epoch} instead of hardcoded epoch because of the way the plot function saves the data. Similarly, you have to tweak the path returned from get_logpath() a bit to make it work. I think it would be easier if we can directly use get_logpath().

Thanks Again. Best, Anmol