mediapipe/mediapipe/examples/facial_search/graphs/subgraph_face_embeddings_gpu.pbtxt

78 lines
2.2 KiB
Plaintext

# MediaPipe graph that performs face detection with TensorFlow Lite on GPU.
# Used in the examples in
# mediapipe/examples/facial_search.
type: "FaceEmbeddingsSubgraph"
input_stream: "IMAGE:input_frame"
input_stream: "DETECTIONS:head_detections"
output_stream: "FLOATS:embeddings"
# DetectionsToRectsCalculator takes DETECTIONS in and outputs NORM_RECT of
# the first detection.
node {
calculator: "DetectionsToRectsCalculator"
input_stream: "DETECTIONS:head_detections"
output_stream: "NORM_RECT:head_rect"
node_options: {
[type.googleapis.com/mediapipe.DetectionsToRectsCalculatorOptions] {
output_zero_rect_for_empty_detections: true
}
}
}
node {
calculator: "ImageCroppingCalculator"
input_stream: "IMAGE_GPU:input_frame"
input_stream: "NORM_RECT:head_rect"
output_stream: "IMAGE_GPU:cropped_head"
}
node {
calculator: "ImageTransformationCalculator"
input_stream: "IMAGE_GPU:cropped_head"
output_stream: "IMAGE_GPU:scaled_head"
node_options: {
[type.googleapis.com/mediapipe.ImageTransformationCalculatorOptions] {
output_width: 140
output_height: 140
scale_mode: FIT
}
}
}
node {
calculator: "GpuBufferToImageFrameCalculator"
input_stream: "scaled_head"
output_stream: "scaled_head_cpu"
}
node {
calculator: "TfLiteConverterCalculator"
input_stream: "IMAGE:scaled_head_cpu"
output_stream: "TENSORS:scaled_head_tensor"
}
# Runs inference on CPU as this tflite uses operations that are not supported on GPU.
# Warnings shown when attempting to run on GPU:
# ERROR: Next operations are not supported by GPU delegate:
# MAXIMUM: Operation is not supported.
# MEAN: Operation is not supported.
# First 0 operations will run on the GPU, and the remaining 81 on the CPU.
node {
calculator: "TfLiteInferenceCalculator"
input_stream: "TENSORS:scaled_head_tensor"
output_stream: "TENSORS:embeddings_tensors"
node_options: {
[type.googleapis.com/mediapipe.TfLiteInferenceCalculatorOptions] {
use_gpu: false
model_path: "mediapipe/models/face_embeddings.tflite"
}
}
}
node {
calculator: "TfLiteTensorsToFloatsCalculator"
input_stream: "TENSORS:embeddings_tensors"
output_stream: "FLOATS:embeddings"
}