Project import generated by Copybara.

GitOrigin-RevId: 1610e588e497817fae2d9a458093ab6a370e2972
This commit is contained in:
MediaPipe Team
2021-08-18 17:45:46 -07:00
committed by jqtang
parent b899d17f18
commit 710fb3de58
158 changed files with 10104 additions and 1568 deletions
@@ -65,6 +65,30 @@ mediapipe_simple_subgraph(
],
)
mediapipe_simple_subgraph(
name = "selfie_segmentation_cpu_image",
graph = "selfie_segmentation_cpu_image.pbtxt",
register_as = "SelfieSegmentationCpuImage",
deps = [
":selfie_segmentation_cpu",
"//mediapipe/calculators/image:image_transformation_calculator",
"//mediapipe/calculators/util:from_image_calculator",
"//mediapipe/calculators/util:to_image_calculator",
],
)
mediapipe_simple_subgraph(
name = "selfie_segmentation_gpu_image",
graph = "selfie_segmentation_gpu_image.pbtxt",
register_as = "SelfieSegmentationGpuImage",
deps = [
":selfie_segmentation_gpu",
"//mediapipe/calculators/image:image_transformation_calculator",
"//mediapipe/calculators/util:from_image_calculator",
"//mediapipe/calculators/util:to_image_calculator",
],
)
exports_files(
srcs = [
"selfie_segmentation.tflite",
@@ -0,0 +1,50 @@
# MediaPipe graph to perform selfie segmentation.
type: "SelfieSegmentationCpuImage"
# Input image. (Image)
input_stream: "IMAGE:image"
# The original input image. (Image)
output_stream: "IMAGE:image"
# An integer 0 or 1. Use 0 to select a general-purpose model (operating on a
# 256x256 tensor), and 1 to select a model (operating on a 256x144 tensor) more
# optimized for landscape images. If unspecified, functions as set to 0. (int)
input_side_packet: "MODEL_SELECTION:model_selection"
# Segmentation mask. (Image)
output_stream: "SEGMENTATION_MASK:segmentation_mask"
# Converts Image to ImageFrame for SelfieSegmentationCpu to consume.
node {
calculator: "FromImageCalculator"
input_stream: "IMAGE:image"
output_stream: "IMAGE_CPU:raw_image_frame"
output_stream: "SOURCE_ON_GPU:is_gpu_image"
}
# TODO: Remove the extra flipping once adopting MlImage.
# If the source images are on gpu, flip the data vertically before sending them
# into SelfieSegmentationCpu. This maybe needed because OpenGL represents images
# assuming the image origin is at the bottom-left corner, whereas MediaPipe in
# general assumes the image origin is at the top-left corner.
node: {
calculator: "ImageTransformationCalculator"
input_stream: "IMAGE:raw_image_frame"
input_stream: "FLIP_VERTICALLY:is_gpu_image"
output_stream: "IMAGE:image_frame"
}
node {
calculator: "SelfieSegmentationCpu"
input_side_packet: "MODEL_SELECTION:model_selection"
input_stream: "IMAGE:image_frame"
output_stream: "SEGMENTATION_MASK:segmentation_mask_image_frame"
}
node {
calculator: "ToImageCalculator"
input_stream: "IMAGE_CPU:segmentation_mask_image_frame"
output_stream: "IMAGE:segmentation_mask"
}
@@ -0,0 +1,50 @@
# MediaPipe graph to perform selfie segmentation.
type: "SelfieSegmentationGpuImage"
# Input image. (Image)
input_stream: "IMAGE:image"
# The original input image. (Image)
output_stream: "IMAGE:image"
# An integer 0 or 1. Use 0 to select a general-purpose model (operating on a
# 256x256 tensor), and 1 to select a model (operating on a 256x144 tensor) more
# optimized for landscape images. If unspecified, functions as set to 0. (int)
input_side_packet: "MODEL_SELECTION:model_selection"
# Segmentation mask. (Image)
output_stream: "SEGMENTATION_MASK:segmentation_mask"
# Converts Image to ImageFrame for SelfieSegmentationGpu to consume.
node {
calculator: "FromImageCalculator"
input_stream: "IMAGE:image"
output_stream: "IMAGE_GPU:raw_gpu_buffer"
output_stream: "SOURCE_ON_GPU:is_gpu_image"
}
# TODO: Remove the extra flipping once adopting MlImage.
# If the source images are on gpu, flip the data vertically before sending them
# into SelfieSegmentationGpu. This maybe needed because OpenGL represents images
# assuming the image origin is at the bottom-left corner, whereas MediaPipe in
# general assumes the image origin is at the top-left corner.
node: {
calculator: "ImageTransformationCalculator"
input_stream: "IMAGE_GPU:raw_gpu_buffer"
input_stream: "FLIP_VERTICALLY:is_gpu_image"
output_stream: "IMAGE_GPU:gpu_buffer"
}
node {
calculator: "SelfieSegmentationGpu"
input_side_packet: "MODEL_SELECTION:model_selection"
input_stream: "IMAGE:gpu_buffer"
output_stream: "SEGMENTATION_MASK:segmentation_mask_gpu_buffer"
}
node {
calculator: "ToImageCalculator"
input_stream: "IMAGE_GPU:segmentation_mask_gpu_buffer"
output_stream: "IMAGE:segmentation_mask"
}