docarray.document.mixins.plot module#

class docarray.document.mixins.plot.PlotMixin[source]#

Bases: object

Provide helper functions for Document to plot and visualize itself.

summary()[source]#

Print non-empty fields and nested structure of this Document object.

Return type:

None

display(from_=None)[source]#

Plot image data from uri or from tensor if uri is empty .

Parameters:

from – an optional string to decide if a document should display using either the uri or the tensor field.

display_tensor()[source]#

Plot image data from tensor

display_uri()[source]#

Plot image data from uri

plot_matches_sprites(top_k=10, channel_axis=-1, inv_normalize=False, skip_empty=False, canvas_size=1920, min_size=100, output=None)[source]#

Generate a sprite image for the query and its matching images in this Document object.

An image sprite is a collection of images put into a single image. Query image is on the left followed by matching images. The Document object should contain matches.

Parameters:
  • top_k (int) – the number of top matching documents to show in the sprite.

  • channel_axis (int) – the axis id of the color channel, -1 indicates the color channel info at the last axis

  • inv_normalize (bool) – If set to True, inverse the normalization of a float32 image tensor into a uint8 image tensor inplace.

  • skip_empty (bool) – skip matches which has no .uri or .tensor.

  • canvas_size (int) – the width of the canvas

  • min_size (int) – the minimum size of the image

  • output (Optional[str]) – Optional path to store the visualization. If not given, show in UI