erlexec icon indicating copy to clipboard operation
erlexec copied to clipboard

poc: parametrized image type

Open JohannesMessner opened this issue 2 years ago • 1 comments

This proof of concept shows how we can make our dataclass types more flexible, for example by allowing the user to set the desired Image size right there.

This POC make the following possible:

from docarray import dataclass, Document
from docarray.typing import Image, Text


@dataclass
class MMDoc:
    default_img: Image
    small_img: Image[10, 10]  # set image size
    large_img: Image[1000, 1000, 1]  # set size and channel axis


d = Document(MMDoc(default_img='testflow.jpg', small_img='testflow.jpg', large_img='testflow.jpg'))

print(d.default_img.tensor.shape)
print(d.small_img.tensor.shape)
print(d.large_img.tensor.shape)

>>> (50, 215, 3)
>>> (10, 10, 3)
>>> (1000, 3, 1000)

JohannesMessner avatar Jul 25 '22 18:07 JohannesMessner