Project import generated by Copybara.
GitOrigin-RevId: 852dfb05d450167899c0dd5ef7c45622a12e865b
This commit is contained in:
committed by
Hadon Nash
parent
d144e564d8
commit
de4fbc10e6
@@ -40,7 +40,7 @@ cc_library(
|
||||
# Demos
|
||||
|
||||
cc_binary(
|
||||
name = "object_detection_cpu",
|
||||
name = "object_detection_tpu",
|
||||
deps = [
|
||||
"//mediapipe/examples/coral:demo_run_graph_main",
|
||||
"//mediapipe/graphs/object_detection:desktop_tflite_calculators",
|
||||
@@ -48,7 +48,7 @@ cc_binary(
|
||||
)
|
||||
|
||||
cc_binary(
|
||||
name = "face_detection_cpu",
|
||||
name = "face_detection_tpu",
|
||||
deps = [
|
||||
"//mediapipe/examples/coral:demo_run_graph_main",
|
||||
"//mediapipe/graphs/face_detection:desktop_tflite_calculators",
|
||||
|
||||
@@ -19,13 +19,13 @@ Docker container for building MediaPipe applications that run on Edge TPU.
|
||||
* (on coral device) prepare MediaPipe
|
||||
|
||||
cd ~
|
||||
sudo apt-get install git
|
||||
sudo apt-get install -y git
|
||||
git clone https://github.com/google/mediapipe.git
|
||||
mkdir mediapipe/bazel-bin
|
||||
|
||||
* (on coral device) install opencv 3.2
|
||||
|
||||
sudo apt-get update && apt-get install -y libopencv-dev
|
||||
sudo apt-get update && sudo apt-get install -y libopencv-dev
|
||||
|
||||
* (on coral device) find all opencv libs
|
||||
|
||||
@@ -78,7 +78,7 @@ Docker container for building MediaPipe applications that run on Edge TPU.
|
||||
|
||||
return NULL;
|
||||
|
||||
* Edit /edgetpu/libedgetpu/BUILD
|
||||
* Edit /edgetpu/libedgetpu/BUILD
|
||||
|
||||
to add this build target
|
||||
|
||||
@@ -90,9 +90,9 @@ Docker container for building MediaPipe applications that run on Edge TPU.
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
* Edit *tflite_inference_calculator.cc* BUILD rules:
|
||||
* Edit /mediapipe/mediapipe/calculators/tflite/BUILD to change rules for *tflite_inference_calculator.cc*
|
||||
|
||||
sed -i 's/\":tflite_inference_calculator_cc_proto\",/\":tflite_inference_calculator_cc_proto\",\n\t\"@edgetpu\/\/:header\",\n\t\"@libedgetpu\/\/:lib\",/g' mediapipe/calculators/tflite/BUILD
|
||||
sed -i 's/\":tflite_inference_calculator_cc_proto\",/\":tflite_inference_calculator_cc_proto\",\n\t\"@edgetpu\/\/:header\",\n\t\"@libedgetpu\/\/:lib\",/g' /mediapipe/mediapipe/calculators/tflite/BUILD
|
||||
|
||||
The above command should add
|
||||
|
||||
@@ -105,37 +105,37 @@ Docker container for building MediaPipe applications that run on Edge TPU.
|
||||
|
||||
* Object detection demo
|
||||
|
||||
bazel build -c opt --crosstool_top=@crosstool//:toolchains --compiler=gcc --cpu=aarch64 --define MEDIAPIPE_DISABLE_GPU=1 --copt -DMEDIAPIPE_EDGE_TPU --copt=-flax-vector-conversions mediapipe/examples/coral:object_detection_cpu
|
||||
bazel build -c opt --crosstool_top=@crosstool//:toolchains --compiler=gcc --cpu=aarch64 --define MEDIAPIPE_DISABLE_GPU=1 --copt -DMEDIAPIPE_EDGE_TPU --copt=-flax-vector-conversions mediapipe/examples/coral:object_detection_tpu
|
||||
|
||||
Copy object_detection_cpu binary to the MediaPipe checkout on the coral device
|
||||
Copy object_detection_tpu binary to the MediaPipe checkout on the coral device
|
||||
|
||||
# outside docker env, open new terminal on host machine #
|
||||
docker ps
|
||||
docker cp <container-id>:/mediapipe/bazel-bin/mediapipe/examples/coral/object_detection_cpu /tmp/.
|
||||
mdt push /tmp/object_detection_cpu /home/mendel/mediapipe/bazel-bin/.
|
||||
docker cp <container-id>:/mediapipe/bazel-bin/mediapipe/examples/coral/object_detection_tpu /tmp/.
|
||||
mdt push /tmp/object_detection_tpu /home/mendel/mediapipe/bazel-bin/.
|
||||
|
||||
* Face detection demo
|
||||
|
||||
bazel build -c opt --crosstool_top=@crosstool//:toolchains --compiler=gcc --cpu=aarch64 --define MEDIAPIPE_DISABLE_GPU=1 --copt -DMEDIAPIPE_EDGE_TPU --copt=-flax-vector-conversions mediapipe/examples/coral:face_detection_cpu
|
||||
bazel build -c opt --crosstool_top=@crosstool//:toolchains --compiler=gcc --cpu=aarch64 --define MEDIAPIPE_DISABLE_GPU=1 --copt -DMEDIAPIPE_EDGE_TPU --copt=-flax-vector-conversions mediapipe/examples/coral:face_detection_tpu
|
||||
|
||||
Copy face_detection_cpu binary to the MediaPipe checkout on the coral device
|
||||
Copy face_detection_tpu binary to the MediaPipe checkout on the coral device
|
||||
|
||||
# outside docker env, open new terminal on host machine #
|
||||
docker ps
|
||||
docker cp <container-id>:/mediapipe/bazel-bin/mediapipe/examples/coral/face_detection_cpu /tmp/.
|
||||
mdt push /tmp/face_detection_cpu /home/mendel/mediapipe/bazel-bin/.
|
||||
docker cp <container-id>:/mediapipe/bazel-bin/mediapipe/examples/coral/face_detection_tpu /tmp/.
|
||||
mdt push /tmp/face_detection_tpu /home/mendel/mediapipe/bazel-bin/.
|
||||
|
||||
## On the coral device (with display)
|
||||
|
||||
# Object detection
|
||||
cd ~/mediapipe
|
||||
chmod +x bazel-bin/object_detection_cpu
|
||||
chmod +x bazel-bin/object_detection_tpu
|
||||
export GLOG_logtostderr=1
|
||||
bazel-bin/object_detection_cpu --calculator_graph_config_file=mediapipe/examples/coral/graphs/object_detection_desktop_live.pbtxt
|
||||
bazel-bin/object_detection_tpu --calculator_graph_config_file=mediapipe/examples/coral/graphs/object_detection_desktop_live.pbtxt
|
||||
|
||||
# Face detection
|
||||
cd ~/mediapipe
|
||||
chmod +x bazel-bin/face_detection_cpu
|
||||
chmod +x bazel-bin/face_detection_tpu
|
||||
export GLOG_logtostderr=1
|
||||
bazel-bin/face_detection_cpu --calculator_graph_config_file=mediapipe/examples/coral/graphs/face_detection_desktop_live.pbtxt
|
||||
bazel-bin/face_detection_tpu --calculator_graph_config_file=mediapipe/examples/coral/graphs/face_detection_desktop_live.pbtxt
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# MediaPipe graph that performs face detection with TensorFlow Lite on CPU.
|
||||
# MediaPipe graph that performs face detection with TensorFlow Lite on TPU.
|
||||
# Used in the examples in
|
||||
# mediapipe/examples/coral:face_detection_cpu.
|
||||
# mediapipe/examples/coral:face_detection_tpu.
|
||||
|
||||
# Images on GPU coming into and out of the graph.
|
||||
input_stream: "input_video"
|
||||
@@ -36,7 +36,7 @@ node {
|
||||
node: {
|
||||
calculator: "ImageTransformationCalculator"
|
||||
input_stream: "IMAGE:throttled_input_video"
|
||||
output_stream: "IMAGE:transformed_input_video_cpu"
|
||||
output_stream: "IMAGE:transformed_input_video"
|
||||
output_stream: "LETTERBOX_PADDING:letterbox_padding"
|
||||
options: {
|
||||
[mediapipe.ImageTransformationCalculatorOptions.ext] {
|
||||
@@ -51,7 +51,7 @@ node: {
|
||||
# TfLiteTensor.
|
||||
node {
|
||||
calculator: "TfLiteConverterCalculator"
|
||||
input_stream: "IMAGE:transformed_input_video_cpu"
|
||||
input_stream: "IMAGE:transformed_input_video"
|
||||
output_stream: "TENSORS:image_tensor"
|
||||
options: {
|
||||
[mediapipe.TfLiteConverterCalculatorOptions.ext] {
|
||||
@@ -60,7 +60,7 @@ node {
|
||||
}
|
||||
}
|
||||
|
||||
# Runs a TensorFlow Lite model on CPU that takes an image tensor and outputs a
|
||||
# Runs a TensorFlow Lite model on TPU that takes an image tensor and outputs a
|
||||
# vector of tensors representing, for instance, detection boxes/keypoints and
|
||||
# scores.
|
||||
node {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# MediaPipe graph that performs object detection with TensorFlow Lite on CPU.
|
||||
# MediaPipe graph that performs object detection with TensorFlow Lite on TPU.
|
||||
# Used in the examples in
|
||||
# mediapipie/examples/coral:object_detection_cpu.
|
||||
# mediapipie/examples/coral:object_detection_tpu.
|
||||
|
||||
# Images on CPU coming into and out of the graph.
|
||||
# Images on TPU coming into and out of the graph.
|
||||
input_stream: "input_video"
|
||||
output_stream: "output_video"
|
||||
|
||||
@@ -30,7 +30,7 @@ node {
|
||||
output_stream: "throttled_input_video"
|
||||
}
|
||||
|
||||
# Transforms the input image on CPU to a 320x320 image. To scale the image, by
|
||||
# Transforms the input image on CPU to a 300x300 image. To scale the image, by
|
||||
# default it uses the STRETCH scale mode that maps the entire input image to the
|
||||
# entire transformed image. As a result, image aspect ratio may be changed and
|
||||
# objects in the image may be deformed (stretched or squeezed), but the object
|
||||
@@ -60,7 +60,7 @@ node {
|
||||
}
|
||||
}
|
||||
|
||||
# Runs a TensorFlow Lite model on CPU that takes an image tensor and outputs a
|
||||
# Runs a TensorFlow Lite model on TPU that takes an image tensor and outputs a
|
||||
# vector of tensors representing, for instance, detection boxes/keypoints and
|
||||
# scores.
|
||||
node {
|
||||
|
||||
@@ -25,7 +25,7 @@ import sys
|
||||
|
||||
from absl import app
|
||||
import tensorflow.compat.v1 as tf
|
||||
from tensorflow.python.tools import freeze_graph
|
||||
from tensorflow.compat.v1.python.tools import freeze_graph
|
||||
|
||||
BASE_DIR = '/tmp/mediapipe/'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user