Project import generated by Copybara.
GitOrigin-RevId: 4419aaa472eeb91123d1f8576188166ee0e5ea69
This commit is contained in:
@@ -11,6 +11,8 @@
|
||||
|
||||
2. Build and run the run_autoflip binary to process a local video.
|
||||
|
||||
Note: AutoFlip currently only works with OpenCV 3 . Please verify your OpenCV version beforehand.
|
||||
|
||||
```bash
|
||||
bazel build -c opt --define MEDIAPIPE_DISABLE_GPU=1 \
|
||||
mediapipe/examples/desktop/autoflip:run_autoflip
|
||||
|
||||
@@ -63,12 +63,15 @@ import random
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import urllib
|
||||
import zipfile
|
||||
|
||||
from absl import app
|
||||
from absl import flags
|
||||
from absl import logging
|
||||
from six.moves import range
|
||||
from six.moves import urllib
|
||||
import tensorflow.compat.v1 as tf
|
||||
|
||||
from mediapipe.util.sequence import media_sequence as ms
|
||||
|
||||
|
||||
@@ -218,7 +221,7 @@ class Charades(object):
|
||||
return output_dict
|
||||
|
||||
if split not in SPLITS:
|
||||
raise ValueError("Split %s not in %s" % split, str(SPLITS.keys()))
|
||||
raise ValueError("Split %s not in %s" % split, str(list(SPLITS.keys())))
|
||||
all_shards = tf.io.gfile.glob(
|
||||
os.path.join(self.path_to_data, SPLITS[split][0] + "-*-of-*"))
|
||||
random.shuffle(all_shards)
|
||||
@@ -329,7 +332,7 @@ class Charades(object):
|
||||
if sys.version_info >= (3, 0):
|
||||
urlretrieve = urllib.request.urlretrieve
|
||||
else:
|
||||
urlretrieve = urllib.urlretrieve
|
||||
urlretrieve = urllib.request.urlretrieve
|
||||
logging.info("Creating data directory.")
|
||||
tf.io.gfile.makedirs(self.path_to_data)
|
||||
logging.info("Downloading license.")
|
||||
|
||||
@@ -57,11 +57,12 @@ import random
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import urllib
|
||||
|
||||
from absl import app
|
||||
from absl import flags
|
||||
from absl import logging
|
||||
from six.moves import range
|
||||
from six.moves import urllib
|
||||
import tensorflow.compat.v1 as tf
|
||||
|
||||
from mediapipe.util.sequence import media_sequence as ms
|
||||
@@ -198,7 +199,7 @@ class DemoDataset(object):
|
||||
if sys.version_info >= (3, 0):
|
||||
urlretrieve = urllib.request.urlretrieve
|
||||
else:
|
||||
urlretrieve = urllib.urlretrieve
|
||||
urlretrieve = urllib.request.urlretrieve
|
||||
for split in SPLITS:
|
||||
reader = csv.DictReader(SPLITS[split].split("\n"))
|
||||
all_metadata = []
|
||||
|
||||
@@ -73,11 +73,13 @@ import subprocess
|
||||
import sys
|
||||
import tarfile
|
||||
import tempfile
|
||||
import urllib
|
||||
|
||||
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 as tf
|
||||
|
||||
from mediapipe.util.sequence import media_sequence as ms
|
||||
@@ -96,15 +98,15 @@ FILEPATTERN = "kinetics_700_%s_25fps_rgb_flow"
|
||||
SPLITS = {
|
||||
"train": {
|
||||
"shards": 1000,
|
||||
"examples": 540247
|
||||
"examples": 538779
|
||||
},
|
||||
"validate": {
|
||||
"shards": 100,
|
||||
"examples": 34610
|
||||
"examples": 34499
|
||||
},
|
||||
"test": {
|
||||
"shards": 100,
|
||||
"examples": 69103
|
||||
"examples": 68847
|
||||
},
|
||||
"custom": {
|
||||
"csv": None, # Add a CSV for your own data here.
|
||||
@@ -198,7 +200,7 @@ class Kinetics(object):
|
||||
return output_dict
|
||||
|
||||
if split not in SPLITS:
|
||||
raise ValueError("Split %s not in %s" % split, str(SPLITS.keys()))
|
||||
raise ValueError("Split %s not in %s" % split, str(list(SPLITS.keys())))
|
||||
all_shards = tf.io.gfile.glob(
|
||||
os.path.join(self.path_to_data, FILEPATTERN % split + "-*-of-*"))
|
||||
random.shuffle(all_shards)
|
||||
@@ -302,11 +304,12 @@ class Kinetics(object):
|
||||
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))
|
||||
row = dict(
|
||||
list(
|
||||
zip(["label_name", "video", "start", "end", "split"],
|
||||
csv_row)))
|
||||
else:
|
||||
row = dict(zip(["video", "start", "end", "split"],
|
||||
csv_row))
|
||||
row = dict(list(zip(["video", "start", "end", "split"], csv_row)))
|
||||
metadata = tf.train.SequenceExample()
|
||||
ms.set_example_id(bytes23(row["video"] + "_" + row["start"]),
|
||||
metadata)
|
||||
@@ -328,7 +331,7 @@ class Kinetics(object):
|
||||
if sys.version_info >= (3, 0):
|
||||
urlretrieve = urllib.request.urlretrieve
|
||||
else:
|
||||
urlretrieve = urllib.urlretrieve
|
||||
urlretrieve = urllib.request.urlretrieve
|
||||
logging.info("Creating data directory.")
|
||||
tf.io.gfile.makedirs(self.path_to_data)
|
||||
logging.info("Downloading annotations.")
|
||||
@@ -404,7 +407,7 @@ class Kinetics(object):
|
||||
assert NUM_CLASSES == num_keys, (
|
||||
"Found %d labels for split: %s, should be %d" % (
|
||||
num_keys, name, NUM_CLASSES))
|
||||
label_map = dict(zip(classes, range(len(classes))))
|
||||
label_map = dict(list(zip(classes, list(range(len(classes))))))
|
||||
if SPLITS[name]["examples"] > 0:
|
||||
assert SPLITS[name]["examples"] == num_examples, (
|
||||
"Found %d examples for split: %s, should be %d" % (
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
```bash
|
||||
# cd to the root directory of the MediaPipe repo
|
||||
cd -
|
||||
|
||||
pip3 install tf_slim
|
||||
python -m mediapipe.examples.desktop.youtube8m.generate_vggish_frozen_graph
|
||||
```
|
||||
|
||||
@@ -47,7 +49,7 @@
|
||||
5. Run the MediaPipe binary to extract the features.
|
||||
|
||||
```bash
|
||||
bazel build -c opt \
|
||||
bazel build -c opt --linkopt=-s \
|
||||
--define MEDIAPIPE_DISABLE_GPU=1 --define no_aws_support=true \
|
||||
mediapipe/examples/desktop/youtube8m:extract_yt8m_features
|
||||
|
||||
@@ -87,7 +89,7 @@
|
||||
3. Build and run the inference binary.
|
||||
|
||||
```bash
|
||||
bazel build -c opt --define='MEDIAPIPE_DISABLE_GPU=1' \
|
||||
bazel build -c opt --define='MEDIAPIPE_DISABLE_GPU=1' --linkopt=-s \
|
||||
mediapipe/examples/desktop/youtube8m:model_inference
|
||||
|
||||
GLOG_logtostderr=1 bazel-bin/mediapipe/examples/desktop/youtube8m/model_inference \
|
||||
@@ -113,13 +115,13 @@
|
||||
2. Build the inference binary.
|
||||
|
||||
```bash
|
||||
bazel build -c opt --define='MEDIAPIPE_DISABLE_GPU=1' \
|
||||
bazel build -c opt --define='MEDIAPIPE_DISABLE_GPU=1' --linkopt=-s \
|
||||
mediapipe/examples/desktop/youtube8m:model_inference
|
||||
```
|
||||
|
||||
3. Run the python web server.
|
||||
|
||||
Note: pip install absl-py
|
||||
Note: pip3 install absl-py
|
||||
|
||||
```bash
|
||||
python mediapipe/examples/desktop/youtube8m/viewer/server.py --root `pwd`
|
||||
@@ -142,7 +144,7 @@
|
||||
3. Build and run the inference binary.
|
||||
|
||||
```bash
|
||||
bazel build -c opt --define='MEDIAPIPE_DISABLE_GPU=1' \
|
||||
bazel build -c opt --define='MEDIAPIPE_DISABLE_GPU=1' --linkopt=-s \
|
||||
mediapipe/examples/desktop/youtube8m:model_inference
|
||||
|
||||
# segment_size is the number of seconds window of frames.
|
||||
|
||||
@@ -25,7 +25,7 @@ import sys
|
||||
|
||||
from absl import app
|
||||
import tensorflow.compat.v1 as tf
|
||||
from tensorflow.compat.v1.python.tools import freeze_graph
|
||||
from tensorflow.python.tools import freeze_graph
|
||||
|
||||
BASE_DIR = '/tmp/mediapipe/'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user