Skip to content

Commit fb2edac

Browse files
committed
docs: adding field descriptions to predefined image document
Signed-off-by: punndcoder28 <puneethk.2899@gmail.com>
1 parent 3dc525f commit fb2edac

1 file changed

Lines changed: 22 additions & 4 deletions

File tree

docarray/documents/image.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22

33
import numpy as np
44

5+
from pydantic import Field
6+
57
from docarray.base_doc import BaseDoc
68
from docarray.typing import AnyEmbedding, ImageBytes, ImageUrl
79
from docarray.typing.tensor.abstract_tensor import AbstractTensor
810
from docarray.typing.tensor.image.image_tensor import ImageTensor
911
from docarray.utils._internal.misc import import_library
1012

13+
1114
if TYPE_CHECKING:
1215
import tensorflow as tf # type: ignore
1316
import torch
@@ -92,10 +95,25 @@ class MultiModalDoc(BaseDoc):
9295
```
9396
"""
9497

95-
url: Optional[ImageUrl]
96-
tensor: Optional[ImageTensor]
97-
embedding: Optional[AnyEmbedding]
98-
bytes_: Optional[ImageBytes]
98+
url: Optional[ImageUrl] = Field(
99+
description='URL of the remote image',
100+
example='https://github.com/docarray/docarray/blob/main/tests/toydata/image-data/apple.png?raw=true',
101+
)
102+
tensor: Optional[ImageTensor] = Field(
103+
description='''Tensor object of the image which can be specifed to one of
104+
`ImageNdArray`, `ImageTorchTensor`, `ImageTensorflowTensor`.''',
105+
example='img.url.load()',
106+
)
107+
embedding: Optional[AnyEmbedding] = Field(
108+
description='''Embedding field is used to store tensor objects of type
109+
Tensorflow, PyTorch, NumPy and Jax''',
110+
example='np.zeros((3, 32, 32))',
111+
)
112+
bytes_: Optional[ImageBytes] = Field(
113+
description='''Bytes object of the image which is an instance of
114+
`ImageBytes.''',
115+
example='img.url.load_bytes()',
116+
)
99117

100118
@classmethod
101119
def validate(

0 commit comments

Comments
 (0)