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
docs: small fixes in docs
Signed-off-by: anna-charlotte <[email protected]>
  • Loading branch information
anna-charlotte committed Jan 11, 2023
commit 7ab8dbd41af0d7ef7bb1a8b89a07d5b2e81af4ce
5 changes: 4 additions & 1 deletion docarray/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
from docarray.array.array import DocumentArray
from docarray.base_document.document import BaseDocument

__all__ = ['BaseDocument', 'DocumentArray']
__all__ = [
'BaseDocument',
'DocumentArray',
]
7 changes: 4 additions & 3 deletions docarray/computation/abstract_comp_backend.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import typing
from abc import ABC, abstractmethod
from typing import List, Optional, Tuple, TypeVar, Union
from typing import TYPE_CHECKING, List, Optional, Tuple, TypeVar, Union

import numpy as np
if TYPE_CHECKING:
import numpy as np

# In practice all of the below will be the same type
TTensor = TypeVar('TTensor')
Expand Down Expand Up @@ -38,7 +39,7 @@ def n_dim(array: 'TTensor') -> int:

@staticmethod
@abstractmethod
def to_numpy(array: 'TTensor') -> np.ndarray:
def to_numpy(array: 'TTensor') -> 'np.ndarray':
"""
Convert array to np.ndarray.
"""
Expand Down
2 changes: 1 addition & 1 deletion docarray/computation/numpy_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def n_dim(array: 'np.ndarray') -> int:
return array.ndim

@staticmethod
def to_numpy(array: 'np.ndarray') -> np.ndarray:
def to_numpy(array: 'np.ndarray') -> 'np.ndarray':
return array

@staticmethod
Expand Down
2 changes: 1 addition & 1 deletion docarray/computation/torch_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def n_dim(array: 'torch.Tensor') -> int:
return array.ndim

@staticmethod
def to_numpy(array: 'torch.Tensor') -> np.ndarray:
def to_numpy(array: 'torch.Tensor') -> 'np.ndarray':
return array.cpu().detach().numpy()

@staticmethod
Expand Down
3 changes: 2 additions & 1 deletion docarray/documents/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ 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
('Video.key_frame_indices), and an AnyEmbedding (`Video.embedding`).
representing the indices of the video's key frames (`Video.key_frame_indices`),
and an AnyEmbedding (`Video.embedding`).

EXAMPLE USAGE:

Expand Down
4 changes: 2 additions & 2 deletions docarray/typing/tensor/video/abstract_video_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ class AbstractVideoTensor(AbstractTensor, ABC):
def save_to_mp4_file(
self: 'T',
file_path: Union[str, BinaryIO],
audio_tensor: Optional[AudioTensor] = None,
video_frame_rate: int = 24,
video_codec: str = 'h264',
audio_tensor: Optional[AudioTensor] = None,
audio_frame_rate: int = 48000,
audio_codec: str = 'aac',
audio_format: str = 'fltp',
Expand All @@ -25,9 +25,9 @@ def save_to_mp4_file(

:param file_path: path to a .mp4 file. If file is a string, open the file by
that name, otherwise treat it as a file-like object.
:param audio_tensor: AudioTensor containing the video's soundtrack.
:param video_frame_rate: video frames per second.
:param video_codec: the name of a video decoder/encoder.
:param audio_tensor: AudioTensor that should be added as soundtrack.
:param audio_frame_rate: audio frames per second.
:param audio_codec: the name of an audio decoder/encoder.
:param audio_format: the name of one of the audio formats supported by PyAV,
Expand Down
8 changes: 6 additions & 2 deletions docarray/typing/url/video_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ class MyDoc(BaseDocument):
key_frame_indices: Optional[NdArray]


doc = MyDoc(video_url='toydata/mov_bbb.mp4')
doc = MyDoc(
video_url='https://github.com/docarray/docarray/tree/feat-add-video-v2/tests/toydata/mov_bbb.mp4?raw=true'
)
doc.audio, doc.video, doc.key_frame_indices = doc.video_url.load()

assert isinstance(doc.video, VideoNdArray)
Expand All @@ -109,7 +111,9 @@ class MyDoc(BaseDocument):
video_key_frames: Optional[VideoNdArray]


doc = MyDoc(video_url='toydata/mov_bbb.mp4')
doc = MyDoc(
video_url='https://github.com/docarray/docarray/tree/feat-add-video-v2/tests/toydata/mov_bbb.mp4?raw=true'
)
doc.video_key_frames = doc.video_url.load(only_keyframes=True)

assert isinstance(doc.video_key_frames, VideoNdArray)
Expand Down