def build_inputs(self, params: yt8m_cfg.DataConfig, input_context=None):
        """Builds input.

    Args:
      params: configuration for input data
      input_context: indicates information about the compute replicas and input
        pipelines

    Returns:
      dataset: dataset fetched from reader
    """

        decoder = yt8m_input.Decoder(input_params=params)
        decoder_fn = decoder.decode
        parser = yt8m_input.Parser(input_params=params)
        parser_fn = parser.parse_fn(params.is_training)
        postprocess = yt8m_input.PostBatchProcessor(input_params=params)
        postprocess_fn = postprocess.post_fn
        transform_batch = yt8m_input.TransformBatcher(input_params=params)
        batch_fn = transform_batch.batch_fn

        reader = input_reader.InputReader(params,
                                          dataset_fn=tf.data.TFRecordDataset,
                                          decoder_fn=decoder_fn,
                                          parser_fn=parser_fn,
                                          postprocess_fn=postprocess_fn,
                                          transform_and_batch_fn=batch_fn)

        dataset = reader.read(input_context=input_context)

        return dataset
Exemple #2
0
    def create_input_reader(self, params):
        decoder = yt8m_input.Decoder(input_params=params)
        decoder_fn = decoder.decode
        parser = yt8m_input.Parser(input_params=params)
        parser_fn = parser.parse_fn(params.is_training)
        postprocess = yt8m_input.PostBatchProcessor(input_params=params)
        postprocess_fn = postprocess.post_fn
        transform_batch = yt8m_input.TransformBatcher(input_params=params)
        batch_fn = transform_batch.batch_fn

        return input_reader.InputReader(params,
                                        dataset_fn=tf.data.TFRecordDataset,
                                        decoder_fn=decoder_fn,
                                        parser_fn=parser_fn,
                                        postprocess_fn=postprocess_fn,
                                        transform_and_batch_fn=batch_fn)