Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
a452268
feat: add video url and tensors to proto
Jan 3, 2023
3ccb697
feat: add video url and video ndarray
Jan 3, 2023
dc957d1
feat: add video torch tensor and tests
Jan 4, 2023
fc86920
fix: mypy checks
Jan 4, 2023
8a55e0b
chore: add av to video extra
Jan 4, 2023
5cb098a
fix: allow dim 3
Jan 4, 2023
3ba1f78
test: wip video load and save
Jan 5, 2023
be63926
refactor: move to numpy to computational backend
Jan 6, 2023
395a495
fix: video load and save
Jan 11, 2023
406ec80
test: adjust tests
Jan 11, 2023
091e79a
fix: video load and save and add docstrings
Jan 11, 2023
dee1146
Merge remote-tracking branch 'origin/feat-rewrite-v2' into feat-add-v…
Jan 11, 2023
e4106a8
fix: fix some imports after merging
Jan 11, 2023
23ee930
docs: add doc strings and fix example urls
Jan 11, 2023
7ab8dbd
docs: small fixes in docs
Jan 11, 2023
ecf01d8
Merge remote-tracking branch 'origin/feat-rewrite-v2' into feat-add-v…
Jan 11, 2023
5295dd1
refactor: rename save to mp4 file to save
Jan 11, 2023
b3f2ccb
feat: add shape method to comp backend
Jan 16, 2023
20ecf2c
refactor: move validate shape to video tensor mixin
Jan 16, 2023
711d105
refactor: extract private load and make separate methods for frames
Jan 16, 2023
0c9c1fd
fix: use torch shape instead of size method
Jan 16, 2023
e3a465c
fix: add typehint to shape in comp backend
Jan 16, 2023
40eac93
docs: add supported strings for skip type
Jan 16, 2023
a700f30
fix: apply suggestions from code review
Jan 17, 2023
94572fd
Merge remote-tracking branch 'origin/feat-rewrite-v2' into feat-add-v…
Jan 17, 2023
07ceae8
fix: small change to trigger ci again
Jan 17, 2023
c2e129d
fix: extract shape var
Jan 17, 2023
d50ae67
fix: introduce compbackendinterface
Jan 17, 2023
2e365e6
fix: revert previous pr and fix for mypy
Jan 17, 2023
c44a035
Merge remote-tracking branch 'origin/feat-rewrite-v2' into feat-add-v…
Jan 17, 2023
95b0b81
Merge remote-tracking branch 'origin/feat-rewrite-v2' into feat-add-v…
Jan 17, 2023
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
Prev Previous commit
Next Next commit
fix: apply suggestions from code review
Signed-off-by: anna-charlotte <[email protected]>
  • Loading branch information
anna-charlotte committed Jan 17, 2023
commit a700f308a743e7ada0f90f3bc5d97852ee5d47cd
18 changes: 9 additions & 9 deletions docarray/documents/video.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from typing import Optional, TypeVar

from docarray.base_document import BaseDocument
from docarray.documents import Audio
from docarray.typing import AnyEmbedding, AnyTensor
from docarray.typing.tensor.audio.audio_tensor import AudioTensor
from docarray.typing.tensor.video.video_tensor import VideoTensor
from docarray.typing.url.video_url import VideoUrl

Expand All @@ -12,10 +12,10 @@
class Video(BaseDocument):
"""
Document for handling video.
The Video Document can contain a VideoUrl (`Video.url`), an AudioTensor
(`Video.audio_tensor`), a VideoTensor (`Video.video_tensor`), an AnyTensor
representing the indices of the video's key frames (`Video.key_frame_indices`),
and an AnyEmbedding (`Video.embedding`).
The Video Document can contain a VideoUrl (`Video.url`), an Audio Document
(`Video.audio`), a VideoTensor (`Video.video_tensor`), an AnyTensor representing
the indices of the video's key frames (`Video.key_frame_indices`) and an
AnyEmbedding (`Video.embedding`).

EXAMPLE USAGE:

Expand All @@ -29,7 +29,7 @@ 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.video_tensor, vid.key_frame_indices = vid.url.load()
model = MyEmbeddingModel()
vid.embedding = model(vid.video_tensor)

Expand All @@ -50,7 +50,7 @@ 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(only_keyframes=True)
video.video_tensor = video.url.load_key_frames()
model = MyEmbeddingModel()
video.embedding = model(video.video_tensor)
video.name = Text(text='my first video')
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(only_keyframes=True)
mmdoc.video.video_tensor = mmdoc.video.url.load_key_frames()
"""

url: Optional[VideoUrl]
audio_tensor: Optional[AudioTensor]
audio: Optional[Audio] = Audio()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not None as a default value ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The .load() from VideoUrl returns an AudioNdArray (and some other stuff), which can't be written to video.audio.tensor if video.audio == None.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay makes sense

video_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.video_tensor, vid.key_frame_indices = vid.url.load()

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