docarray.array.mixins.plot module#
- class docarray.array.mixins.plot.PlotMixin[source]#
Bases:
object
Helper functions for plotting the arrays.
- summary()[source]#
Print the structure and attribute summary of this DocumentArray object.
Warning
Calling {meth}`.summary` on large DocumentArray can be slow.
- plot_embeddings(title='MyDocumentArray', path=None, image_sprites=False, min_image_size=16, channel_axis=-1, start_server=True, host='127.0.0.1', port=None, image_source='tensor', exclude_fields_metas=None)[source]#
Interactively visualize
embeddings
using the Embedding Projector and store the visualization informations.- Parameters:
title (
str
) – the title of this visualization. If you want to compare multiple embeddings at the same time, make sure to give different names each time and setpath
to the same value.host (
str
) – if set, bind the embedding-projector frontend to given host. Otherwise localhost is used.port (
Optional
[int
]) – if set, run the embedding-projector frontend at given port. Otherwise a random port is used.image_sprites (
bool
) – if set, visualize the dots usinguri
andtensor
.path (
Optional
[str
]) – if set, then append the visualization to an existing folder, where you can compare multiple embeddings at the same time. Make sure to use a differenttitle
each time .min_image_size (
int
) – only used when image_sprites=True. the minimum size of the imagechannel_axis (
int
) – only used when image_sprites=True. the axis id of the color channel,-1
indicates the color channel info at the last axisstart_server (
bool
) – if set, start a HTTP server and open the frontend directly. Otherwise, you need to rely onreturn
path and serve by yourself.image_source (
str
) – specify where the image comes from, can beuri
ortensor
. empty tensor will fallback to uriexclude_fields_metas (
Optional
[List
[str
]]) – specify the fields that you want to exclude from metadata tsv file
- Return type:
str
- Returns:
the path to the embeddings visualization info.
- save_gif(output, channel_axis=-1, duration=200, size_ratio=1.0, inline_display=False, image_source='tensor', skip_empty=False, show_index=False, show_progress=False)[source]#
Save a gif of the DocumentArray. Each frame corresponds to a Document.uri/.tensor in the DocumentArray.
- Parameters:
output (
str
) – the file path to save the gif to.channel_axis (
int
) – the color channel axis of the tensor.duration (
int
) – the duration of each frame in milliseconds.size_ratio (
float
) – the size ratio of each frame.inline_display (
bool
) – if to show the gif in Jupyter notebook.image_source (
str
) – the source of the image in Document atribute.skip_empty (
bool
) – if to skip empty documents.show_index (
bool
) – if to show the index of the document in the top-right corner.show_progress (
bool
) – if to show a progress bar.
- Return type:
None
- Returns:
- plot_image_sprites(output=None, canvas_size=512, min_size=16, channel_axis=-1, image_source='tensor', skip_empty=False, show_progress=False, show_index=False, fig_size=(10, 10), keep_aspect_ratio=False)[source]#
Generate a sprite image for all image tensors in this DocumentArray-like object.
An image sprite is a collection of images put into a single image. It is always square-sized. Each sub-image is also square-sized and equally-sized.
- Parameters:
output (
Optional
[str
]) – Optional path to store the visualization. If not given, show in UIcanvas_size (
int
) – the size of the canvasmin_size (
int
) – the minimum size of the imagechannel_axis (
int
) – the axis id of the color channel,-1
indicates the color channel info at the last axisimage_source (
str
) – specify where the image comes from, can beuri
ortensor
. empty tensor will fallback to uriskip_empty (
bool
) – skip Document who has no .uri or .tensor.show_index (
bool
) – show the index on the top-right corner of every imagefig_size (
Optional
[Tuple
[int
,int
]]) – the size of the figureshow_progress (
bool
) – show a progressbar while plotting.keep_aspect_ratio (
bool
) – preserve the aspect ratio of the image by using the aspect ratio of the first image in self.
- Return type:
None