Merge branch 'master' into ios-task-files

This commit is contained in:
Prianka Liz Kariat 2022-12-23 16:09:05 +05:30
commit c61f0a457f
31 changed files with 208 additions and 120 deletions

View File

@ -567,7 +567,7 @@ cc_library(
name = "packet_thinner_calculator",
srcs = ["packet_thinner_calculator.cc"],
deps = [
"//mediapipe/calculators/core:packet_thinner_calculator_cc_proto",
":packet_thinner_calculator_cc_proto",
"//mediapipe/framework:calculator_context",
"//mediapipe/framework:calculator_framework",
"//mediapipe/framework/formats:video_stream_header",
@ -584,7 +584,7 @@ cc_test(
srcs = ["packet_thinner_calculator_test.cc"],
deps = [
":packet_thinner_calculator",
"//mediapipe/calculators/core:packet_thinner_calculator_cc_proto",
":packet_thinner_calculator_cc_proto",
"//mediapipe/framework:calculator_framework",
"//mediapipe/framework:calculator_runner",
"//mediapipe/framework/formats:video_stream_header",
@ -762,7 +762,7 @@ cc_library(
srcs = ["packet_resampler_calculator.cc"],
hdrs = ["packet_resampler_calculator.h"],
deps = [
"//mediapipe/calculators/core:packet_resampler_calculator_cc_proto",
":packet_resampler_calculator_cc_proto",
"//mediapipe/framework:calculator_framework",
"//mediapipe/framework:collection_item_id",
"//mediapipe/framework/deps:mathutil",
@ -786,7 +786,7 @@ cc_test(
],
deps = [
":packet_resampler_calculator",
"//mediapipe/calculators/core:packet_resampler_calculator_cc_proto",
":packet_resampler_calculator_cc_proto",
"//mediapipe/framework:calculator_framework",
"//mediapipe/framework:calculator_runner",
"//mediapipe/framework/formats:video_stream_header",
@ -852,10 +852,10 @@ cc_test(
name = "flow_limiter_calculator_test",
srcs = ["flow_limiter_calculator_test.cc"],
deps = [
":counting_source_calculator",
":flow_limiter_calculator",
":flow_limiter_calculator_cc_proto",
"//mediapipe/calculators/core:counting_source_calculator",
"//mediapipe/calculators/core:pass_through_calculator",
":pass_through_calculator",
"//mediapipe/framework:calculator_framework",
"//mediapipe/framework:calculator_runner",
"//mediapipe/framework:test_calculators",
@ -1302,7 +1302,7 @@ cc_test(
srcs = ["packet_sequencer_calculator_test.cc"],
deps = [
":packet_sequencer_calculator",
"//mediapipe/calculators/core:pass_through_calculator",
":pass_through_calculator",
"//mediapipe/framework:calculator_cc_proto",
"//mediapipe/framework:calculator_framework",
"//mediapipe/framework:subgraph",

View File

@ -76,7 +76,11 @@ constexpr char kMaxInFlightTag[] = "MAX_IN_FLIGHT";
// }
// output_stream: "gated_frames"
// }
class RealTimeFlowLimiterCalculator : public CalculatorBase {
//
// Please use FlowLimiterCalculator, which replaces this calculator and
// defines a few additional configuration options.
class ABSL_DEPRECATED("Use FlowLimiterCalculator instead.")
RealTimeFlowLimiterCalculator : public CalculatorBase {
public:
static absl::Status GetContract(CalculatorContract* cc) {
int num_data_streams = cc->Inputs().NumEntries("");

View File

@ -66,12 +66,16 @@ class SequenceShiftCalculator : public Node {
// The number of packets or timestamps we need to store to output packet[i] at
// the timestamp of packet[i + packet_offset]; equal to abs(packet_offset).
int cache_size_;
bool emit_empty_packets_before_first_packet_ = false;
};
MEDIAPIPE_REGISTER_NODE(SequenceShiftCalculator);
absl::Status SequenceShiftCalculator::Open(CalculatorContext* cc) {
packet_offset_ = kOffset(cc).GetOr(
cc->Options<mediapipe::SequenceShiftCalculatorOptions>().packet_offset());
emit_empty_packets_before_first_packet_ =
cc->Options<mediapipe::SequenceShiftCalculatorOptions>()
.emit_empty_packets_before_first_packet();
cache_size_ = abs(packet_offset_);
// An offset of zero is a no-op, but someone might still request it.
if (packet_offset_ == 0) {
@ -96,6 +100,8 @@ void SequenceShiftCalculator::ProcessPositiveOffset(CalculatorContext* cc) {
// Ready to output oldest packet with current timestamp.
kOut(cc).Send(packet_cache_.front().At(cc->InputTimestamp()));
packet_cache_.pop_front();
} else if (emit_empty_packets_before_first_packet_) {
LOG(FATAL) << "Not supported yet";
}
// Store current packet for later output.
packet_cache_.push_back(kIn(cc).packet());

View File

@ -23,4 +23,8 @@ message SequenceShiftCalculatorOptions {
optional SequenceShiftCalculatorOptions ext = 107633927;
}
optional int32 packet_offset = 1 [default = -1];
// Emits empty packets before the first delayed packet is emitted. Takes
// effect only when packet offset is set to positive.
optional bool emit_empty_packets_before_first_packet = 2 [default = false];
}

View File

@ -378,8 +378,8 @@ cc_library(
name = "scale_image_calculator",
srcs = ["scale_image_calculator.cc"],
deps = [
":scale_image_calculator_cc_proto",
":scale_image_utils",
"//mediapipe/calculators/image:scale_image_calculator_cc_proto",
"//mediapipe/framework:calculator_framework",
"//mediapipe/framework/formats:image_format_cc_proto",
"//mediapipe/framework/formats:image_frame",
@ -747,8 +747,8 @@ cc_test(
tags = ["desktop_only_test"],
deps = [
":affine_transformation",
":image_transformation_calculator",
":warp_affine_calculator",
"//mediapipe/calculators/image:image_transformation_calculator",
"//mediapipe/calculators/tensor:image_to_tensor_converter",
"//mediapipe/calculators/tensor:image_to_tensor_utils",
"//mediapipe/calculators/util:from_image_calculator",

View File

@ -92,8 +92,8 @@ class GlTextureWarpAffineRunner
constexpr GLchar kVertShader[] = R"(
in vec4 position;
in mediump vec4 texture_coordinate;
out mediump vec2 sample_coordinate;
in highp vec4 texture_coordinate;
out highp vec2 sample_coordinate;
uniform mat4 transform_matrix;
void main() {
@ -104,7 +104,7 @@ class GlTextureWarpAffineRunner
)";
constexpr GLchar kFragShader[] = R"(
DEFAULT_PRECISION(mediump, float)
DEFAULT_PRECISION(highp, float)
in vec2 sample_coordinate;
uniform sampler2D input_texture;

View File

@ -68,8 +68,8 @@ class GlProcessor : public ImageToTensorConverter {
constexpr GLchar kExtractSubRectVertexShader[] = R"(
in vec4 position;
in mediump vec4 texture_coordinate;
out mediump vec2 sample_coordinate;
in highp vec4 texture_coordinate;
out highp vec2 sample_coordinate;
uniform mat4 transform_matrix;
void main() {
@ -86,7 +86,7 @@ class GlProcessor : public ImageToTensorConverter {
)";
constexpr GLchar kExtractSubRectFragBody[] = R"(
DEFAULT_PRECISION(mediump, float)
DEFAULT_PRECISION(highp, float)
// Provided by kExtractSubRectVertexShader.
in vec2 sample_coordinate;

View File

@ -22,8 +22,8 @@ cc_library(
name = "alignment_points_to_rects_calculator",
srcs = ["alignment_points_to_rects_calculator.cc"],
deps = [
":detections_to_rects_calculator",
":detections_to_rects_calculator_cc_proto",
"//mediapipe/calculators/util:detections_to_rects_calculator",
"//mediapipe/framework:calculator_framework",
"//mediapipe/framework:calculator_options_cc_proto",
"//mediapipe/framework/formats:detection_cc_proto",

View File

@ -226,13 +226,13 @@ cc_library(
":mediapipe_internal",
],
deps = [
":calculator_cc_proto",
":graph_service",
":mediapipe_options_cc_proto",
":packet_generator_cc_proto",
":packet_type",
":port",
"//mediapipe/framework:calculator_cc_proto",
"//mediapipe/framework:mediapipe_options_cc_proto",
"//mediapipe/framework:packet_generator_cc_proto",
"//mediapipe/framework:status_handler_cc_proto",
":status_handler_cc_proto",
"//mediapipe/framework/port:any_proto",
"//mediapipe/framework/port:status",
"//mediapipe/framework/tool:options_map",
@ -328,10 +328,10 @@ cc_library(
":thread_pool_executor",
":timestamp",
":validated_graph_config",
"//mediapipe/framework:calculator_cc_proto",
"//mediapipe/framework:packet_generator_cc_proto",
"//mediapipe/framework:status_handler_cc_proto",
"//mediapipe/framework:thread_pool_executor_cc_proto",
":calculator_cc_proto",
":packet_generator_cc_proto",
":status_handler_cc_proto",
":thread_pool_executor_cc_proto",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/container:fixed_array",
"@com_google_absl//absl/container:flat_hash_map",
@ -369,7 +369,7 @@ cc_library(
visibility = [":mediapipe_internal"],
deps = [
":graph_service",
"//mediapipe/framework:packet",
":packet",
"@com_google_absl//absl/status",
],
)
@ -379,7 +379,7 @@ cc_test(
srcs = ["graph_service_manager_test.cc"],
deps = [
":graph_service_manager",
"//mediapipe/framework:packet",
":packet",
"//mediapipe/framework/port:gtest_main",
],
)
@ -391,6 +391,7 @@ cc_library(
visibility = [":mediapipe_internal"],
deps = [
":calculator_base",
":calculator_cc_proto",
":calculator_context",
":calculator_context_manager",
":calculator_state",
@ -407,10 +408,9 @@ cc_library(
":packet_set",
":packet_type",
":port",
":stream_handler_cc_proto",
":timestamp",
":validated_graph_config",
"//mediapipe/framework:calculator_cc_proto",
"//mediapipe/framework:stream_handler_cc_proto",
"//mediapipe/framework/port:core_proto",
"//mediapipe/framework/port:integral_types",
"//mediapipe/framework/port:logging",
@ -466,6 +466,7 @@ cc_library(
hdrs = ["calculator_state.h"],
visibility = [":mediapipe_internal"],
deps = [
":calculator_cc_proto",
":counter",
":counter_factory",
":graph_service",
@ -475,7 +476,6 @@ cc_library(
":packet",
":packet_set",
":port",
"//mediapipe/framework:calculator_cc_proto",
"//mediapipe/framework/port:any_proto",
"//mediapipe/framework/port:logging",
"//mediapipe/framework/tool:options_map",
@ -583,7 +583,7 @@ cc_library(
hdrs = ["executor.h"],
visibility = ["//visibility:public"],
deps = [
"//mediapipe/framework:mediapipe_options_cc_proto",
":mediapipe_options_cc_proto",
"//mediapipe/framework/deps:registration",
"//mediapipe/framework/port:status",
"//mediapipe/framework/port:statusor",
@ -670,11 +670,11 @@ cc_library(
":collection_item_id",
":input_stream_manager",
":input_stream_shard",
":mediapipe_options_cc_proto",
":mediapipe_profiling",
":packet",
":packet_set",
":packet_type",
"//mediapipe/framework:mediapipe_options_cc_proto",
"//mediapipe/framework/deps:registration",
"//mediapipe/framework/port:ret_check",
"//mediapipe/framework/port:status",
@ -784,12 +784,12 @@ cc_library(
":calculator_context_manager",
":collection",
":collection_item_id",
":mediapipe_options_cc_proto",
":output_stream_manager",
":output_stream_shard",
":packet_set",
":packet_type",
":timestamp",
"//mediapipe/framework:mediapipe_options_cc_proto",
"//mediapipe/framework/deps:registration",
"//mediapipe/framework/port:logging",
"//mediapipe/framework/port:status",
@ -875,10 +875,10 @@ cc_library(
visibility = ["//visibility:public"],
deps = [
":packet",
":packet_generator_cc_proto",
":packet_set",
":packet_type",
":port",
"//mediapipe/framework:packet_generator_cc_proto",
"//mediapipe/framework/deps:registration",
"//mediapipe/framework/port:core_proto",
"//mediapipe/framework/port:status",
@ -896,13 +896,13 @@ cc_library(
":delegating_executor",
":executor",
":packet",
":packet_factory_cc_proto",
":packet_generator",
":packet_generator_cc_proto",
":packet_type",
":port",
":thread_pool_executor",
":validated_graph_config",
"//mediapipe/framework:packet_factory_cc_proto",
"//mediapipe/framework:packet_generator_cc_proto",
"//mediapipe/framework/port:core_proto",
"//mediapipe/framework/port:logging",
"//mediapipe/framework/port:ret_check",
@ -1019,10 +1019,10 @@ cc_library(
hdrs = ["status_handler.h"],
visibility = ["//visibility:public"],
deps = [
":mediapipe_options_cc_proto",
":packet_set",
":packet_type",
":port",
"//mediapipe/framework:mediapipe_options_cc_proto",
"//mediapipe/framework/deps:registration",
"//mediapipe/framework/port:status",
"@com_google_absl//absl/memory",
@ -1035,10 +1035,10 @@ cc_library(
hdrs = ["subgraph.h"],
visibility = ["//visibility:public"],
deps = [
":calculator_cc_proto",
":graph_service",
":graph_service_manager",
":port",
"//mediapipe/framework:calculator_cc_proto",
"//mediapipe/framework/deps:registration",
"//mediapipe/framework/port:ret_check",
"//mediapipe/framework/port:status",
@ -1060,7 +1060,7 @@ cc_library(
visibility = ["//visibility:public"],
deps = [
":calculator_framework",
"//mediapipe/framework:test_calculators_cc_proto",
":test_calculators_cc_proto",
"//mediapipe/framework/deps:mathutil",
"//mediapipe/framework/formats:matrix",
"//mediapipe/framework/port:integral_types",
@ -1097,7 +1097,7 @@ cc_library(
visibility = ["//visibility:public"],
deps = [
":executor",
"//mediapipe/framework:thread_pool_executor_cc_proto",
":thread_pool_executor_cc_proto",
"//mediapipe/framework/deps:thread_options",
"//mediapipe/framework/port:logging",
"//mediapipe/framework/port:status",
@ -1162,22 +1162,22 @@ cc_library(
visibility = ["//visibility:public"],
deps = [
":calculator_base",
":calculator_cc_proto",
":calculator_contract",
":graph_service_manager",
":legacy_calculator_support",
":packet",
":packet_generator",
":packet_generator_cc_proto",
":packet_set",
":packet_type",
":port",
":status_handler",
":status_handler_cc_proto",
":stream_handler_cc_proto",
":subgraph",
":thread_pool_executor_cc_proto",
":timestamp",
"//mediapipe/framework:calculator_cc_proto",
"//mediapipe/framework:packet_generator_cc_proto",
"//mediapipe/framework:status_handler_cc_proto",
"//mediapipe/framework:stream_handler_cc_proto",
"//mediapipe/framework:thread_pool_executor_cc_proto",
"//mediapipe/framework/port:core_proto",
"//mediapipe/framework/port:integral_types",
"//mediapipe/framework/port:logging",
@ -1202,11 +1202,11 @@ cc_test(
name = "validated_graph_config_test",
srcs = ["validated_graph_config_test.cc"],
deps = [
":calculator_cc_proto",
":calculator_framework",
":graph_service",
":graph_service_manager",
":validated_graph_config",
"//mediapipe/framework:calculator_cc_proto",
"//mediapipe/framework/api2:node",
"//mediapipe/framework/api2:port",
"//mediapipe/framework/port:gtest_main",
@ -1233,6 +1233,7 @@ cc_test(
linkstatic = 1,
deps = [
":calculator_base",
":calculator_cc_proto",
":calculator_context",
":calculator_context_manager",
":calculator_registry",
@ -1242,7 +1243,6 @@ cc_test(
":output_stream_shard",
":packet_set",
":packet_type",
"//mediapipe/framework:calculator_cc_proto",
"//mediapipe/framework/port:gtest_main",
"//mediapipe/framework/port:status",
"//mediapipe/framework/tool:status_util",
@ -1256,11 +1256,11 @@ cc_test(
srcs = ["calculator_contract_test.cc"],
linkstatic = 1,
deps = [
":calculator_cc_proto",
":calculator_contract",
":calculator_contract_test_cc_proto",
"//mediapipe/framework:calculator_cc_proto",
"//mediapipe/framework:packet_generator_cc_proto",
"//mediapipe/framework:status_handler_cc_proto",
":packet_generator_cc_proto",
":status_handler_cc_proto",
"//mediapipe/framework/port:gtest_main",
"//mediapipe/framework/port:parse_text_proto",
],
@ -1368,6 +1368,7 @@ cc_test(
srcs = ["calculator_context_test.cc"],
linkstatic = 1,
deps = [
":calculator_cc_proto",
":calculator_context",
":calculator_context_manager",
":calculator_state",
@ -1376,7 +1377,6 @@ cc_test(
":output_stream_shard",
":packet_set",
":packet_type",
"//mediapipe/framework:calculator_cc_proto",
"//mediapipe/framework/port:gtest_main",
"//mediapipe/framework/port:parse_text_proto",
"//mediapipe/framework/port:status",
@ -1403,6 +1403,7 @@ cc_test(
":executor",
":input_stream_handler",
":lifetime_tracker",
":mediapipe_options_cc_proto",
":output_stream_poller",
":packet_set",
":packet_type",
@ -1410,13 +1411,12 @@ cc_test(
":subgraph",
":test_calculators",
":thread_pool_executor",
":thread_pool_executor_cc_proto",
":timestamp",
":type_map",
"//mediapipe/calculators/core:counting_source_calculator",
"//mediapipe/calculators/core:mux_calculator",
"//mediapipe/calculators/core:pass_through_calculator",
"//mediapipe/framework:mediapipe_options_cc_proto",
"//mediapipe/framework:thread_pool_executor_cc_proto",
"//mediapipe/framework/port:gtest_main",
"//mediapipe/framework/port:logging",
"//mediapipe/framework/port:parse_text_proto",
@ -1481,12 +1481,12 @@ cc_test(
],
visibility = ["//visibility:public"],
deps = [
":calculator_cc_proto",
":calculator_framework",
":test_calculators",
"//mediapipe/calculators/core:counting_source_calculator",
"//mediapipe/calculators/core:mux_calculator",
"//mediapipe/calculators/core:pass_through_calculator",
"//mediapipe/framework:calculator_cc_proto",
"//mediapipe/framework/port:gtest_main",
"//mediapipe/framework/port:logging",
"//mediapipe/framework/port:parse_text_proto",
@ -1630,8 +1630,8 @@ cc_test(
srcs = ["packet_generator_test.cc"],
deps = [
":packet_generator",
":packet_generator_cc_proto",
":packet_type",
"//mediapipe/framework:packet_generator_cc_proto",
"//mediapipe/framework/port:gtest_main",
"//mediapipe/framework/tool:validate_type",
"@com_google_absl//absl/strings",

View File

@ -20,9 +20,14 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
licenses(["notice"])
package(default_visibility = [
"//mediapipe:__subpackages__",
])
package_group(
name = "mediapipe_internal",
packages = [
"//mediapipe/...",
],
)
package(default_visibility = ["mediapipe_internal"])
bzl_library(
name = "expand_template_bzl",
@ -214,6 +219,9 @@ cc_library(
name = "registration",
srcs = ["registration.cc"],
hdrs = ["registration.h"],
visibility = [
"mediapipe_internal",
],
deps = [
":registration_token",
"//mediapipe/framework/port:logging",

View File

@ -26,7 +26,7 @@ licenses(["notice"])
mediapipe_proto_library(
name = "detection_proto",
srcs = ["detection.proto"],
deps = ["//mediapipe/framework/formats:location_data_proto"],
deps = [":location_data_proto"],
)
mediapipe_register_type(
@ -38,7 +38,7 @@ mediapipe_register_type(
"::std::vector<::mediapipe::Detection>",
"::std::vector<::mediapipe::DetectionList>",
],
deps = ["//mediapipe/framework/formats:detection_cc_proto"],
deps = [":detection_cc_proto"],
)
mediapipe_proto_library(
@ -105,8 +105,8 @@ cc_library(
srcs = ["matrix.cc"],
hdrs = ["matrix.h"],
deps = [
":matrix_data_cc_proto",
"//mediapipe/framework:port",
"//mediapipe/framework/formats:matrix_data_cc_proto",
"//mediapipe/framework/port:core_proto",
"//mediapipe/framework/port:logging",
"//mediapipe/framework/port:ret_check",
@ -142,7 +142,7 @@ cc_library(
srcs = ["image_frame.cc"],
hdrs = ["image_frame.h"],
deps = [
"//mediapipe/framework/formats:image_format_cc_proto",
":image_format_cc_proto",
"@com_google_absl//absl/base",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/memory",
@ -166,8 +166,8 @@ cc_library(
srcs = ["image_frame_opencv.cc"],
hdrs = ["image_frame_opencv.h"],
deps = [
":image_format_cc_proto",
":image_frame",
"//mediapipe/framework/formats:image_format_cc_proto",
"//mediapipe/framework/port:opencv_core",
],
)
@ -194,7 +194,7 @@ cc_library(
deps = [
"@com_google_protobuf//:protobuf",
"//mediapipe/framework/formats/annotation:locus_cc_proto",
"//mediapipe/framework/formats:location_data_cc_proto",
":location_data_cc_proto",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/memory",
"@com_google_absl//absl/strings",
@ -245,7 +245,7 @@ cc_library(
name = "video_stream_header",
hdrs = ["video_stream_header.h"],
deps = [
"//mediapipe/framework/formats:image_format_cc_proto",
":image_format_cc_proto",
],
)
@ -263,9 +263,9 @@ cc_test(
size = "small",
srcs = ["image_frame_opencv_test.cc"],
deps = [
":image_format_cc_proto",
":image_frame",
":image_frame_opencv",
"//mediapipe/framework/formats:image_format_cc_proto",
"//mediapipe/framework/port:gtest_main",
"//mediapipe/framework/port:integral_types",
"//mediapipe/framework/port:logging",
@ -324,8 +324,8 @@ cc_library(
"//conditions:default": [],
}),
deps = [
"//mediapipe/framework/formats:image_format_cc_proto",
"//mediapipe/framework/formats:image_frame",
":image_format_cc_proto",
":image_frame",
"@com_google_absl//absl/synchronization",
"//mediapipe/framework:port",
"//mediapipe/framework:type_map",
@ -354,7 +354,7 @@ cc_library(
hdrs = ["image_multi_pool.h"],
deps = [
":image",
"//mediapipe/framework/formats:image_frame_pool",
":image_frame_pool",
"//mediapipe/framework:port",
"//mediapipe/framework/port:logging",
"@com_google_absl//absl/memory",
@ -390,7 +390,7 @@ cc_library(
],
deps = [
":image",
"//mediapipe/framework/formats:image_format_cc_proto",
":image_format_cc_proto",
"//mediapipe/framework/port:logging",
"//mediapipe/framework/port:opencv_core",
"//mediapipe/framework/port:statusor",

View File

@ -38,11 +38,11 @@ cc_library(
srcs = ["optical_flow_field.cc"],
hdrs = ["optical_flow_field.h"],
deps = [
":optical_flow_field_data_cc_proto",
"//mediapipe/framework:type_map",
"//mediapipe/framework/deps:mathutil",
"//mediapipe/framework/formats:location",
"//mediapipe/framework/formats:location_opencv",
"//mediapipe/framework/formats/motion:optical_flow_field_data_cc_proto",
"//mediapipe/framework/port:file_helpers",
"//mediapipe/framework/port:integral_types",
"//mediapipe/framework/port:logging",

View File

@ -88,8 +88,8 @@ cc_library(
srcs = ["default_input_stream_handler.cc"],
hdrs = ["default_input_stream_handler.h"],
deps = [
":default_input_stream_handler_cc_proto",
"//mediapipe/framework:input_stream_handler",
"//mediapipe/framework/stream_handler:default_input_stream_handler_cc_proto",
"@com_google_absl//absl/strings",
],
alwayslink = 1,
@ -110,8 +110,8 @@ cc_library(
srcs = ["fixed_size_input_stream_handler.cc"],
deps = [
":default_input_stream_handler",
":fixed_size_input_stream_handler_cc_proto",
"//mediapipe/framework:input_stream_handler",
"//mediapipe/framework/stream_handler:fixed_size_input_stream_handler_cc_proto",
],
alwayslink = 1,
)
@ -159,13 +159,13 @@ cc_library(
name = "sync_set_input_stream_handler",
srcs = ["sync_set_input_stream_handler.cc"],
deps = [
":sync_set_input_stream_handler_cc_proto",
"//mediapipe/framework:collection",
"//mediapipe/framework:collection_item_id",
"//mediapipe/framework:input_stream_handler",
"//mediapipe/framework:mediapipe_options_cc_proto",
"//mediapipe/framework:packet_set",
"//mediapipe/framework:timestamp",
"//mediapipe/framework/stream_handler:sync_set_input_stream_handler_cc_proto",
"//mediapipe/framework/tool:tag_map",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/synchronization",
@ -177,10 +177,10 @@ cc_library(
name = "timestamp_align_input_stream_handler",
srcs = ["timestamp_align_input_stream_handler.cc"],
deps = [
":timestamp_align_input_stream_handler_cc_proto",
"//mediapipe/framework:collection_item_id",
"//mediapipe/framework:input_stream_handler",
"//mediapipe/framework:timestamp",
"//mediapipe/framework/stream_handler:timestamp_align_input_stream_handler_cc_proto",
"//mediapipe/framework/tool:validate_name",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/synchronization",
@ -243,6 +243,7 @@ cc_test(
srcs = ["set_input_stream_handler_test.cc"],
deps = [
":fixed_size_input_stream_handler",
":fixed_size_input_stream_handler_cc_proto",
":mux_input_stream_handler",
"//mediapipe/calculators/core:mux_calculator",
"//mediapipe/calculators/core:pass_through_calculator",
@ -251,7 +252,6 @@ cc_test(
"//mediapipe/framework/port:gtest_main",
"//mediapipe/framework/port:parse_text_proto",
"//mediapipe/framework/port:ret_check",
"//mediapipe/framework/stream_handler:fixed_size_input_stream_handler_cc_proto",
],
)
@ -272,13 +272,13 @@ cc_test(
srcs = ["fixed_size_input_stream_handler_test.cc"],
deps = [
":fixed_size_input_stream_handler",
":fixed_size_input_stream_handler_cc_proto",
"//mediapipe/calculators/core:counting_source_calculator",
"//mediapipe/calculators/core:pass_through_calculator",
"//mediapipe/framework:calculator_framework",
"//mediapipe/framework/port:gtest_main",
"//mediapipe/framework/port:logging",
"//mediapipe/framework/port:parse_text_proto",
"//mediapipe/framework/stream_handler:fixed_size_input_stream_handler_cc_proto",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/synchronization",
],
@ -289,11 +289,11 @@ cc_test(
srcs = ["sync_set_input_stream_handler_test.cc"],
deps = [
":sync_set_input_stream_handler",
":sync_set_input_stream_handler_cc_proto",
"//mediapipe/framework:calculator_framework",
"//mediapipe/framework:test_calculators",
"//mediapipe/framework/port:gtest_main",
"//mediapipe/framework/port:parse_text_proto",
"//mediapipe/framework/stream_handler:sync_set_input_stream_handler_cc_proto",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/memory",
"@com_google_absl//absl/strings",

View File

@ -299,6 +299,7 @@ mediapipe_cc_test(
requires_full_emulation = False,
deps = [
":node_chain_subgraph_cc_proto",
":node_chain_subgraph_options_lib",
":options_field_util",
":options_registry",
":options_syntax_util",
@ -313,7 +314,6 @@ mediapipe_cc_test(
"//mediapipe/framework/port:status",
"//mediapipe/framework/testdata:night_light_calculator_cc_proto",
"//mediapipe/framework/testdata:night_light_calculator_options_lib",
"//mediapipe/framework/tool:node_chain_subgraph_options_lib",
"//mediapipe/util:header_util",
"@com_google_absl//absl/strings",
],
@ -422,9 +422,9 @@ cc_library(
srcs = ["source.cc"],
visibility = ["//visibility:public"],
deps = [
":source_cc_proto",
"//mediapipe/framework:calculator_framework",
"//mediapipe/framework/port:status",
"//mediapipe/framework/tool:source_cc_proto",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/strings",
],
@ -485,13 +485,13 @@ cc_library(
hdrs = ["template_expander.h"],
visibility = ["//visibility:public"],
deps = [
":calculator_graph_template_cc_proto",
":proto_util_lite",
"//mediapipe/framework:calculator_cc_proto",
"//mediapipe/framework/port:logging",
"//mediapipe/framework/port:numbers",
"//mediapipe/framework/port:ret_check",
"//mediapipe/framework/port:status",
"//mediapipe/framework/tool:calculator_graph_template_cc_proto",
"@com_google_absl//absl/strings",
],
)
@ -506,6 +506,7 @@ cc_library(
],
visibility = ["//visibility:public"],
deps = [
":calculator_graph_template_cc_proto",
":proto_util_lite",
"//mediapipe/framework:calculator_cc_proto",
"//mediapipe/framework/deps:proto_descriptor_cc_proto",
@ -515,7 +516,6 @@ cc_library(
"//mediapipe/framework/port:map_util",
"//mediapipe/framework/port:ret_check",
"//mediapipe/framework/port:status",
"//mediapipe/framework/tool:calculator_graph_template_cc_proto",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/memory",
"@com_google_absl//absl/strings",
@ -661,8 +661,8 @@ cc_library(
hdrs = ["simulation_clock_executor.h"],
visibility = ["//visibility:public"],
deps = [
":simulation_clock",
"//mediapipe/framework:thread_pool_executor",
"//mediapipe/framework/tool:simulation_clock",
],
)
@ -789,10 +789,10 @@ cc_library(
visibility = ["//visibility:public"],
deps = [
":name_util",
":switch_container_cc_proto",
"//mediapipe/framework:calculator_framework",
"//mediapipe/framework/port:ret_check",
"//mediapipe/framework/port:status",
"//mediapipe/framework/tool:switch_container_cc_proto",
],
)
@ -805,6 +805,7 @@ cc_library(
deps = [
":container_util",
":options_util",
":switch_container_cc_proto",
"//mediapipe/framework:calculator_framework",
"//mediapipe/framework:collection_item_id",
"//mediapipe/framework/deps:mathutil",
@ -814,7 +815,6 @@ cc_library(
"//mediapipe/framework/port:ret_check",
"//mediapipe/framework/port:status",
"//mediapipe/framework/stream_handler:immediate_input_stream_handler",
"//mediapipe/framework/tool:switch_container_cc_proto",
"@com_google_absl//absl/strings",
],
alwayslink = 1,
@ -841,6 +841,7 @@ cc_library(
],
deps = [
":container_util",
":switch_container_cc_proto",
"//mediapipe/framework:calculator_framework",
"//mediapipe/framework:collection_item_id",
"//mediapipe/framework:input_stream_shard",
@ -850,7 +851,6 @@ cc_library(
"//mediapipe/framework/port:ret_check",
"//mediapipe/framework/port:status",
"//mediapipe/framework/stream_handler:immediate_input_stream_handler",
"//mediapipe/framework/tool:switch_container_cc_proto",
],
alwayslink = 1,
)
@ -893,6 +893,7 @@ cc_library(
":container_util",
":name_util",
":subgraph_expansion",
":switch_container_cc_proto",
":switch_demux_calculator",
":switch_mux_calculator",
"//mediapipe/calculators/core:packet_sequencer_calculator",
@ -904,7 +905,6 @@ cc_library(
"//mediapipe/framework/port:core_proto",
"//mediapipe/framework/port:ret_check",
"//mediapipe/framework/port:status",
"//mediapipe/framework/tool:switch_container_cc_proto",
"@com_google_absl//absl/strings",
],
alwayslink = 1,

View File

@ -564,6 +564,7 @@ cc_library(
name = "gpu_shared_data_internal_stub",
visibility = ["//visibility:private"],
deps = [
":gl_context_options_cc_proto",
":graph_support",
"//mediapipe/framework:calculator_context",
"//mediapipe/framework:calculator_node",
@ -571,7 +572,6 @@ cc_library(
"//mediapipe/framework:port",
"//mediapipe/framework/deps:no_destructor",
"//mediapipe/framework/port:ret_check",
"//mediapipe/gpu:gl_context_options_cc_proto",
],
)
@ -592,7 +592,7 @@ cc_library(
}),
visibility = ["//visibility:private"],
deps = [
"//mediapipe/gpu:gl_context_options_cc_proto",
":gl_context_options_cc_proto",
":graph_support",
"//mediapipe/framework:calculator_context",
"//mediapipe/framework:executor",
@ -833,10 +833,10 @@ cc_library(
deps = [
":gl_base",
":gl_simple_shaders",
":scale_mode_cc_proto",
":shader_util",
"//mediapipe/framework/port:ret_check",
"//mediapipe/framework/port:status",
"//mediapipe/gpu:scale_mode_cc_proto",
],
)
@ -907,8 +907,8 @@ proto_library(
srcs = ["gl_scaler_calculator.proto"],
visibility = ["//visibility:public"],
deps = [
":scale_mode_proto",
"//mediapipe/framework:calculator_proto",
"//mediapipe/gpu:scale_mode_proto",
],
)
@ -930,6 +930,7 @@ cc_library(
deps = [
":gl_calculator_helper",
":gl_quad_renderer",
":gl_scaler_calculator_cc_proto",
":gl_simple_shaders",
":shader_util",
"//mediapipe/framework:calculator_framework",
@ -937,7 +938,6 @@ cc_library(
"//mediapipe/framework/port:ret_check",
"//mediapipe/framework/port:status",
"//mediapipe/framework/tool:options_util",
"//mediapipe/gpu:gl_scaler_calculator_cc_proto",
],
alwayslink = 1,
)
@ -950,13 +950,13 @@ cc_library(
":egl_surface_holder",
":gl_calculator_helper",
":gl_quad_renderer",
":gl_surface_sink_calculator_cc_proto",
":gpu_buffer",
":shader_util",
"//mediapipe/framework:calculator_framework",
"//mediapipe/framework/api2:node",
"//mediapipe/framework/port:ret_check",
"//mediapipe/framework/port:status",
"//mediapipe/gpu:gl_surface_sink_calculator_cc_proto",
"@com_google_absl//absl/synchronization",
],
alwayslink = 1,
@ -966,8 +966,8 @@ proto_library(
name = "gl_surface_sink_calculator_proto",
srcs = ["gl_surface_sink_calculator.proto"],
deps = [
":scale_mode_proto",
"//mediapipe/framework:calculator_proto",
"//mediapipe/gpu:scale_mode_proto",
],
)

View File

@ -15,10 +15,13 @@
package com.google.mediapipe.framework;
import android.graphics.Bitmap;
import android.graphics.PixelFormat;
import android.media.Image;
import com.google.mediapipe.framework.image.BitmapExtractor;
import com.google.mediapipe.framework.image.ByteBufferExtractor;
import com.google.mediapipe.framework.image.MPImage;
import com.google.mediapipe.framework.image.MPImageProperties;
import com.google.mediapipe.framework.image.MediaImageExtractor;
import java.nio.ByteBuffer;
// TODO: use Preconditions in this file.
@ -97,7 +100,17 @@ public class AndroidPacketCreator extends PacketCreator {
}
return Packet.create(nativeCreateRgbaImage(mediapipeGraph.getNativeHandle(), bitmap));
}
if (properties.getStorageType() == MPImage.STORAGE_TYPE_MEDIA_IMAGE) {
Image mediaImage = MediaImageExtractor.extract(image);
if (mediaImage.getFormat() != PixelFormat.RGBA_8888) {
throw new UnsupportedOperationException("Android media image must use RGBA_8888 config.");
}
return createImage(
mediaImage.getPlanes()[0].getBuffer(),
mediaImage.getWidth(),
mediaImage.getHeight(),
/* numChannels= */ 4);
}
// Unsupported type.
throw new UnsupportedOperationException(
"Unsupported Image container type: " + properties.getStorageType());

View File

@ -17,3 +17,6 @@ from mediapipe.model_maker.python.core.utils import quantization
from mediapipe.model_maker.python.vision import image_classifier
from mediapipe.model_maker.python.vision import gesture_recognizer
from mediapipe.model_maker.python.text import text_classifier
# Remove duplicated and non-public API
del python

View File

@ -29,3 +29,12 @@ BertModelOptions = model_options.BertModelOptions
SupportedModels = model_spec.SupportedModels
TextClassifier = text_classifier.TextClassifier
TextClassifierOptions = text_classifier_options.TextClassifierOptions
# Remove duplicated and non-public API
del hyperparameters
del dataset
del model_options
del model_spec
del preprocessor # pylint: disable=undefined-variable
del text_classifier
del text_classifier_options

View File

@ -33,7 +33,6 @@ from mediapipe.model_maker.python.text.text_classifier import preprocessor
from mediapipe.model_maker.python.text.text_classifier import text_classifier_options
from mediapipe.tasks.python.metadata.metadata_writers import metadata_writer
from mediapipe.tasks.python.metadata.metadata_writers import text_classifier as text_classifier_writer
from official.nlp import optimization
def _validate(options: text_classifier_options.TextClassifierOptions):
@ -417,8 +416,22 @@ class _BertClassifier(TextClassifier):
total_steps = self._hparams.steps_per_epoch * self._hparams.epochs
warmup_steps = int(total_steps * 0.1)
initial_lr = self._hparams.learning_rate
self._optimizer = optimization.create_optimizer(initial_lr, total_steps,
warmup_steps)
# Implements linear decay of the learning rate.
lr_schedule = tf.keras.optimizers.schedules.PolynomialDecay(
initial_learning_rate=initial_lr,
decay_steps=total_steps,
end_learning_rate=0.0,
power=1.0)
if warmup_steps:
lr_schedule = model_util.WarmUp(
initial_learning_rate=initial_lr,
decay_schedule_fn=lr_schedule,
warmup_steps=warmup_steps)
self._optimizer = tf.keras.optimizers.experimental.AdamW(
lr_schedule, weight_decay=0.01, epsilon=1e-6, global_clipnorm=1.0)
self._optimizer.exclude_from_weight_decay(
var_names=["LayerNorm", "layer_norm", "bias"])
def _save_vocab(self, vocab_filepath: str):
tf.io.gfile.copy(

View File

@ -146,6 +146,8 @@ py_test(
tags = ["notsan"],
deps = [
":gesture_recognizer_import",
":hyperparameters",
":model_options",
"//mediapipe/model_maker/python/core/utils:test_util",
"//mediapipe/tasks/python/test:test_utils",
],

View File

@ -25,3 +25,12 @@ HParams = hyperparameters.HParams
Dataset = dataset.Dataset
HandDataPreprocessingParams = dataset.HandDataPreprocessingParams
GestureRecognizerOptions = gesture_recognizer_options.GestureRecognizerOptions
# Remove duplicated and non-public API
del constants # pylint: disable=undefined-variable
del dataset
del gesture_recognizer
del gesture_recognizer_options
del hyperparameters
del metadata_writer # pylint: disable=undefined-variable
del model_options

View File

@ -23,6 +23,8 @@ import tensorflow as tf
from mediapipe.model_maker.python.core.utils import test_util
from mediapipe.model_maker.python.vision import gesture_recognizer
from mediapipe.model_maker.python.vision.gesture_recognizer import hyperparameters
from mediapipe.model_maker.python.vision.gesture_recognizer import model_options
from mediapipe.tasks.python.test import test_utils
_TEST_DATA_DIR = 'mediapipe/model_maker/python/vision/gesture_recognizer/testdata'
@ -48,11 +50,11 @@ class GestureRecognizerTest(tf.test.TestCase):
self._train_data, self._validation_data = all_data.split(0.9)
def test_gesture_recognizer_model(self):
model_options = gesture_recognizer.ModelOptions()
mo = gesture_recognizer.ModelOptions()
hparams = gesture_recognizer.HParams(
export_dir=tempfile.mkdtemp(), epochs=2)
gesture_recognizer_options = gesture_recognizer.GestureRecognizerOptions(
model_options=model_options, hparams=hparams)
model_options=mo, hparams=hparams)
model = gesture_recognizer.GestureRecognizer.create(
train_data=self._train_data,
validation_data=self._validation_data,
@ -64,11 +66,11 @@ class GestureRecognizerTest(tf.test.TestCase):
tf.keras.layers, 'Dense', wraps=tf.keras.layers.Dense)
def test_gesture_recognizer_model_layer_widths(self, mock_dense):
layer_widths = [64, 32]
model_options = gesture_recognizer.ModelOptions(layer_widths=layer_widths)
mo = gesture_recognizer.ModelOptions(layer_widths=layer_widths)
hparams = gesture_recognizer.HParams(
export_dir=tempfile.mkdtemp(), epochs=2)
gesture_recognizer_options = gesture_recognizer.GestureRecognizerOptions(
model_options=model_options, hparams=hparams)
model_options=mo, hparams=hparams)
model = gesture_recognizer.GestureRecognizer.create(
train_data=self._train_data,
validation_data=self._validation_data,
@ -87,11 +89,11 @@ class GestureRecognizerTest(tf.test.TestCase):
self._test_accuracy(model)
def test_export_gesture_recognizer_model(self):
model_options = gesture_recognizer.ModelOptions()
mo = gesture_recognizer.ModelOptions()
hparams = gesture_recognizer.HParams(
export_dir=tempfile.mkdtemp(), epochs=2)
gesture_recognizer_options = gesture_recognizer.GestureRecognizerOptions(
model_options=model_options, hparams=hparams)
model_options=mo, hparams=hparams)
model = gesture_recognizer.GestureRecognizer.create(
train_data=self._train_data,
validation_data=self._validation_data,
@ -128,12 +130,12 @@ class GestureRecognizerTest(tf.test.TestCase):
self.assertGreater(accuracy, threshold)
@unittest_mock.patch.object(
gesture_recognizer.hyperparameters,
hyperparameters,
'HParams',
autospec=True,
return_value=gesture_recognizer.HParams(epochs=1))
@unittest_mock.patch.object(
gesture_recognizer.model_options,
model_options,
'GestureRecognizerModelOptions',
autospec=True,
return_value=gesture_recognizer.ModelOptions())
@ -148,11 +150,11 @@ class GestureRecognizerTest(tf.test.TestCase):
mock_model_options.assert_called_once()
def test_continual_training_by_loading_checkpoint(self):
model_options = gesture_recognizer.ModelOptions()
mo = gesture_recognizer.ModelOptions()
hparams = gesture_recognizer.HParams(
export_dir=tempfile.mkdtemp(), epochs=2)
gesture_recognizer_options = gesture_recognizer.GestureRecognizerOptions(
model_options=model_options, hparams=hparams)
model_options=mo, hparams=hparams)
mock_stdout = io.StringIO()
with mock.patch('sys.stdout', mock_stdout):
model = gesture_recognizer.GestureRecognizer.create(

View File

@ -121,7 +121,9 @@ py_library(
srcs = ["image_classifier_test.py"],
data = ["//mediapipe/model_maker/python/vision/image_classifier/testdata"],
deps = [
":hyperparameters",
":image_classifier_import",
":model_options",
"//mediapipe/tasks/python/test:test_utils",
],
)

View File

@ -27,3 +27,12 @@ ModelOptions = model_options.ImageClassifierModelOptions
ModelSpec = model_spec.ModelSpec
SupportedModels = model_spec.SupportedModels
ImageClassifierOptions = image_classifier_options.ImageClassifierOptions
# Remove duplicated and non-public API
del dataset
del hyperparameters
del image_classifier
del image_classifier_options
del model_options
del model_spec
del train_image_classifier_lib # pylint: disable=undefined-variable

View File

@ -24,6 +24,8 @@ import numpy as np
import tensorflow as tf
from mediapipe.model_maker.python.vision import image_classifier
from mediapipe.model_maker.python.vision.image_classifier import hyperparameters
from mediapipe.model_maker.python.vision.image_classifier import model_options
from mediapipe.tasks.python.test import test_utils
@ -159,15 +161,15 @@ class ImageClassifierTest(tf.test.TestCase, parameterized.TestCase):
self.assertGreaterEqual(accuracy, threshold)
@unittest_mock.patch.object(
image_classifier.hyperparameters,
hyperparameters,
'HParams',
autospec=True,
return_value=image_classifier.HParams(epochs=1))
return_value=hyperparameters.HParams(epochs=1))
@unittest_mock.patch.object(
image_classifier.model_options,
model_options,
'ImageClassifierModelOptions',
autospec=True,
return_value=image_classifier.ModelOptions())
return_value=model_options.ImageClassifierModelOptions())
def test_create_hparams_and_model_options_if_none_in_image_classifier_options(
self, mock_hparams, mock_model_options):
options = image_classifier.ImageClassifierOptions(

View File

@ -1,5 +1,5 @@
absl-py
mediapipe==0.9.1
mediapipe==0.9.0.1
numpy
opencv-python
tensorflow>=2.10

View File

@ -86,7 +86,7 @@ describe('convertBaseOptionsToProto()', () => {
it('can enable CPU delegate', async () => {
const baseOptionsProto = await convertBaseOptionsToProto({
modelAssetBuffer: new Uint8Array(mockBytes),
delegate: 'cpu',
delegate: 'CPU',
});
expect(baseOptionsProto.toObject()).toEqual(mockBytesResult);
});
@ -94,7 +94,7 @@ describe('convertBaseOptionsToProto()', () => {
it('can enable GPU delegate', async () => {
const baseOptionsProto = await convertBaseOptionsToProto({
modelAssetBuffer: new Uint8Array(mockBytes),
delegate: 'gpu',
delegate: 'GPU',
});
expect(baseOptionsProto.toObject()).toEqual({
...mockBytesResult,
@ -117,7 +117,7 @@ describe('convertBaseOptionsToProto()', () => {
it('can reset delegate', async () => {
let baseOptionsProto = await convertBaseOptionsToProto({
modelAssetBuffer: new Uint8Array(mockBytes),
delegate: 'gpu',
delegate: 'GPU',
});
// Clear backend
baseOptionsProto =

View File

@ -71,7 +71,7 @@ async function configureExternalFile(
/** Configues the `acceleration` option. */
function configureAcceleration(options: BaseOptions, proto: BaseOptionsProto) {
const acceleration = proto.getAcceleration() ?? new Acceleration();
if (options.delegate === 'gpu') {
if (options.delegate === 'GPU') {
acceleration.setGpu(new InferenceCalculatorOptions.Delegate.Gpu());
} else {
acceleration.setTflite(new InferenceCalculatorOptions.Delegate.TfLite());

View File

@ -31,7 +31,7 @@ export declare interface BaseOptions {
modelAssetBuffer?: Uint8Array|undefined;
/** Overrides the default backend to use for the provided model. */
delegate?: 'cpu'|'gpu'|undefined;
delegate?: 'CPU'|'GPU'|undefined;
}
/** Options to configure MediaPipe Tasks in general. */

View File

@ -1028,7 +1028,9 @@ export class GraphRunner {
// Set up our TS listener to receive any packets for this stream, and
// additionally reformat our Uint8Array into a Float32Array for the user.
this.setListener(outputStreamName, (data: Uint8Array) => {
const floatArray = new Float32Array(data.buffer); // Should be very fast
// Should be very fast
const floatArray =
new Float32Array(data.buffer, data.byteOffset, data.length / 4);
callbackFcn(floatArray);
});

View File

@ -490,10 +490,10 @@ setuptools.setup(
'Operating System :: MacOS :: MacOS X',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3 :: Only',
'Topic :: Scientific/Engineering',
'Topic :: Scientific/Engineering :: Artificial Intelligence',