Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions docarray/documents/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Video(BaseDocument):
"""
Document for handling video.
The Video Document can contain a VideoUrl (`Video.url`), an Audio Document
(`Video.audio`), a VideoTensor (`Video.video_tensor`), an AnyTensor representing
(`Video.audio`), a VideoTensor (`Video.tensor`), an AnyTensor representing
the indices of the video's key frames (`Video.key_frame_indices`) and an
AnyEmbedding (`Video.embedding`).

Expand All @@ -29,9 +29,9 @@ class Video(BaseDocument):
vid = Video(
url='https://github.com/docarray/docarray/tree/feat-add-video-v2/tests/toydata/mov_bbb.mp4?raw=true'
)
vid.audio.tensor, vid.video_tensor, vid.key_frame_indices = vid.url.load()
vid.audio.tensor, vid.tensor, vid.key_frame_indices = vid.url.load()
model = MyEmbeddingModel()
vid.embedding = model(vid.video_tensor)
vid.embedding = model(vid.tensor)

You can extend this Document:

Expand All @@ -50,9 +50,9 @@ class MyVideo(Video):
video = MyVideo(
url='https://github.com/docarray/docarray/blob/feat-rewrite-v2/tests/toydata/mov_bbb.mp4?raw=true'
)
video.video_tensor = video.url.load_key_frames()
video.tensor = video.url.load_key_frames()
model = MyEmbeddingModel()
video.embedding = model(video.video_tensor)
video.embedding = model(video.tensor)
video.name = Text(text='my first video')

You can use this Document for composition:
Expand All @@ -75,11 +75,11 @@ class MultiModalDoc(BaseDocument):
),
text=Text(text='hello world, how are you doing?'),
)
mmdoc.video.video_tensor = mmdoc.video.url.load_key_frames()
mmdoc.video.tensor = mmdoc.video.url.load_key_frames()
"""

url: Optional[VideoUrl]
audio: Optional[Audio] = Audio()
video_tensor: Optional[VideoTensor]
tensor: Optional[VideoTensor]
key_frame_indices: Optional[AnyTensor]
embedding: Optional[AnyEmbedding]
4 changes: 2 additions & 2 deletions tests/integrations/predefined_document/test_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
@pytest.mark.parametrize('file_url', [LOCAL_VIDEO_FILE, REMOTE_VIDEO_FILE])
def test_video(file_url):
vid = Video(url=file_url)
vid.audio.tensor, vid.video_tensor, vid.key_frame_indices = vid.url.load()
vid.audio.tensor, vid.tensor, vid.key_frame_indices = vid.url.load()

assert isinstance(vid.audio.tensor, AudioNdArray)
assert isinstance(vid.video_tensor, VideoNdArray)
assert isinstance(vid.tensor, VideoNdArray)
assert isinstance(vid.key_frame_indices, NdArray)