File tree Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -93,7 +93,7 @@ class Video(sequence_feature.Sequence):
93
93
94
94
def __init__ (
95
95
self ,
96
- shape : Sequence [Optional [int ]],
96
+ shape : Sequence [Optional [int ]] | None = None ,
97
97
encoding_format : str = 'png' ,
98
98
ffmpeg_extra_args : Sequence [str ] = (),
99
99
use_colormap : bool = False ,
@@ -121,19 +121,22 @@ def __init__(
121
121
ValueError: If the shape is invalid
122
122
"""
123
123
dtype = tf .dtypes .as_dtype (dtype )
124
- shape = tuple (shape )
125
- if len (shape ) != 4 :
126
- raise ValueError ('Video shape should be of rank 4' )
124
+ img_shape = None
125
+ if shape :
126
+ shape = tuple (shape )
127
+ if len (shape ) != 4 :
128
+ raise ValueError ('Video shape should be of rank 4' )
129
+ img_shape = shape [1 :]
127
130
self ._encoding_format = encoding_format
128
131
self ._extra_ffmpeg_args = list (ffmpeg_extra_args or [])
129
132
super (Video , self ).__init__ (
130
133
image_feature .Image (
131
- shape = shape [ 1 :] ,
134
+ shape = img_shape ,
132
135
dtype = dtype ,
133
136
encoding_format = encoding_format ,
134
137
use_colormap = use_colormap ,
135
138
),
136
- length = shape [0 ],
139
+ length = shape [0 ] if shape else None ,
137
140
)
138
141
139
142
def _ffmpeg_decode (self , path_or_fobj ):
Original file line number Diff line number Diff line change @@ -119,6 +119,8 @@ def convert_hf_features(hf_features) -> feature_lib.FeatureConnector:
119
119
sample_rate = hf_features .sampling_rate ,
120
120
dtype = np .int32 ,
121
121
)
122
+ case hf_datasets .Video ():
123
+ return feature_lib .Video ()
122
124
123
125
raise TypeError (f'Type { type (hf_features )} is not supported.' )
124
126
You can’t perform that action at this time.
0 commit comments