I have a script that generates a sequence of matplotlib figures and writes them to disk using a TensorBoard SummaryWriter()
. TensorBoard offers the ability to move a little slider to advance forwards and backwards through the image sequence, but I'd like to convert the image sequence to a video or animation. Is there a way to do this?
Edit 1: Here's a simplified example of what my code current does. I'd like to take the images that are written to the log file by .add_figure
and convert them to a gif.
import matplotlib.pyplot as plt
import numpy as np
from torch.utils.tensorboard import SummaryWriter
n = 200
nframes = 25
x = np.linspace(-np.pi*4, np.pi*4, n)
tensorboard_writer = SummaryWriter()
for i, t in enumerate(np.linspace(0, np.pi, nframes)):
plt.plot(x, np.cos(x + t))
plt.plot(x, np.sin(2*x - t))
plt.plot(x, np.cos(x + t) + np.sin(2*x - t))
plt.ylim(-2.5,2.5)
fig = plt.gcf()
tensorboard_writer.add_figure(
tag='temp',
figure=fig,
global_step=i,
close=True)