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
.
If a Document is nested, then it pretty-prints the nested structure.
Display rich content#
If a Document is an image Document, you can use display()
to visualize it.
Note that it finds .tensor
or .uri
for visualization.
This works even if your Document is not a real image but just a ndarray
in .tensor
.
Video and audio Document can be displayed as well, you can play them in the cell.
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.
Additionally, you can also display an RGB image and its corresponding depth image:
Display DocumentArray#
A cell with a DocumentArray object can be pretty-printed automatically.
Display image sprite#
DocumentArray with all image Documents (image is either in .uri
or .tensor
) can be plotted into one sprite image.
Display embeddings#
DocumentArray with non-empty .embeddings
can be visualized interactively via plot_embeddings()
DocumentArray with non-empty .embeddings
and image Documents can be visualized in a much richer way via .plot_embeddings(image_sprites=True)
.
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: