Source code for docarray.dataclasses.getter

from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from docarray import Document


[docs]def image_getter(doc: 'Document'): if doc._metadata['image_type'] == 'uri': return doc.uri elif doc._metadata['image_type'] == 'PIL': from PIL import Image return Image.fromarray(doc.tensor) elif doc._metadata['image_type'] == 'ndarray': return doc.tensor
[docs]def text_getter(doc: 'Document'): return doc.text
[docs]def audio_getter(doc: 'Document'): return doc.uri or doc.tensor
[docs]def video_getter(doc: 'Document'): return doc.uri or doc.tensor
[docs]def mesh_getter(doc: 'Document'): return doc.uri or doc.tensor
[docs]def tabular_getter(doc: 'Document'): return doc.uri
[docs]def blob_getter(doc: 'Document'): return doc.uri or doc.blob
[docs]def json_getter(doc: 'Document'): return doc.tags