tensorboard icon indicating copy to clipboard operation
tensorboard copied to clipboard

TensorBoard Jupyter Magic HTML Export

Open Queuecumber opened this issue 5 years ago • 9 comments

Tensorflow from tf-nightly-2.0-preview

I frequently using jupyter-nbconvert to share my notebooks as HTML since it's easier to host on a static site and be viewable by anyone. I have recently been using the tensorboard magic to get nice graphs of my metrics and loss as I train, but I found that when I export, these graphs are missing.

It would be nice to be able to export the tensorboard interface somehow. When I do the export, graphs and images from matplotlib are always fine so there should be a way to do it, although it might be up to the nbconvert people.

Queuecumber avatar Mar 23 '19 18:03 Queuecumber

Thanks for the feature request - yes, this is a known limitation of the way that the tensorboard magic is currently implemented, since the frontend HTML visualization expects to find an actual running tensorboard backend from which it can fetch data. Unfortunately I suspect it would not be easy to work around this unless there's possibly some way that nbconvert can cache those responses and bundle them with the exported HTML.

cc @wchargin

nfelt avatar Mar 26 '19 19:03 nfelt

Interestingly, google colab has no problem displaying the data even when its not connected to a backend, not sure if thats a known thing but however that works would probably be enough

Queuecumber avatar Mar 27 '19 02:03 Queuecumber

Colab caches network requests made within a cell output frame and saves them in the notebook directly. If you create a simple Colab notebook with a %tensorboard invocation, then download the ipynb, you can see the cached data:

$ jq '.cells[1].metadata.colab.resources | keys' Downloads/colab_tensorboard_sample.ipynb
[
  "http://localhost:6006/",
  "http://localhost:6006/data/environment",
  "http://localhost:6006/data/experiments",
  "http://localhost:6006/data/plugins_listing",
  "http://localhost:6006/data/runs",
  "http://localhost:6006/font-roboto/RxZJdnzeo3R5zSexge8UUZBw1xU1rKptJj_0jans920.woff2",
  "http://localhost:6006/font-roboto/d-6IYplOFocCacKzxwXSOJBw1xU1rKptJj_0jans920.woff2",
  "http://localhost:6006/font-roboto/vPcynSL0qHq_6dX7lKVByXYhjbSpvc47ee6xR_80Hnw.woff2",
  "http://localhost:6006/tf-interactive-inference-dashboard/distance.png",
  "http://localhost:6006/tf-interactive-inference-dashboard/editedexample.png",
  "http://localhost:6006/tf-interactive-inference-dashboard/explorecounterfactuals.png",
  "http://localhost:6006/tf-interactive-inference-dashboard/pdplots.png"
]
$ jq -r '.cells[1].metadata.colab.resources["http://localhost:6006/data/environment"].data' Downloads/colab_tensorboard_sample.ipynb | base64 -d; echo
{"window_title": "", "mode": "logdir", "data_location": "/tmp/whatever"}

This is the kind of caching mechanism that @nfelt was referring to; nbconvert would need to do something similar, and the generated HTML would need some kind of runtime to actually hook up the cache to the output frame.

wchargin avatar Mar 27 '19 18:03 wchargin

Or the caching could be done by the client right?

Queuecumber avatar Mar 28 '19 02:03 Queuecumber

Hello, is there any update on this? I have a similar use case where I want to export the static Tensorboard HTML so that I can host it on my own web app and the user doesn't have to deal with launching a Tensorboard instance.

arif-ahmed-nv avatar Jan 25 '24 18:01 arif-ahmed-nv

Hello, is there any update on this? I have a similar use case where I want to export the static Tensorboard HTML so that I can host it on my own web app and the user doesn't have to deal with launching a Tensorboard instance.

did you find a solution?

orioninthesky98 avatar Jul 10 '24 07:07 orioninthesky98

for what it's worth, images (PNGs, JPEGs) can be easily embedded in HTMLs by converting them to base64 and inserting them into the HTML

orioninthesky98 avatar Jul 10 '24 07:07 orioninthesky98

@orioninthesky98 We couldn't figure out a way to get around this issue without launching a dedicated instance for Tensorboard. We would appreciate if a Flask API (or something similar) layer would be added on top of Tensorboard, so that we could simply make GET requests to the Tensorboard instance to receive the content, instead of having the user directly connect to the running instance to view Tensorboard.

arif-ahmed-nv avatar Jul 10 '24 15:07 arif-ahmed-nv

We would appreciate if a Flask API (or something similar) layer would be added on top of Tensorboard, so that we could simply make GET requests to the Tensorboard instance to receive the content

While there isn't an official Flask interface, you can use this trick with the server_class argument to tensorboard.program.TensorBoard to smuggle one out: https://github.com/tensorflow/tensorboard/issues/3709#issuecomment-639687689

wchargin avatar Jul 10 '24 16:07 wchargin