|
2 | 2 |
|
3 | 3 | import numpy as np
|
4 | 4 |
|
| 5 | +from pydantic import Field |
| 6 | + |
5 | 7 | from docarray.base_doc import BaseDoc
|
6 | 8 | from docarray.typing import AnyEmbedding, ImageBytes, ImageUrl
|
7 | 9 | from docarray.typing.tensor.abstract_tensor import AbstractTensor
|
8 | 10 | from docarray.typing.tensor.image.image_tensor import ImageTensor
|
9 | 11 | from docarray.utils._internal.misc import import_library
|
10 | 12 |
|
| 13 | + |
11 | 14 | if TYPE_CHECKING:
|
12 | 15 | import tensorflow as tf # type: ignore
|
13 | 16 | import torch
|
@@ -92,10 +95,25 @@ class MultiModalDoc(BaseDoc):
|
92 | 95 | ```
|
93 | 96 | """
|
94 | 97 |
|
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 | + ) |
99 | 117 |
|
100 | 118 | @classmethod
|
101 | 119 | def validate(
|
|
0 commit comments