Project import generated by Copybara.
GitOrigin-RevId: 5aca6b3f07b67e09988a901f50f595ca5f566e67
This commit is contained in:
@@ -68,13 +68,15 @@ import os
|
||||
import random
|
||||
import subprocess
|
||||
import sys
|
||||
import tarfile
|
||||
import tempfile
|
||||
import urllib
|
||||
import zipfile
|
||||
|
||||
from absl import app
|
||||
from absl import flags
|
||||
from absl import logging
|
||||
import tensorflow as tf
|
||||
|
||||
from mediapipe.util.sequence import media_sequence as ms
|
||||
|
||||
CITATION = r"""@article{kay2017kinetics,
|
||||
@@ -84,21 +86,28 @@ CITATION = r"""@article{kay2017kinetics,
|
||||
year={2017},
|
||||
url = {https://deepmind.com/research/open-source/kinetics},
|
||||
}"""
|
||||
ANNOTATION_URL = "https://storage.googleapis.com/deepmind-media/research/Kinetics_700.zip"
|
||||
ANNOTATION_URL = "https://storage.googleapis.com/deepmind-media/Datasets/kinetics700.tar.gz"
|
||||
SECONDS_TO_MICROSECONDS = 1000000
|
||||
GRAPHS = ["tvl1_flow_and_rgb_from_file.pbtxt"]
|
||||
FILEPATTERN = "kinetics_700_%s_25fps_rgb_flow"
|
||||
SPLITS = {
|
||||
"train": {
|
||||
"shards": 1000,
|
||||
"examples": 545317},
|
||||
"val": {"shards": 100,
|
||||
"examples": 35000},
|
||||
"test": {"shards": 100,
|
||||
"examples": 70000},
|
||||
"custom": {"csv": None, # Add a CSV for your own data here.
|
||||
"shards": 1, # Change this number to increase sharding.
|
||||
"examples": -1}, # Negative 1 allows any number of examples.
|
||||
"examples": 541632
|
||||
},
|
||||
"validate": {
|
||||
"shards": 100,
|
||||
"examples": 34727
|
||||
},
|
||||
"test": {
|
||||
"shards": 100,
|
||||
"examples": 69347
|
||||
},
|
||||
"custom": {
|
||||
"csv": None, # Add a CSV for your own data here.
|
||||
"shards": 1, # Change this number to increase sharding.
|
||||
"examples": -1
|
||||
}, # Negative 1 allows any number of examples.
|
||||
}
|
||||
NUM_CLASSES = 700
|
||||
|
||||
@@ -312,18 +321,16 @@ class Kinetics(object):
|
||||
logging.info("Downloading annotations.")
|
||||
paths = {}
|
||||
if download_labels_for_map:
|
||||
zip_path = os.path.join(self.path_to_data, ANNOTATION_URL.split("/")[-1])
|
||||
if not tf.io.gfile.exists(zip_path):
|
||||
urlretrieve(ANNOTATION_URL, zip_path)
|
||||
with zipfile.ZipFile(zip_path) as annotations_zip:
|
||||
annotations_zip.extractall(self.path_to_data)
|
||||
for split in ["train", "test", "val"]:
|
||||
zip_path = os.path.join(self.path_to_data,
|
||||
"kinetics_700_%s.zip" % split)
|
||||
csv_path = zip_path.replace(".zip", ".csv")
|
||||
tar_path = os.path.join(self.path_to_data, ANNOTATION_URL.split("/")[-1])
|
||||
if not tf.io.gfile.exists(tar_path):
|
||||
urlretrieve(ANNOTATION_URL, tar_path)
|
||||
with tarfile.open(tar_path) as annotations_tar:
|
||||
annotations_tar.extractall(self.path_to_data)
|
||||
for split in ["train", "test", "validate"]:
|
||||
csv_path = os.path.join(self.path_to_data, "kinetics700/%s.csv" % split)
|
||||
if not tf.io.gfile.exists(csv_path):
|
||||
with zipfile.ZipFile(zip_path) as annotations_zip:
|
||||
annotations_zip.extractall(self.path_to_data)
|
||||
with tarfile.open(tar_path) as annotations_tar:
|
||||
annotations_tar.extractall(self.path_to_data)
|
||||
paths[split] = csv_path
|
||||
for split, contents in SPLITS.items():
|
||||
if "csv" in contents and contents["csv"]:
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
# Copyright 2019 The MediaPipe Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
licenses(["notice"]) # Apache 2.0
|
||||
|
||||
package(default_visibility = ["//mediapipe/examples:__subpackages__"])
|
||||
|
||||
cc_binary(
|
||||
name = "multi_hand_tracking_tflite",
|
||||
deps = [
|
||||
"//mediapipe/examples/desktop:simple_run_graph_main",
|
||||
"//mediapipe/graphs/hand_tracking:multi_hand_desktop_tflite_calculators",
|
||||
],
|
||||
)
|
||||
|
||||
cc_binary(
|
||||
name = "multi_hand_tracking_cpu",
|
||||
deps = [
|
||||
"//mediapipe/examples/desktop:demo_run_graph_main",
|
||||
"//mediapipe/graphs/hand_tracking:multi_hand_desktop_tflite_calculators",
|
||||
],
|
||||
)
|
||||
|
||||
# Linux only
|
||||
cc_binary(
|
||||
name = "multi_hand_tracking_gpu",
|
||||
deps = [
|
||||
"//mediapipe/examples/desktop:demo_run_graph_main_gpu",
|
||||
"//mediapipe/graphs/hand_tracking:multi_hand_mobile_calculators",
|
||||
],
|
||||
)
|
||||
@@ -16,51 +16,12 @@ licenses(["notice"]) # Apache 2.0
|
||||
|
||||
package(default_visibility = ["//mediapipe/examples:__subpackages__"])
|
||||
|
||||
cc_library(
|
||||
name = "object_detection_tensorflow_deps",
|
||||
deps = [
|
||||
"@org_tensorflow//tensorflow/c/kernels:bitcast_op",
|
||||
"@org_tensorflow//tensorflow/core:direct_session",
|
||||
"@org_tensorflow//tensorflow/core/kernels:argmax_op",
|
||||
"@org_tensorflow//tensorflow/core/kernels:bias_op",
|
||||
"@org_tensorflow//tensorflow/core/kernels:cast_op",
|
||||
"@org_tensorflow//tensorflow/core/kernels:concat_op",
|
||||
"@org_tensorflow//tensorflow/core/kernels:constant_op",
|
||||
"@org_tensorflow//tensorflow/core/kernels:control_flow_ops",
|
||||
"@org_tensorflow//tensorflow/core/kernels:conv_ops",
|
||||
"@org_tensorflow//tensorflow/core/kernels:cwise_op",
|
||||
"@org_tensorflow//tensorflow/core/kernels:depthwise_conv_op",
|
||||
"@org_tensorflow//tensorflow/core/kernels:fused_batch_norm_op",
|
||||
"@org_tensorflow//tensorflow/core/kernels:gather_op",
|
||||
"@org_tensorflow//tensorflow/core/kernels:identity_op",
|
||||
"@org_tensorflow//tensorflow/core/kernels:logging_ops",
|
||||
"@org_tensorflow//tensorflow/core/kernels:matmul_op",
|
||||
"@org_tensorflow//tensorflow/core/kernels:non_max_suppression_op",
|
||||
"@org_tensorflow//tensorflow/core/kernels:pack_op",
|
||||
"@org_tensorflow//tensorflow/core/kernels:reduction_ops",
|
||||
"@org_tensorflow//tensorflow/core/kernels:relu_op",
|
||||
"@org_tensorflow//tensorflow/core/kernels:reshape_op",
|
||||
"@org_tensorflow//tensorflow/core/kernels:resize_bilinear_op",
|
||||
"@org_tensorflow//tensorflow/core/kernels:sequence_ops",
|
||||
"@org_tensorflow//tensorflow/core/kernels:shape_ops",
|
||||
"@org_tensorflow//tensorflow/core/kernels:slice_op",
|
||||
"@org_tensorflow//tensorflow/core/kernels:split_op",
|
||||
"@org_tensorflow//tensorflow/core/kernels:tensor_array_ops",
|
||||
"@org_tensorflow//tensorflow/core/kernels:tile_ops",
|
||||
"@org_tensorflow//tensorflow/core/kernels:topk_op",
|
||||
"@org_tensorflow//tensorflow/core/kernels:transpose_op",
|
||||
"@org_tensorflow//tensorflow/core/kernels:unpack_op",
|
||||
"@org_tensorflow//tensorflow/core/kernels/data:tensor_dataset_op",
|
||||
],
|
||||
alwayslink = 1,
|
||||
)
|
||||
|
||||
cc_binary(
|
||||
name = "object_detection_tensorflow",
|
||||
deps = [
|
||||
":object_detection_tensorflow_deps",
|
||||
"//mediapipe/examples/desktop:simple_run_graph_main",
|
||||
"//mediapipe/graphs/object_detection:desktop_tensorflow_calculators",
|
||||
"@org_tensorflow//tensorflow/core:all_kernels",
|
||||
"@org_tensorflow//tensorflow/core:direct_session",
|
||||
],
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user