Beispiel #1
0
    def __init__(self, shape, encoding_format='png', ffmpeg_extra_args=()):
        """Initializes the connector.

    Args:
      shape: tuple of ints, the shape of the video (num_frames, height, width,
        channels), where channels is 1 or 3.
      encoding_format: The video is stored as a sequence of encoded images.
        You can use any encoding format supported by image_feature.Feature.
      ffmpeg_extra_args: A sequence of additional args to be passed to the
        ffmpeg binary. Specifically, ffmpeg will be called as:
          ``
          ffmpeg -i <input_file> <ffmpeg_extra_args> %010d.<encoding_format>
          ``
    Raises:
      ValueError: If the shape is invalid
    """
        shape = tuple(shape)
        if len(shape) != 4:
            raise ValueError('Video shape should be of rank 4')
        self._encoding_format = encoding_format
        self._extra_ffmpeg_args = list(ffmpeg_extra_args or [])
        super(Video, self).__init__(
            image_feature.Image(shape=shape[1:],
                                encoding_format=encoding_format),
            length=shape[0],
        )
Beispiel #2
0
    def __init__(
        self,
        shape: Sequence[Optional[int]],
        encoding_format: str = 'png',
        ffmpeg_extra_args: Sequence[str] = (),
        use_colormap: bool = False,
        dtype=tf.uint8,
        doc: feature_lib.DocArg = None,
    ):
        """Initializes the connector.

    Args:
      shape: tuple of ints, the shape of the video (num_frames, height, width,
        channels), where channels is 1 or 3.
      encoding_format: The video is stored as a sequence of encoded images. You
        can use any encoding format supported by image_feature.Feature.
      ffmpeg_extra_args: A sequence of additional args to be passed to the
        ffmpeg binary. Specifically, ffmpeg will be called as: `` ffmpeg -i
          <input_file> <ffmpeg_extra_args> %010d.<encoding_format> ``
      use_colormap: Forwarded to `tfds.features.Image`. If `True`,
        `tfds.as_dataframe` will display each value in the image with a
        different color.
      dtype: tf.uint16 or tf.uint8 (default). tf.uint16 can be used only with
        png encoding_format
      doc: Documentation of this feature (e.g. description).

    Raises:
      ValueError: If the shape is invalid
    """
        shape = tuple(shape)
        if len(shape) != 4:
            raise ValueError('Video shape should be of rank 4')
        self._encoding_format = encoding_format
        self._extra_ffmpeg_args = list(ffmpeg_extra_args or [])
        super(Video, self).__init__(
            image_feature.Image(
                shape=shape[1:],
                dtype=dtype,
                encoding_format=encoding_format,
                use_colormap=use_colormap,
            ),
            length=shape[0],
        )
Beispiel #3
0
    def __init__(self, shape):
        """Construct the connector.

    Args:
      shape: tuple of ints, the shape of the video (num_frames, height, width,
        channels), where channels is 1 or 3.

    Raises:
      ValueError: If the shape is invalid
    """
        shape = tuple(shape)
        if len(shape) != 4:
            raise ValueError('Video shape should be of rank 4')
        if shape.count(None) > 1:
            raise ValueError('Video shape cannot have more than 1 unknown dim')

        super(Video, self).__init__(
            image_feature.Image(shape=shape[1:], encoding_format='png'),
            length=shape[0],
        )