Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add images to jupyter notebooks viewable through github in a private repo

I found that images embedded in jupyter markups by a simple eg ![](img/myimage.png) didnt display in the github notebook viewer, when the repository is private.

I tried a bunch of hacking around.

Apparently there is functionality in 4.x.x to embed images as base64 metadata? But I couldnt see that in my own notebook.

like image 464
Hugh Perkins Avatar asked Feb 10 '17 12:02

Hugh Perkins


1 Answers

Finally, what worked for me, very simply, create a code cell that looks like:

from IPython.display import Image, display
display(Image(filename='img/myimage.png', embed=True))

This did:

  • loaded the local image img/myimage.png, into the notebook
  • embedded it in the notebook (probably as base64), so that it could be viewed via the github notebook viewer, with no issues
  • didnt involve embedding 400 lines of base64 into the code section itself :-)
like image 93
Hugh Perkins Avatar answered Sep 18 '22 16:09

Hugh Perkins