Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZeroDivisionError for a Simple Example #61

Closed
siavashk opened this issue May 19, 2022 · 5 comments
Closed

ZeroDivisionError for a Simple Example #61

siavashk opened this issue May 19, 2022 · 5 comments
Assignees

Comments

@siavashk
Copy link

siavashk commented May 19, 2022

This plugin produces a ZeroDivisonError for a simple example. I installed the most recent version (1.0.3) from pypi. I have attached the full stack trace and the relevant portion of the error is the following:

...
 File "/home/ubuntu/anaconda3/envs/pytensorboard3d/lib/python3.8/site-packages/tensorboard_plugin_3d/plugin.py", line 80, in _serve_image
    data = self._find_next_images(1)
File "/home/ubuntu/anaconda3/envs/pytensorboard3d/lib/python3.8/site-packages/tensorboard_plugin_3d/plugin.py", line 173, in _find_next_images
    self.current_run = (int(idx) - 1) % len(self._all_runs)
ZeroDivisionError: integer division or modulo by zero

Steps to reproduce:

  1. Environment setup. The pip installation step is taken from here:
conda create -n pytensorboard3d python=3.8 -y
conda activate pytensorboard3d

pip install -q "monai-weekly[gdown, nibabel, tqdm, ignite]"
pip install -q matplotlib
pip install -q tensorboard-plugin-3d
  1. Write a simple cube to the summary:
from monai.visualize.img2tensorboard import plot_2d_or_3d_image
import torch
from torch.utils.tensorboard import SummaryWriter

def make_white_cube_batch():
    x = torch.zeros((8, 1, 100, 100, 100))
    x[:, :, 25:75, 25:75, 25:75] = 1
    return x

log_dir = '/home/ubuntu/foo'
sw = SummaryWriter(log_dir=log_dir)

batch = make_white_cube_batch()
plot_2d_or_3d_image(data=batch, step=1, writer=sw, tag='White Cube')
  1. Run tensorboard from the terminal:
tensorboard --logdir /home/ubuntu/foo --port 8080

Expected behaviour:

  1. Tensorboad 3D tab appears in tensorboard.
  2. If you navigate manually to Tensorboard 3D in the plugin tab, a volume would be rendered.

Actual Behaviour:

  1. Tensorboad 3D tab does not appear in tensorboard.
  2. If you navigate manually to Tensorboard 3D in the plugin tab, you get spinning wheel with the following message:
    Tensorboard 3D is loading, please wait....
  3. There is an error in the stack trace as mentioned earlier.

image

@thewtex
Copy link
Member

thewtex commented May 23, 2022

@siavashk thanks for the report 👍 @bnmajor please take a look

@bnmajor
Copy link
Collaborator

bnmajor commented May 24, 2022

@siavashk I took a look at this and I am able to view the cube, but I can see where the problems that you are seeing are coming from. Important to note:

  1. The tag that is passed in must be either image or label, as this is how the plugin identifies what to load and what role the data has. Changing the tag should fix your issue.
  2. In TensorBoard plugins are made available if they have data to display. If the TensorBoard tab is not available it is because no data is being found. This is why you saw the infinitely spinning wheel.

cube

Thank you for sharing your issue though! This information is covered in the docs but I think that it should be made even clearer and probably re-iterated throughout the docs in a few more places. And I can look into a more useful message for others that select the plugin from the drop down in the future so that it is not a misleading progress bar.

I am going to close this for now but please feel free to re-open or add on if you have additional questions!

@bnmajor bnmajor closed this as completed May 24, 2022
@siavashk
Copy link
Author

@bnmajor thank you for looking into this. I will try it out later today.

I didn't find the information in the docs though (maybe I am looking at the wrong place?). I looked here.

@bnmajor
Copy link
Collaborator

bnmajor commented May 24, 2022

@siavashk Yes, that information is in the TensorBoardPlugin3D docs here (at the bottom of the Plot Images section directly above the Select Images to View section). But this is a bit buried and since, as you can see in the docs you were referencing, this differs from the MONAI docs a little I think we should make it more obvious.

@siavashk
Copy link
Author

Thank you. I can verify that this works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants