Skip to content

自定义多模态Document报错 #1015

@di-osc

Description

@di-osc

Describe the bug
我根据文档用dataclass装饰器自定义多模态Document,此时,如果定义的多模态模型图片为List[Image],但当我传入的图片只有一张时,则通过属性获取该数据时,获取到的并非为一个列表,而是一个Document。

To Reproduce

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

@dataclass
class MyDoc:
    title: Text
    images: List[Image]

my = MyDoc(title='黎明', images=['https://bkimg.cdn.bcebos.com/pic/359b033b5bb5c9ea15ce3757e86fa1003af33a871573?x-bce-process=image/watermark,image_d2F0ZXIvYmFpa2UxNTA=,g_7,xp_5,yp_5'])
 
doc = Document(my)
img = doc.images[0]

Expected behavior
此时应该返回一个列表

Screenshots
image

Desktop (please complete the following information):

  • Version [0.20.1]

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions