From 16393ede4dfe61641e1bc0beb6f4d61fc4282213 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Wed, 18 Sep 2024 18:23:41 +0100 Subject: [PATCH] add TensorBoard 3D --- README.md | 1 + petric.py | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/README.md b/README.md index cf913c1..de6b148 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,7 @@ docker run --rm -it --gpus all -p 6006:6006 \ # 3. optionally, conda/pip/apt install environment.yml/requirements.txt/apt.txt # 4. install metrics & run your submission pip install git+https://github.com/TomographicImaging/Hackathon-000-Stochastic-QualityMetrics +pip install tensorboard-plugin-3d monai python petric.py & # 5. optionally, serve logs at tensorboard --bind_all --port 6006 --logdir ./output diff --git a/petric.py b/petric.py index e1b886a..b7a423d 100755 --- a/petric.py +++ b/petric.py @@ -105,6 +105,12 @@ def __call__(self, algo: Algorithm): self.tb.add_image("coronal", np.clip(x_arr[None, :, self.coronal_slice] / self.vmax, 0, 1), algo.iteration, t) self.tb.add_image("sagittal", np.clip(x_arr[None, :, :, self.sagittal_slice] / self.vmax, 0, 1), algo.iteration, t) + try: + from monai.visualize import plot_2d_or_3d_image + except ImportError: + pass + else: + plot_2d_or_3d_image(np.clip(x_arr[None, None] / self.vmax, 0, 1), algo.iteration, self.tb, tag='image') log.debug("...logged")