How to use the mediapipe.util.sequence.media_sequence function in mediapipe

To help you get started, we’ve selected a few mediapipe examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github google / mediapipe / mediapipe / examples / desktop / media_sequence / charades_dataset.py View on Github external
action_start_times = []
        action_end_times = []
        for action in actions:
          if not action:
            continue
          string, start, end = action.split(" ")
          action_indices.append(int(string[1:]))
          action_strings.append(bytes23(string))
          action_start_times.append(int(float(start) * SECONDS_TO_MICROSECONDS))
          action_end_times.append(int(float(end) * SECONDS_TO_MICROSECONDS))
        ms.set_example_id(bytes23(row["id"]), metadata)
        ms.set_clip_data_path(bytes23(filepath), metadata)
        ms.set_clip_start_timestamp(0, metadata)
        ms.set_clip_end_timestamp(
            int(float(row["length"]) * SECONDS_TO_MICROSECONDS), metadata)
        ms.set_segment_start_timestamp(action_start_times, metadata)
        ms.set_segment_end_timestamp(action_end_times, metadata)
        ms.set_segment_label_string(action_strings, metadata)
        ms.set_segment_label_index(action_indices, metadata)
        yield metadata
github google / mediapipe / mediapipe / examples / desktop / media_sequence / kinetics_dataset.py View on Github external
reader = csv.reader(annotations)
      for i, csv_row in enumerate(reader):
        if i == 0:  # the first row is the header
          continue
        # rename the row with a constitent set of names.
        if len(csv_row) == 5:
          row = dict(zip(["label_name", "video", "start", "end", "split"],
                         csv_row))
        else:
          row = dict(zip(["video", "start", "end", "split"],
                         csv_row))
        metadata = tf.train.SequenceExample()
        ms.set_example_id(bytes23(row["video"] + "_" + row["start"]),
                          metadata)
        ms.set_clip_media_id(bytes23(row["video"]), metadata)
        ms.set_clip_alternative_media_id(bytes23(row["split"]), metadata)
        if video_path_format_string:
          filepath = video_path_format_string.format(**row)
          ms.set_clip_data_path(bytes23(filepath), metadata)
        assert row["start"].isdigit(), "Invalid row: %s" % str(row)
        assert row["end"].isdigit(), "Invalid row: %s" % str(row)
        if "label_name" in row:
          ms.set_clip_label_string([bytes23(row["label_name"])], metadata)
          if label_map:
            ms.set_clip_label_index([label_map[row["label_name"]]], metadata)
        yield metadata
github google / mediapipe / mediapipe / examples / desktop / media_sequence / charades_dataset.py View on Github external
if not action:
            continue
          string, start, end = action.split(" ")
          action_indices.append(int(string[1:]))
          action_strings.append(bytes23(string))
          action_start_times.append(int(float(start) * SECONDS_TO_MICROSECONDS))
          action_end_times.append(int(float(end) * SECONDS_TO_MICROSECONDS))
        ms.set_example_id(bytes23(row["id"]), metadata)
        ms.set_clip_data_path(bytes23(filepath), metadata)
        ms.set_clip_start_timestamp(0, metadata)
        ms.set_clip_end_timestamp(
            int(float(row["length"]) * SECONDS_TO_MICROSECONDS), metadata)
        ms.set_segment_start_timestamp(action_start_times, metadata)
        ms.set_segment_end_timestamp(action_end_times, metadata)
        ms.set_segment_label_string(action_strings, metadata)
        ms.set_segment_label_index(action_indices, metadata)
        yield metadata
github google / mediapipe / mediapipe / examples / desktop / media_sequence / kinetics_dataset.py View on Github external
csv_row))
        else:
          row = dict(zip(["video", "start", "end", "split"],
                         csv_row))
        metadata = tf.train.SequenceExample()
        ms.set_example_id(bytes23(row["video"] + "_" + row["start"]),
                          metadata)
        ms.set_clip_media_id(bytes23(row["video"]), metadata)
        ms.set_clip_alternative_media_id(bytes23(row["split"]), metadata)
        if video_path_format_string:
          filepath = video_path_format_string.format(**row)
          ms.set_clip_data_path(bytes23(filepath), metadata)
        assert row["start"].isdigit(), "Invalid row: %s" % str(row)
        assert row["end"].isdigit(), "Invalid row: %s" % str(row)
        if "label_name" in row:
          ms.set_clip_label_string([bytes23(row["label_name"])], metadata)
          if label_map:
            ms.set_clip_label_index([label_map[row["label_name"]]], metadata)
        yield metadata

mediapipe

MediaPipe is the simplest way for researchers and developers to build world-class ML solutions and applications for mobile, edge, cloud and the web.

Apache-2.0
Latest version published 12 days ago

Package Health Score

91 / 100
Full package analysis