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

Image logging to tensorboard #54

Closed
tmquan opened this issue Aug 7, 2019 · 10 comments
Closed

Image logging to tensorboard #54

tmquan opened this issue Aug 7, 2019 · 10 comments

Comments

@tmquan
Copy link

tmquan commented Aug 7, 2019

Hi @williamFalcon ,

Thanks for your nice work.
I am just wondering is it possible to log the image tensor to tensorboard to train such a U-net?

Bests,

@williamFalcon
Copy link
Contributor

yup!

in the lightningModule you can call self.experiment. that’s a summarywriter for tensorboard. for the api of that refer to pytorch summarywriter.

https://pytorch.org/docs/stable/tensorboard

it’s all explained here: https://williamfalcon.github.io/pytorch-lightning/Trainer/Logging/#tensorboard-support

realized self.experiment from docs. adding now!

@williamFalcon
Copy link
Contributor

@tmquan can you update to the latest test-tube version and try again?

luiscape pushed a commit to luiscape/pytorch-lightning that referenced this issue Jan 17, 2020
They should be the same grey as the other links, not blue, and should turn orange when active like the other links.
@celsofranssa
Copy link

Is there an approach to only log a subset of images instead of all over the validation_step or test_step call?

@epignatelli
Copy link

epignatelli commented Jul 31, 2020

@williamFalcon I don't think it's a feasible solution.

It means returning the outputs of the forward pass from training_step.

However, as soon as you override training_epoch_end, it will stack things up in the GPU, until it fill its/their memory.

@ananyahjha93
Copy link
Contributor

@ceceu have you tried

torchvision.utils.make_grid()

and then log images?

@ananyahjha93
Copy link
Contributor

@epignatelli you can create a variable such as

self.imgs = # something

and then plot these. This will work with DDP and the regular single GPU case but will not work with DP the default version does not support state maintenance.

@williamFalcon
Copy link
Contributor

example:

https://pytorch-lightning-bolts.readthedocs.io/en/latest/vision_callbacks.html#confused-logit

@celsofranssa
Copy link

Thanks @ananyahjha93 and @williamFalcon, I guess the callback approach is the best practice.

@qmpzzpmq
Copy link
Contributor

qmpzzpmq commented May 8, 2023

Hi, right now is there any method to call tensorboard's add_image add_audio

@tmquan
Copy link
Author

tmquan commented May 8, 2023

@qmpzzpmq
There should be

tensorboard = self.logger.experiment
grid = torchvision.utils.make_grid(...)
tensorboard.add_image(f'{stage}_samples', grid.clamp(0., 1.), self.current_epoch*self.batch_size + batch_idx)    

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

6 participants