Jupyter Notebook/Colab#

Many data scientists work with Jupyter Notebook or Google Colab especially at the early prototyping stage. We understand that and that’s why we optimize DocArray’s user experience in these two environments. In this chapter, I use Jupyter Notebook as an example to demonstrate the features that can improve your productivity. On Google Colab, it is the same experience.

Tip

Some features require extra dependencies beyond the basic install of DocArray. Use pip install "docarray[common]" to enable them.

Display Document#

A cell with a Document object will be pretty-printed with its non-empty field and id.

../../_images/single-doc.png

If a Document is nested, then it pretty-prints the nested structure.

../../_images/single-doc-nested.png

Display rich content#

If a Document is an image Document, you can use display() to visualize it.

../../_images/image-doc.png

Note that it finds .tensor or .uri for visualization.

../../_images/image-doc-tensor.png

This works even if your Document is not a real image but just a ndarray in .tensor.

../../_images/image-tensor.png

Video and audio Document can be displayed as well, you can play them in the cell.

../../_images/audio-video.png

You can also display your 3D object and interact with it in the cell, whether you stored it as a point cloud or vertices and faces.

../../_images/mesh-point-cloud.png

Additionally, you can also display an RGB image and its corresponding depth image:

../../_images/image-rgbd.png

Display DocumentArray#

A cell with a DocumentArray object can be pretty-printed automatically.

../../_images/doc-array.png

Display image sprite#

DocumentArray with all image Documents (image is either in .uri or .tensor) can be plotted into one sprite image.

../../_images/image-sprite.png

Display embeddings#

DocumentArray with non-empty .embeddings can be visualized interactively via plot_embeddings()

../../_images/embedding-ani1.gif

DocumentArray with non-empty .embeddings and image Documents can be visualized in a much richer way via .plot_embeddings(image_sprites=True).

../../_images/embedding-ani2.gif

PyCharm users#

All rich visualization, progressbar, table are not shown correctly in PyCharm debug console. You may get broken visualization or empty visualization.

PyCharm users will need to enable “emulate terminal” in output console option in run/debug configuration to see styled output.

Please follow the steps below to enable it:

../../_images/pycharm-rich.png