Project import generated by Copybara.
GitOrigin-RevId: 5b23708185311ae39a8605b0c2eff721e7b4939f
This commit is contained in:
@@ -8,4 +8,5 @@ Each module (represented as a subfolder) provides subgraphs and corresponding re
|
||||
| :--- | :--- |
|
||||
| [`face_detection`](face_detection/README.md) | Subgraphs to detect faces. |
|
||||
| [`face_landmark`](face_landmark/README.md) | Subgraphs to detect and track face landmarks. |
|
||||
| [`iris_landmark`](iris_landmark/README.md) | Subgraphs to detect iris landmarks. |
|
||||
|
||||
|
||||
@@ -60,6 +60,7 @@ node {
|
||||
options: {
|
||||
[mediapipe.TfLiteInferenceCalculatorOptions.ext] {
|
||||
model_path: "mediapipe/modules/face_detection/face_detection_front.tflite"
|
||||
delegate { xnnpack {} }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,6 +74,7 @@ node {
|
||||
options: {
|
||||
[mediapipe.TfLiteInferenceCalculatorOptions.ext] {
|
||||
model_path: "mediapipe/modules/face_landmark/face_landmark.tflite"
|
||||
delegate { xnnpack {} }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
# Copyright 2020 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.
|
||||
|
||||
load(
|
||||
"//mediapipe/framework/tool:mediapipe_graph.bzl",
|
||||
"mediapipe_simple_subgraph",
|
||||
)
|
||||
|
||||
licenses(["notice"]) # Apache 2.0
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
mediapipe_simple_subgraph(
|
||||
name = "iris_landmark_cpu",
|
||||
graph = "iris_landmark_cpu.pbtxt",
|
||||
register_as = "IrisLandmarkCpu",
|
||||
deps = [
|
||||
"//mediapipe/calculators/core:clip_vector_size_calculator",
|
||||
"//mediapipe/calculators/core:split_vector_calculator",
|
||||
"//mediapipe/calculators/image:image_cropping_calculator",
|
||||
"//mediapipe/calculators/image:image_properties_calculator",
|
||||
"//mediapipe/calculators/image:image_transformation_calculator",
|
||||
"//mediapipe/calculators/tflite:tflite_converter_calculator",
|
||||
"//mediapipe/calculators/tflite:tflite_inference_calculator",
|
||||
"//mediapipe/calculators/tflite:tflite_tensors_to_floats_calculator",
|
||||
"//mediapipe/calculators/tflite:tflite_tensors_to_landmarks_calculator",
|
||||
"//mediapipe/calculators/util:landmark_letterbox_removal_calculator",
|
||||
"//mediapipe/calculators/util:landmark_projection_calculator",
|
||||
],
|
||||
)
|
||||
|
||||
mediapipe_simple_subgraph(
|
||||
name = "iris_landmark_gpu",
|
||||
graph = "iris_landmark_gpu.pbtxt",
|
||||
register_as = "IrisLandmarkGpu",
|
||||
deps = [
|
||||
"//mediapipe/calculators/core:clip_vector_size_calculator",
|
||||
"//mediapipe/calculators/core:split_vector_calculator",
|
||||
"//mediapipe/calculators/image:image_cropping_calculator",
|
||||
"//mediapipe/calculators/image:image_properties_calculator",
|
||||
"//mediapipe/calculators/image:image_transformation_calculator",
|
||||
"//mediapipe/calculators/tflite:tflite_converter_calculator",
|
||||
"//mediapipe/calculators/tflite:tflite_inference_calculator",
|
||||
"//mediapipe/calculators/tflite:tflite_tensors_to_floats_calculator",
|
||||
"//mediapipe/calculators/tflite:tflite_tensors_to_landmarks_calculator",
|
||||
"//mediapipe/calculators/util:landmark_letterbox_removal_calculator",
|
||||
"//mediapipe/calculators/util:landmark_projection_calculator",
|
||||
],
|
||||
)
|
||||
|
||||
mediapipe_simple_subgraph(
|
||||
name = "iris_landmark_left_and_right_gpu",
|
||||
graph = "iris_landmark_left_and_right_gpu.pbtxt",
|
||||
register_as = "IrisLandmarkLeftAndRightGpu",
|
||||
deps = [
|
||||
":iris_landmark_gpu",
|
||||
":iris_landmark_landmarks_to_roi",
|
||||
"//mediapipe/calculators/core:constant_side_packet_calculator",
|
||||
"//mediapipe/calculators/core:side_packet_to_stream_calculator",
|
||||
"//mediapipe/calculators/image:image_properties_calculator",
|
||||
],
|
||||
)
|
||||
|
||||
mediapipe_simple_subgraph(
|
||||
name = "iris_landmark_left_and_right_cpu",
|
||||
graph = "iris_landmark_left_and_right_cpu.pbtxt",
|
||||
register_as = "IrisLandmarkLeftAndRightCpu",
|
||||
deps = [
|
||||
":iris_landmark_cpu",
|
||||
":iris_landmark_landmarks_to_roi",
|
||||
"//mediapipe/calculators/core:constant_side_packet_calculator",
|
||||
"//mediapipe/calculators/core:side_packet_to_stream_calculator",
|
||||
"//mediapipe/calculators/image:image_properties_calculator",
|
||||
],
|
||||
)
|
||||
|
||||
exports_files(
|
||||
srcs = [
|
||||
"iris_landmark.tflite",
|
||||
],
|
||||
)
|
||||
|
||||
mediapipe_simple_subgraph(
|
||||
name = "iris_landmark_landmarks_to_roi",
|
||||
graph = "iris_landmark_landmarks_to_roi.pbtxt",
|
||||
register_as = "IrisLandmarkLandmarksToRoi",
|
||||
deps = [
|
||||
"//mediapipe/calculators/util:detections_to_rects_calculator",
|
||||
"//mediapipe/calculators/util:landmarks_to_detection_calculator",
|
||||
"//mediapipe/calculators/util:rect_transformation_calculator",
|
||||
],
|
||||
)
|
||||
@@ -0,0 +1,8 @@
|
||||
# iris_landmark
|
||||
|
||||
Subgraphs|Details
|
||||
:--- | :---
|
||||
[`IrisLandmarkCpu`](https://github.com/google/mediapipe/tree/master/mediapipe/modules/iris_landmark/iris_landmark_cpu.pbtxt)| Detects iris landmarks for left or right eye. (CPU input, and inference is executed on CPU.)
|
||||
[`IrisLandmarkGpu`](https://github.com/google/mediapipe/tree/master/mediapipe/modules/iris_landmark/iris_landmark_gpu.pbtxt)| Detects iris landmarks for left or right eye. (GPU input, and inference is executed on GPU)
|
||||
[`IrisLandmarkLeftAndRightCpu`](https://github.com/google/mediapipe/tree/master/mediapipe/modules/iris_landmark/iris_landmark_left_and_right_cpu.pbtxt)| Detects iris landmarks for both left and right eyes. (CPU input, and inference is executed on CPU)
|
||||
[`IrisLandmarkLeftAndRightGpu`](https://github.com/google/mediapipe/tree/master/mediapipe/modules/iris_landmark/iris_landmark_left_and_right_gpu.pbtxt)| Detects iris landmarks for both left and right eyes. (GPU input, and inference is executed on GPU.)
|
||||
BIN
Binary file not shown.
@@ -0,0 +1,156 @@
|
||||
# MediaPipe subgraph to calculate iris landmarks and eye contour landmarks for
|
||||
# a single eye. (CPU input, and inference is executed on CPU.)
|
||||
#
|
||||
# It is required that "iris_landmark.tflite" is available at
|
||||
# "mediapipe/modules/iris_landmark/iris_landmark.tflite"
|
||||
# path during execution.
|
||||
#
|
||||
# EXAMPLE:
|
||||
# node {
|
||||
# calculator: "IrisLandmarkCpu"
|
||||
# input_stream: "IMAGE:image"
|
||||
# input_stream: "ROI:eye_roi"
|
||||
# input_stream: "IS_RIGHT_EYE:is_right_eye"
|
||||
# output_stream: "EYE_CONTOUR_LANDMARKS:eye_contour_landmarks"
|
||||
# output_stream: "IRIS_LANDMARKS:iris_landmarks"
|
||||
# }
|
||||
|
||||
type: "IrisLandmarkCpu"
|
||||
|
||||
# CPU image. (ImageFrame)
|
||||
input_stream: "IMAGE:image"
|
||||
# ROI (region of interest) within the given image where an eye is located.
|
||||
# (NormalizedRect)
|
||||
input_stream: "ROI:roi"
|
||||
# Is right eye. (bool)
|
||||
# (Model is trained to detect left eye landmarks only, hence for right eye,
|
||||
# flipping is required to immitate left eye.)
|
||||
input_stream: "IS_RIGHT_EYE:is_right_eye"
|
||||
|
||||
# 71 refined normalized eye contour landmarks. (NormalizedLandmarkList)
|
||||
output_stream: "EYE_CONTOUR_LANDMARKS:projected_eye_landmarks"
|
||||
# 5 normalized iris landmarks. (NormalizedLandmarkList)
|
||||
output_stream: "IRIS_LANDMARKS:projected_iris_landmarks"
|
||||
|
||||
node {
|
||||
calculator: "ImageCroppingCalculator"
|
||||
input_stream: "IMAGE:image"
|
||||
input_stream: "NORM_RECT:roi"
|
||||
output_stream: "IMAGE:eye_image"
|
||||
options: {
|
||||
[mediapipe.ImageCroppingCalculatorOptions.ext] {
|
||||
border_mode: BORDER_REPLICATE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
node {
|
||||
calculator: "ImageTransformationCalculator"
|
||||
input_stream: "IMAGE:eye_image"
|
||||
input_stream: "FLIP_HORIZONTALLY:is_right_eye"
|
||||
output_stream: "IMAGE:transformed_eye_image"
|
||||
output_stream: "LETTERBOX_PADDING:eye_letterbox_padding"
|
||||
options: {
|
||||
[mediapipe.ImageTransformationCalculatorOptions.ext] {
|
||||
output_width: 64
|
||||
output_height: 64
|
||||
scale_mode: FIT
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Converts the transformed input image on CPU into an image tensor stored as a
|
||||
# TfLiteTensor.
|
||||
node {
|
||||
calculator: "TfLiteConverterCalculator"
|
||||
input_stream: "IMAGE:transformed_eye_image"
|
||||
output_stream: "TENSORS:image_tensor"
|
||||
options: {
|
||||
[mediapipe.TfLiteConverterCalculatorOptions.ext] {
|
||||
zero_center: false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Runs a TensorFlow Lite model on CPU that takes an image tensor and outputs a
|
||||
# vector of tensors representing, for instance, detection boxes/keypoints and
|
||||
# scores.
|
||||
node {
|
||||
calculator: "TfLiteInferenceCalculator"
|
||||
input_stream: "TENSORS:image_tensor"
|
||||
output_stream: "TENSORS:output_tensors"
|
||||
options: {
|
||||
[mediapipe.TfLiteInferenceCalculatorOptions.ext] {
|
||||
model_path: "mediapipe/modules/iris_landmark/iris_landmark.tflite"
|
||||
delegate { xnnpack {} }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Splits a vector of TFLite tensors to multiple vectors according to the ranges
|
||||
# specified in option.
|
||||
node {
|
||||
calculator: "SplitTfLiteTensorVectorCalculator"
|
||||
input_stream: "output_tensors"
|
||||
output_stream: "eye_landmarks_tensor"
|
||||
output_stream: "iris_landmarks_tensor"
|
||||
options: {
|
||||
[mediapipe.SplitVectorCalculatorOptions.ext] {
|
||||
ranges: { begin: 0 end: 1 }
|
||||
ranges: { begin: 1 end: 2 }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Decodes the landmark tensors into a vector of landmarks, where the landmark
|
||||
# coordinates are normalized by the size of the input image to the model.
|
||||
node {
|
||||
calculator: "TfLiteTensorsToLandmarksCalculator"
|
||||
input_stream: "TENSORS:iris_landmarks_tensor"
|
||||
input_stream: "FLIP_HORIZONTALLY:is_right_eye"
|
||||
output_stream: "NORM_LANDMARKS:iris_landmarks"
|
||||
options: {
|
||||
[mediapipe.TfLiteTensorsToLandmarksCalculatorOptions.ext] {
|
||||
num_landmarks: 5
|
||||
input_image_width: 64
|
||||
input_image_height: 64
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Decodes the landmark tensors into a vector of landmarks, where the landmark
|
||||
# coordinates are normalized by the size of the input image to the model.
|
||||
node {
|
||||
calculator: "TfLiteTensorsToLandmarksCalculator"
|
||||
input_stream: "TENSORS:eye_landmarks_tensor"
|
||||
input_stream: "FLIP_HORIZONTALLY:is_right_eye"
|
||||
output_stream: "NORM_LANDMARKS:eye_landmarks"
|
||||
options: {
|
||||
[mediapipe.TfLiteTensorsToLandmarksCalculatorOptions.ext] {
|
||||
num_landmarks: 71
|
||||
input_image_width: 64
|
||||
input_image_height: 64
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
node {
|
||||
calculator: "LandmarkLetterboxRemovalCalculator"
|
||||
input_stream: "LANDMARKS:0:iris_landmarks"
|
||||
input_stream: "LANDMARKS:1:eye_landmarks"
|
||||
input_stream: "LETTERBOX_PADDING:eye_letterbox_padding"
|
||||
output_stream: "LANDMARKS:0:padded_iris_landmarks"
|
||||
output_stream: "LANDMARKS:1:padded_eye_landmarks"
|
||||
}
|
||||
|
||||
# Projects the landmarks from the cropped face image to the corresponding
|
||||
# locations on the full image before cropping (input to the graph).
|
||||
node {
|
||||
calculator: "LandmarkProjectionCalculator"
|
||||
input_stream: "NORM_LANDMARKS:0:padded_iris_landmarks"
|
||||
input_stream: "NORM_LANDMARKS:1:padded_eye_landmarks"
|
||||
input_stream: "NORM_RECT:roi"
|
||||
output_stream: "NORM_LANDMARKS:0:projected_iris_landmarks"
|
||||
output_stream: "NORM_LANDMARKS:1:projected_eye_landmarks"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,162 @@
|
||||
# MediaPipe subgraph to calculate iris landmarks and eye contour landmarks for
|
||||
# a single eye. (GPU input, and inference is executed on GPU.)
|
||||
#
|
||||
# It is required that "iris_landmark.tflite" is available at
|
||||
# "mediapipe/modules/iris_landmark/iris_landmark.tflite"
|
||||
# path during execution.
|
||||
#
|
||||
# EXAMPLE:
|
||||
# node {
|
||||
# calculator: "IrisLandmarkGpu"
|
||||
# input_stream: "IMAGE:image"
|
||||
# input_stream: "ROI:eye_roi"
|
||||
# input_stream: "IS_RIGHT_EYE:is_right_eye"
|
||||
# output_stream: "EYE_CONTOUR_LANDMARKS:eye_contour_landmarks"
|
||||
# output_stream: "IRIS_LANDMARKS:iris_landmarks"
|
||||
# }
|
||||
|
||||
type: "IrisLandmarkGpu"
|
||||
|
||||
# GPU buffer. (GpuBuffer)
|
||||
input_stream: "IMAGE:image"
|
||||
# ROI (region of interest) within the given image where an eye is located.
|
||||
# (NormalizedRect)
|
||||
input_stream: "ROI:roi"
|
||||
# Is right eye. (bool)
|
||||
# (Model is trained to detect left eye landmarks only, hence for right eye,
|
||||
# flipping is required to immitate left eye.)
|
||||
input_stream: "IS_RIGHT_EYE:is_right_eye"
|
||||
|
||||
# TfLite model to detect iris landmarks.
|
||||
# (std::unique_ptr<tflite::FlatBufferModel,
|
||||
# std::function<void(tflite::FlatBufferModel*)>>)
|
||||
# NOTE: currently, mediapipe/modules/iris_landmark/iris_landmark.tflite model
|
||||
# only, can be passed here, otherwise - results are undefined.
|
||||
input_side_packet: "MODEL:model"
|
||||
|
||||
# 71 refined normalized eye contour landmarks. (NormalizedLandmarkList)
|
||||
output_stream: "EYE_CONTOUR_LANDMARKS:projected_eye_landmarks"
|
||||
# 5 normalized iris landmarks. (NormalizedLandmarkList)
|
||||
output_stream: "IRIS_LANDMARKS:projected_iris_landmarks"
|
||||
|
||||
node {
|
||||
calculator: "ImageCroppingCalculator"
|
||||
input_stream: "IMAGE_GPU:image"
|
||||
input_stream: "NORM_RECT:roi"
|
||||
output_stream: "IMAGE_GPU:eye_image"
|
||||
options: {
|
||||
[mediapipe.ImageCroppingCalculatorOptions.ext] {
|
||||
border_mode: BORDER_REPLICATE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
node {
|
||||
calculator: "ImageTransformationCalculator"
|
||||
input_stream: "IMAGE_GPU:eye_image"
|
||||
input_stream: "FLIP_HORIZONTALLY:is_right_eye"
|
||||
output_stream: "IMAGE_GPU:transformed_eye_image"
|
||||
output_stream: "LETTERBOX_PADDING:eye_letterbox_padding"
|
||||
options: {
|
||||
[mediapipe.ImageTransformationCalculatorOptions.ext] {
|
||||
output_width: 64
|
||||
output_height: 64
|
||||
scale_mode: FIT
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Converts the transformed input image on CPU into an image tensor stored as a
|
||||
# TfLiteTensor.
|
||||
node {
|
||||
calculator: "TfLiteConverterCalculator"
|
||||
input_stream: "IMAGE_GPU:transformed_eye_image"
|
||||
output_stream: "TENSORS_GPU:image_tensor"
|
||||
options: {
|
||||
[mediapipe.TfLiteConverterCalculatorOptions.ext] {
|
||||
zero_center: false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Runs a TensorFlow Lite model on CPU that takes an image tensor and outputs a
|
||||
# vector of tensors representing, for instance, detection boxes/keypoints and
|
||||
# scores.
|
||||
node {
|
||||
calculator: "TfLiteInferenceCalculator"
|
||||
input_stream: "TENSORS_GPU:image_tensor"
|
||||
output_stream: "TENSORS:output_tensors"
|
||||
options: {
|
||||
[mediapipe.TfLiteInferenceCalculatorOptions.ext] {
|
||||
model_path: "mediapipe/modules/iris_landmark/iris_landmark.tflite"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Splits a vector of TFLite tensors to multiple vectors according to the ranges
|
||||
# specified in option.
|
||||
node {
|
||||
calculator: "SplitTfLiteTensorVectorCalculator"
|
||||
input_stream: "output_tensors"
|
||||
output_stream: "eye_landmarks_tensor"
|
||||
output_stream: "iris_landmarks_tensor"
|
||||
options: {
|
||||
[mediapipe.SplitVectorCalculatorOptions.ext] {
|
||||
ranges: { begin: 0 end: 1 }
|
||||
ranges: { begin: 1 end: 2 }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Decodes the landmark tensors into a vector of landmarks, where the landmark
|
||||
# coordinates are normalized by the size of the input image to the model.
|
||||
node {
|
||||
calculator: "TfLiteTensorsToLandmarksCalculator"
|
||||
input_stream: "TENSORS:iris_landmarks_tensor"
|
||||
input_stream: "FLIP_HORIZONTALLY:is_right_eye"
|
||||
output_stream: "NORM_LANDMARKS:iris_landmarks"
|
||||
options: {
|
||||
[mediapipe.TfLiteTensorsToLandmarksCalculatorOptions.ext] {
|
||||
num_landmarks: 5
|
||||
input_image_width: 64
|
||||
input_image_height: 64
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Decodes the landmark tensors into a vector of landmarks, where the landmark
|
||||
# coordinates are normalized by the size of the input image to the model.
|
||||
node {
|
||||
calculator: "TfLiteTensorsToLandmarksCalculator"
|
||||
input_stream: "TENSORS:eye_landmarks_tensor"
|
||||
input_stream: "FLIP_HORIZONTALLY:is_right_eye"
|
||||
output_stream: "NORM_LANDMARKS:eye_landmarks"
|
||||
options: {
|
||||
[mediapipe.TfLiteTensorsToLandmarksCalculatorOptions.ext] {
|
||||
num_landmarks: 71
|
||||
input_image_width: 64
|
||||
input_image_height: 64
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
node {
|
||||
calculator: "LandmarkLetterboxRemovalCalculator"
|
||||
input_stream: "LANDMARKS:0:iris_landmarks"
|
||||
input_stream: "LANDMARKS:1:eye_landmarks"
|
||||
input_stream: "LETTERBOX_PADDING:eye_letterbox_padding"
|
||||
output_stream: "LANDMARKS:0:padded_iris_landmarks"
|
||||
output_stream: "LANDMARKS:1:padded_eye_landmarks"
|
||||
}
|
||||
|
||||
# Projects the landmarks from the cropped face image to the corresponding
|
||||
# locations on the full image before cropping (input to the graph).
|
||||
node {
|
||||
calculator: "LandmarkProjectionCalculator"
|
||||
input_stream: "NORM_LANDMARKS:0:padded_iris_landmarks"
|
||||
input_stream: "NORM_LANDMARKS:1:padded_eye_landmarks"
|
||||
input_stream: "NORM_RECT:roi"
|
||||
output_stream: "NORM_LANDMARKS:0:projected_iris_landmarks"
|
||||
output_stream: "NORM_LANDMARKS:1:projected_eye_landmarks"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
# MediaPipe subgraph to calculate region of interest (ROI) which is then can
|
||||
# be used to calculate iris landmarks and eye contour landmarks.
|
||||
#
|
||||
# NOTE: this graph is subject to change and should not be used directly.
|
||||
|
||||
type: "IrisLandmarkLandmarksToRoi"
|
||||
|
||||
# List of two normalized landmarks: left and right corners of an eye.
|
||||
# (NormalizedLandmarkList)
|
||||
input_stream: "LANDMARKS:landmarks"
|
||||
# Image size. (std::pair<int, int>)
|
||||
input_stream: "IMAGE_SIZE:image_size"
|
||||
|
||||
# ROI (region of interest) within the given image where an eye is located.
|
||||
# (NormalizedRect)
|
||||
output_stream: "ROI:roi"
|
||||
|
||||
node {
|
||||
calculator: "LandmarksToDetectionCalculator"
|
||||
input_stream: "NORM_LANDMARKS:landmarks"
|
||||
output_stream: "DETECTION:detection"
|
||||
}
|
||||
|
||||
node {
|
||||
calculator: "DetectionsToRectsCalculator"
|
||||
input_stream: "DETECTION:detection"
|
||||
input_stream: "IMAGE_SIZE:image_size"
|
||||
output_stream: "NORM_RECT:raw_roi"
|
||||
options: {
|
||||
[mediapipe.DetectionsToRectsCalculatorOptions.ext] {
|
||||
rotation_vector_start_keypoint_index: 0
|
||||
rotation_vector_end_keypoint_index: 1
|
||||
rotation_vector_target_angle_degrees: 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
node {
|
||||
calculator: "RectTransformationCalculator"
|
||||
input_stream: "NORM_RECT:raw_roi"
|
||||
input_stream: "IMAGE_SIZE:image_size"
|
||||
output_stream: "roi"
|
||||
options: {
|
||||
[mediapipe.RectTransformationCalculatorOptions.ext] {
|
||||
scale_x: 2.3
|
||||
scale_y: 2.3
|
||||
square_long: true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
# MediaPipe subgraph to calculate iris landmarks and eye contour landmarks for
|
||||
# two eyes: left and right. (CPU input, and inference is executed on CPU.)
|
||||
#
|
||||
# It is required that "iris_landmark.tflite" is available at
|
||||
# "mediapipe/modules/iris_landmark/iris_landmark.tflite"
|
||||
# path during execution.
|
||||
#
|
||||
# EXAMPLE:
|
||||
# node {
|
||||
# calculator: "IrisLandmarkLeftAndRightCpu"
|
||||
# input_stream: "IMAGE:image"
|
||||
# input_stream: "LEFT_EYE_BOUNDARY_LANDMARKS:left_eye_boundary_landmarks"
|
||||
# input_stream: "RIGHT_EYE_BOUNDARY_LANDMARKS:right_eye_boundary_landmarks"
|
||||
# output_stream: "LEFT_EYE_CONTOUR_LANDMARKS:left_eye_contour_landmarks"
|
||||
# output_stream: "LEFT_EYE_IRIS_LANDMARKS:left_iris_landmarks"
|
||||
# output_stream: "RIGHT_EYE_CONTOUR_LANDMARKS:right_eye_contour_landmarks"
|
||||
# output_stream: "RIGHT_EYE_IRIS_LANDMARKS:right_iris_landmarks"
|
||||
# }
|
||||
|
||||
type: "IrisLandmarkLeftAndRightCpu"
|
||||
|
||||
# CPU image. (ImageFrame)
|
||||
input_stream: "IMAGE:image"
|
||||
# List of two landmarks defining LEFT eye boundaries - left and right corners.
|
||||
# (NormalizedLandmarkList)
|
||||
input_stream: "LEFT_EYE_BOUNDARY_LANDMARKS:left_eye_boundary_landmarks"
|
||||
# List of two landmarks defining RIGHT eye boundaries - left and right corners.
|
||||
# (NormalizedLandmarkList)
|
||||
input_stream: "RIGHT_EYE_BOUNDARY_LANDMARKS:right_eye_boundary_landmarks"
|
||||
|
||||
# 71 normalized eye contour landmarks. (NormalizedLandmarkList)
|
||||
output_stream: "LEFT_EYE_CONTOUR_LANDMARKS:left_eye_contour_landmarks"
|
||||
# 5 normalized iris landmarks. (NormalizedLandmarkList)
|
||||
output_stream: "LEFT_EYE_IRIS_LANDMARKS:left_iris_landmarks"
|
||||
# Region of interest used to do calculations for the left eye. (NormalizedRect)
|
||||
output_stream: "LEFT_EYE_ROI:left_eye_roi"
|
||||
|
||||
# 71 normalized eye contour landmarks. (NormalizedLandmarkList)
|
||||
output_stream: "RIGHT_EYE_CONTOUR_LANDMARKS:right_eye_contour_landmarks"
|
||||
# 5 normalized iris landmarks. (NormalizedLandmarkList)
|
||||
output_stream: "RIGHT_EYE_IRIS_LANDMARKS:right_iris_landmarks"
|
||||
# Region of interest used to do calculations for the right eye. (NormalizedRect)
|
||||
output_stream: "RIGHT_EYE_ROI:right_eye_roi"
|
||||
|
||||
node {
|
||||
calculator: "ImagePropertiesCalculator"
|
||||
input_stream: "IMAGE:image"
|
||||
output_stream: "SIZE:image_size"
|
||||
}
|
||||
|
||||
### Processing left eye ###
|
||||
|
||||
node {
|
||||
calculator: "IrisLandmarkLandmarksToRoi"
|
||||
input_stream: "LANDMARKS:left_eye_boundary_landmarks"
|
||||
input_stream: "IMAGE_SIZE:image_size"
|
||||
output_stream: "ROI:left_eye_roi"
|
||||
}
|
||||
|
||||
node {
|
||||
calculator: "ConstantSidePacketCalculator"
|
||||
output_side_packet: "PACKET:left_eye_flag_side_packet"
|
||||
options {
|
||||
[mediapipe.ConstantSidePacketCalculatorOptions.ext] {
|
||||
packet { bool_value: false }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
node {
|
||||
calculator: "SidePacketToStreamCalculator"
|
||||
input_stream: "TICK:image"
|
||||
input_side_packet: "left_eye_flag_side_packet"
|
||||
output_stream: "AT_TICK:left_eye_flag"
|
||||
}
|
||||
|
||||
node {
|
||||
calculator: "IrisLandmarkCpu"
|
||||
input_stream: "IMAGE:image"
|
||||
input_stream: "ROI:left_eye_roi"
|
||||
input_stream: "IS_RIGHT_EYE:left_eye_flag"
|
||||
output_stream: "EYE_CONTOUR_LANDMARKS:left_eye_contour_landmarks"
|
||||
output_stream: "IRIS_LANDMARKS:left_iris_landmarks"
|
||||
}
|
||||
|
||||
### Processing right eye ###
|
||||
|
||||
node {
|
||||
calculator: "IrisLandmarkLandmarksToRoi"
|
||||
input_stream: "LANDMARKS:right_eye_boundary_landmarks"
|
||||
input_stream: "IMAGE_SIZE:image_size"
|
||||
output_stream: "ROI:right_eye_roi"
|
||||
}
|
||||
|
||||
node {
|
||||
calculator: "ConstantSidePacketCalculator"
|
||||
output_side_packet: "PACKET:right_eye_flag_side_packet"
|
||||
options {
|
||||
[mediapipe.ConstantSidePacketCalculatorOptions.ext] {
|
||||
packet { bool_value: true }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
node {
|
||||
calculator: "SidePacketToStreamCalculator"
|
||||
input_stream: "TICK:image"
|
||||
input_side_packet: "right_eye_flag_side_packet"
|
||||
output_stream: "AT_TICK:right_eye_flag"
|
||||
}
|
||||
|
||||
node {
|
||||
calculator: "IrisLandmarkCpu"
|
||||
input_stream: "IMAGE:image"
|
||||
input_stream: "ROI:right_eye_roi"
|
||||
input_stream: "IS_RIGHT_EYE:right_eye_flag"
|
||||
output_stream: "EYE_CONTOUR_LANDMARKS:right_eye_contour_landmarks"
|
||||
output_stream: "IRIS_LANDMARKS:right_iris_landmarks"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
# MediaPipe subgraph to calculate iris landmarks and eye contour landmarks for
|
||||
# two eyes: left and right. (GPU input, and inference is executed on GPU.)
|
||||
#
|
||||
# It is required that "iris_landmark.tflite" is available at
|
||||
# "mediapipe/modules/iris_landmark/iris_landmark.tflite"
|
||||
# path during execution.
|
||||
#
|
||||
# EXAMPLE:
|
||||
# node {
|
||||
# calculator: "IrisLandmarkLeftAndRightGpu"
|
||||
# input_stream: "IMAGE:image"
|
||||
# input_stream: "LEFT_EYE_BOUNDARY_LANDMARKS:left_eye_boundary_landmarks"
|
||||
# input_stream: "RIGHT_EYE_BOUNDARY_LANDMARKS:right_eye_boundary_landmarks"
|
||||
# output_stream: "LEFT_EYE_CONTOUR_LANDMARKS:left_eye_contour_landmarks"
|
||||
# output_stream: "LEFT_EYE_IRIS_LANDMARKS:left_iris_landmarks"
|
||||
# output_stream: "RIGHT_EYE_CONTOUR_LANDMARKS:right_eye_contour_landmarks"
|
||||
# output_stream: "RIGHT_EYE_IRIS_LANDMARKS:right_iris_landmarks"
|
||||
# }
|
||||
|
||||
type: "IrisLandmarkLeftAndRightGpu"
|
||||
|
||||
# GPU buffer. (GpuBuffer)
|
||||
input_stream: "IMAGE:image"
|
||||
# List of two landmarks defining LEFT eye boundaries - left and right corners.
|
||||
# (NormalizedLandmarkList)
|
||||
input_stream: "LEFT_EYE_BOUNDARY_LANDMARKS:left_eye_boundary_landmarks"
|
||||
# List of two landmarks defining RIGHT eye boundaries - left and right corners.
|
||||
# (NormalizedLandmarkList)
|
||||
input_stream: "RIGHT_EYE_BOUNDARY_LANDMARKS:right_eye_boundary_landmarks"
|
||||
|
||||
# 71 normalized eye contour landmarks. (NormalizedLandmarkList)
|
||||
output_stream: "LEFT_EYE_CONTOUR_LANDMARKS:left_eye_contour_landmarks"
|
||||
# 5 normalized iris landmarks. (NormalizedLandmarkList)
|
||||
output_stream: "LEFT_EYE_IRIS_LANDMARKS:left_iris_landmarks"
|
||||
# Region of interest used to do calculations for the left eye. (NormalizedRect)
|
||||
output_stream: "LEFT_EYE_ROI:left_eye_roi"
|
||||
|
||||
# 71 normalized eye contour landmarks. (NormalizedLandmarkList)
|
||||
output_stream: "RIGHT_EYE_CONTOUR_LANDMARKS:right_eye_contour_landmarks"
|
||||
# 5 normalized iris landmarks. (NormalizedLandmarkList)
|
||||
output_stream: "RIGHT_EYE_IRIS_LANDMARKS:right_iris_landmarks"
|
||||
# Region of interest used to do calculations for the right eye. (NormalizedRect)
|
||||
output_stream: "RIGHT_EYE_ROI:right_eye_roi"
|
||||
|
||||
node {
|
||||
calculator: "ImagePropertiesCalculator"
|
||||
input_stream: "IMAGE_GPU:image"
|
||||
output_stream: "SIZE:image_size"
|
||||
}
|
||||
|
||||
### Processing left eye ###
|
||||
|
||||
node {
|
||||
calculator: "IrisLandmarkLandmarksToRoi"
|
||||
input_stream: "LANDMARKS:left_eye_boundary_landmarks"
|
||||
input_stream: "IMAGE_SIZE:image_size"
|
||||
output_stream: "ROI:left_eye_roi"
|
||||
}
|
||||
|
||||
node {
|
||||
calculator: "ConstantSidePacketCalculator"
|
||||
output_side_packet: "PACKET:left_eye_flag_side_packet"
|
||||
options {
|
||||
[mediapipe.ConstantSidePacketCalculatorOptions.ext] {
|
||||
packet { bool_value: false }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
node {
|
||||
calculator: "SidePacketToStreamCalculator"
|
||||
input_stream: "TICK:image"
|
||||
input_side_packet: "left_eye_flag_side_packet"
|
||||
output_stream: "AT_TICK:left_eye_flag"
|
||||
}
|
||||
|
||||
node {
|
||||
calculator: "IrisLandmarkGpu"
|
||||
input_stream: "IMAGE:image"
|
||||
input_stream: "ROI:left_eye_roi"
|
||||
input_stream: "IS_RIGHT_EYE:left_eye_flag"
|
||||
output_stream: "EYE_CONTOUR_LANDMARKS:left_eye_contour_landmarks"
|
||||
output_stream: "IRIS_LANDMARKS:left_iris_landmarks"
|
||||
}
|
||||
|
||||
### Processing right eye ###
|
||||
|
||||
node {
|
||||
calculator: "IrisLandmarkLandmarksToRoi"
|
||||
input_stream: "LANDMARKS:right_eye_boundary_landmarks"
|
||||
input_stream: "IMAGE_SIZE:image_size"
|
||||
output_stream: "ROI:right_eye_roi"
|
||||
}
|
||||
|
||||
node {
|
||||
calculator: "ConstantSidePacketCalculator"
|
||||
output_side_packet: "PACKET:right_eye_flag_side_packet"
|
||||
options {
|
||||
[mediapipe.ConstantSidePacketCalculatorOptions.ext] {
|
||||
packet { bool_value: true }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
node {
|
||||
calculator: "SidePacketToStreamCalculator"
|
||||
input_stream: "TICK:image"
|
||||
input_side_packet: "right_eye_flag_side_packet"
|
||||
output_stream: "AT_TICK:right_eye_flag"
|
||||
}
|
||||
|
||||
node {
|
||||
calculator: "IrisLandmarkGpu"
|
||||
input_stream: "IMAGE:image"
|
||||
input_stream: "ROI:right_eye_roi"
|
||||
input_stream: "IS_RIGHT_EYE:right_eye_flag"
|
||||
output_stream: "EYE_CONTOUR_LANDMARKS:right_eye_contour_landmarks"
|
||||
output_stream: "IRIS_LANDMARKS:right_iris_landmarks"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user