Skip to content

Commit 441db26

Browse files
authored
docs: adding field descriptions to predefined image document (docarray#1772)
Signed-off-by: punndcoder28 <[email protected]>
1 parent 35d2138 commit 441db26

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

docarray/documents/image.py

Lines changed: 21 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,24 @@ class MultiModalDoc(BaseDoc):
9295
```
9396
"""
9497

95-
url: Optional[ImageUrl] = None
96-
tensor: Optional[ImageTensor] = None
97-
embedding: Optional[AnyEmbedding] = None
98-
bytes_: Optional[ImageBytes] = None
98+
url: Optional[ImageUrl] = Field(
99+
description='URL to a (potentially remote) image file that needs to be loaded',
100+
example='https://github.com/docarray/docarray/blob/main/tests/toydata/image-data/apple.png?raw=true',
101+
default=None,
102+
)
103+
tensor: Optional[ImageTensor] = Field(
104+
description='Tensor object of the image which can be specifed to one of `ImageNdArray`, `ImageTorchTensor`, `ImageTensorflowTensor`.',
105+
default=None,
106+
)
107+
embedding: Optional[AnyEmbedding] = Field(
108+
description='Store an embedding: a vector representation of the image.',
109+
example=[1, 0, 1],
110+
default=None,
111+
)
112+
bytes_: Optional[ImageBytes] = Field(
113+
description='Bytes object of the image which is an instance of `ImageBytes`.',
114+
default=None,
115+
)
99116

100117
@classmethod
101118
def validate(

0 commit comments

Comments
 (0)