class_docstr: Generates and loads the Kinetics data set.
docstr: Downloads data and generates sharded TFRecords.
  
  Downloads the data files, generates metadata, and processes the metadata
  with MediaPipe to produce tf.SequenceExamples for training. The resulting
  files can be read with as_dataset(). After running this function the
  original data files can be deleted.
  
  Args:
    path_to_mediapipe_binary: Path to the compiled binary for the BUILD target
      mediapipe/examples/desktop/demo:media_sequence_demo.
    path_to_graph_directory: Path to the directory with MediaPipe graphs in
      mediapipe/graphs/media_sequence/.
    only_generate_metadata: If true, do not run mediapipe and write the
      metadata to disk instead.
    splits_to_process: csv string of which splits to process. Allows providing
      a custom CSV with the CSV flag. The original data is still downloaded
      to generate the label_map.
    video_path_format_string: The format string for the path to local files.
    download_labels_for_map: If true, download the annotations to create the
      label map.
docstr_tok: ["Downloads","data","and","generates","sharded","TFRecords",".","Downloads","the","data","files",",","generates","metadata",",","and","processes","the","metadata","with","MediaPipe","to","produce","tf.SequenceExamples","for","training",".","The","resulting","files","can","be","read","with","as_dataset","(",")",".","After","running","this","function","the","original","data","files","can","be","deleted",".","Args",":","path_to_mediapipe_binary",":","Path","to","the","compiled","binary","for","the","BUILD","target","mediapipe\/examples\/desktop\/demo",":","media_sequence_demo",".","path_to_graph_directory",":","Path","to","the","directory","with","MediaPipe","graphs","in","mediapipe\/graphs\/media_sequence\/",".","only_generate_metadata",":","If","true",",","do","not","run","mediapipe","and","write","the","metadata","to","disk","instead",".","splits_to_process",":","csv","string","of","which","splits","to","process",".","Allows","providing","a","custom","CSV","with","the","CSV","flag",".","The","original","data","is","still","downloaded","to","generate","the","label_map",".","video_path_format_string",":","The","format","string","for","the","path","to","local","files",".","download_labels_for_map",":","If","true",",","download","the","annotations","to","create","the","label","map","."]
code: def generate_examples(
      self,
      path_to_mediapipe_binary,
      path_to_graph_directory,
      only_generate_metadata=False,
      splits_to_process="train,val,test",
      video_path_format_string=None,
      download_labels_for_map=True,
  ):
      """Downloads data and generates sharded TFRecords.
  
      Downloads the data files, generates metadata, and processes the metadata
      with MediaPipe to produce tf.SequenceExamples for training. The resulting
      files can be read with as_dataset(). After running this function the
      original data files can be deleted.
  
      Args:
        path_to_mediapipe_binary: Path to the compiled binary for the BUILD target
          mediapipe/examples/desktop/demo:media_sequence_demo.
        path_to_graph_directory: Path to the directory with MediaPipe graphs in
          mediapipe/graphs/media_sequence/.
        only_generate_metadata: If true, do not run mediapipe and write the
          metadata to disk instead.
        splits_to_process: csv string of which splits to process. Allows providing
          a custom CSV with the CSV flag. The original data is still downloaded
          to generate the label_map.
        video_path_format_string: The format string for the path to local files.
        download_labels_for_map: If true, download the annotations to create the
          label map.
      """
      if not path_to_mediapipe_binary:
          raise ValueError(
              "You must supply the path to the MediaPipe binary for "
              "mediapipe/examples/desktop/demo:media_sequence_demo."
          )
      if not path_to_graph_directory:
          raise ValueError(
              "You must supply the path to the directory with MediaPipe graphs in "
              "mediapipe/graphs/media_sequence/."
          )
      logging.info("Downloading data.")
      download_output = self._download_data(download_labels_for_map)
      for key in splits_to_process.split(","):
          logging.info("Generating metadata for split: %s", key)
          all_metadata = list(
              self._generate_metadata(
                  key, download_output, video_path_format_string
              )
          )
          logging.info("An example of the metadata: ")
          logging.info(all_metadata[0])
          random.seed(47)
          random.shuffle(all_metadata)
          shards = SPLITS[key]["shards"]
          shard_names = [
              os.path.join(
                  self.path_to_data,
                  FILEPATTERN % key + "-%05d-of-%05d" % (i, shards),
              )
              for i in range(shards)
          ]
          writers = [
              tf.io.TFRecordWriter(shard_name)
              for shard_name in shard_names
          ]
          with _close_on_exit(writers) as writers:
              for i, seq_ex in enumerate(all_metadata):
                  if not only_generate_metadata:
                      print(
                          "Processing example %d of %d   (%d%%) \r"
                          % (
                              i,
                              len(all_metadata),
                              i * 100 / len(all_metadata),
                          ),
                          end="",
                      )
                      for graph in GRAPHS:
                          graph_path = os.path.join(
                              path_to_graph_directory, graph
                          )
                          seq_ex = self._run_mediapipe(
                              path_to_mediapipe_binary,
                              seq_ex,
                              graph_path,
                          )
                  writers[i % len(writers)].write(
                      seq_ex.SerializeToString()
                  )
      logging.info("Data extraction complete.")
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import contextlib
  import csv
  import os
  import random
  import subprocess
  import sys
  import tarfile
  import tempfile
  from absl import app
  from absl import flags
  from absl import logging
  from six.moves import range
  from six.moves import urllib
  from six.moves import zip
  import tensorflow.compat.v1
  from mediapipe.util.sequence import media_sequence
label_desc: Use image node_id 3 for calling the Kinetics obj's underlying member method code with example usage: obj.generate_examples(path_to_mediapipe_binary, path_to_graph_directory, only_generate_metadata, splits_to_process, video_path_format_string, download_labels_for_map) without return types