Skip to content

Commit 0dc7bf2

Browse files
author
The TensorFlow Datasets Authors
committed
Support huggingface Video feature
PiperOrigin-RevId: 770677201
1 parent b5effb6 commit 0dc7bf2

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

tensorflow_datasets/core/features/video_feature.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class Video(sequence_feature.Sequence):
9393

9494
def __init__(
9595
self,
96-
shape: Sequence[Optional[int]],
96+
shape: Sequence[Optional[int]] | None = None,
9797
encoding_format: str = 'png',
9898
ffmpeg_extra_args: Sequence[str] = (),
9999
use_colormap: bool = False,
@@ -121,6 +121,8 @@ def __init__(
121121
ValueError: If the shape is invalid
122122
"""
123123
dtype = tf.dtypes.as_dtype(dtype)
124+
if not shape:
125+
shape = (None, None, None, None)
124126
shape = tuple(shape)
125127
if len(shape) != 4:
126128
raise ValueError('Video shape should be of rank 4')

tensorflow_datasets/core/utils/huggingface_utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ def convert_hf_features(hf_features) -> feature_lib.FeatureConnector:
119119
sample_rate=hf_features.sampling_rate,
120120
dtype=np.int32,
121121
)
122+
case hf_datasets.Video():
123+
return feature_lib.Video()
122124

123125
raise TypeError(f'Type {type(hf_features)} is not supported.')
124126

0 commit comments

Comments
 (0)