From 4a2099b53c09d1feaf0e079092c9e075b43df7d2 Mon Sep 17 00:00:00 2001 From: Tim Joseph Date: Mon, 31 May 2021 13:33:56 +0200 Subject: [PATCH] Adds an tensorboardx example for add_video (creates GIFs in tensorboard) --- .../tensorboardx/moviepy_tensorboardx.py | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 examples/frameworks/tensorboardx/moviepy_tensorboardx.py diff --git a/examples/frameworks/tensorboardx/moviepy_tensorboardx.py b/examples/frameworks/tensorboardx/moviepy_tensorboardx.py new file mode 100644 index 00000000..6cf44660 --- /dev/null +++ b/examples/frameworks/tensorboardx/moviepy_tensorboardx.py @@ -0,0 +1,28 @@ +# ClearML - Example of pytorch with tensorboardX add_video. +# +from __future__ import print_function + +import torch +from tensorboardX import SummaryWriter + +from clearml import Task + + +def main(): + + # Connecting ClearML with the current process, + # from here on everything is logged automatically + task = Task.init(project_name="examples", task_name="pytorch with tensorboardX") + + writer = SummaryWriter("runs") + writer.add_text("TEXT", "This is some text", 0) + + # Make a video that simply fades grey colors + video = (torch.sin(torch.arange(0, 1000) / 100) + 1) / 2 * 255 + video = video.byte().view(1, -1, 1, 1, 1).expand(1, -1, 3, 64, 64) + + writer.add_video("my_video", video, 0, fps=50) + + +if __name__ == "__main__": + main()