From 36ec2c60e63fcc4dc44e1e1212dd19dfe7e6311d Mon Sep 17 00:00:00 2001 From: Fergus Henderson Date: Fri, 16 Feb 2024 05:01:58 -0800 Subject: Introduce new intermediate targets that don't depend on frame_buffer_utils. PiperOrigin-RevId: 607654249 --- tensorflow_lite_support/cc/task/processor/BUILD | 34 +++- tensorflow_lite_support/cc/task/vision/BUILD | 197 +++++++++++++++++++++++- 2 files changed, 225 insertions(+), 6 deletions(-) diff --git a/tensorflow_lite_support/cc/task/processor/BUILD b/tensorflow_lite_support/cc/task/processor/BUILD index d38c3690..f43789f3 100644 --- a/tensorflow_lite_support/cc/task/processor/BUILD +++ b/tensorflow_lite_support/cc/task/processor/BUILD @@ -26,18 +26,50 @@ cc_library_with_tflite( cc_library_with_tflite( name = "image_preprocessor", + hdrs = ["image_preprocessor.h"], + # Note, order of dependencies is significant here: image_preprocess_impl + # needs to precede frame_buffer_utils. This is needed in order to + # ensure that the object file for frame_buffer_utils.cc ends up _after_ + # the object file for image_preprocessor.cc on the link line, despite + # the image_preprocessor_impl only depending on frame_buffer_utils_h + # (the target for the header file only) not on frame_buffer_utils (which + # is the target that contains frame_buffer_utils.cc). That order in the + # link line is needed to avoid a "ld: error: backward reference detected" + # error from the linker, due to the reference in image_preprocessor.cc to + # a symbol defined in frame_buffer_utils.cc. That's why this dependency + # needs to be listed in 'more_deps' (which come after 'tflite_deps') + # rather than in 'deps' (which come before 'tflite_deps'). + more_deps = [ + "//tensorflow_lite_support/cc/task/vision/utils:frame_buffer_utils", # build_cleaner: keep + ], + tflite_deps = [ + ":image_preprocessor_impl", + ":processor", + "//tensorflow_lite_support/cc/task/vision/utils:image_tensor_specs", + ], + deps = [ + "//tensorflow_lite_support/cc/port:status_macros", + "//tensorflow_lite_support/cc/task/core:task_utils", + "//tensorflow_lite_support/cc/task/vision/core:frame_buffer", + "//tensorflow_lite_support/cc/task/vision/proto:bounding_box_proto_inc", + ], +) + +cc_library_with_tflite( + name = "image_preprocessor_impl", srcs = ["image_preprocessor.cc"], hdrs = ["image_preprocessor.h"], tflite_deps = [ ":processor", "//tensorflow_lite_support/cc/task/vision/utils:image_tensor_specs", ], + visibility = ["//visibility:private"], deps = [ "//tensorflow_lite_support/cc/port:status_macros", "//tensorflow_lite_support/cc/task/core:task_utils", "//tensorflow_lite_support/cc/task/vision/core:frame_buffer", "//tensorflow_lite_support/cc/task/vision/proto:bounding_box_proto_inc", - "//tensorflow_lite_support/cc/task/vision/utils:frame_buffer_utils", + "//tensorflow_lite_support/cc/task/vision/utils:frame_buffer_utils_h", "@com_google_absl//absl/memory", ], ) diff --git a/tensorflow_lite_support/cc/task/vision/BUILD b/tensorflow_lite_support/cc/task/vision/BUILD index 4849cdbd..6161b002 100644 --- a/tensorflow_lite_support/cc/task/vision/BUILD +++ b/tensorflow_lite_support/cc/task/vision/BUILD @@ -15,6 +15,45 @@ package( # https://github.com/tensorflow/tflite-support/blob/a58a4f9225c411fa9ba29f821523e6e283988d23/tensorflow_lite_support/acceleration/configuration/BUILD#L11 cc_library_with_tflite( name = "object_detector", + hdrs = ["object_detector.h"], + more_deps = [ + "//tensorflow_lite_support/cc/task/vision/utils:frame_buffer_utils", # build_cleaner: keep + ], + tflite_deps = [ + ":object_detector_impl", + "@org_tensorflow//tensorflow/lite/kernels:builtin_ops", + "//tensorflow_lite_support/cc/task/core:task_api_factory", + "//tensorflow_lite_support/cc/task/core:tflite_engine", + "//tensorflow_lite_support/cc/task/vision/core:base_vision_task_api", + ], + deps = [ + "//tensorflow_lite_support/cc:common", + "//tensorflow_lite_support/cc/port:status_macros", + "//tensorflow_lite_support/cc/port:statusor", + "//tensorflow_lite_support/cc/task/core:external_file_handler", + "//tensorflow_lite_support/cc/task/core:task_utils", + "//tensorflow_lite_support/cc/task/vision/core:frame_buffer", + "//tensorflow_lite_support/cc/task/vision/core:label_map_item", + "//tensorflow_lite_support/cc/task/vision/proto:bounding_box_proto_inc", + "//tensorflow_lite_support/cc/task/vision/proto:class_proto_inc", + "//tensorflow_lite_support/cc/task/vision/proto:detections_proto_inc", + "//tensorflow_lite_support/cc/task/vision/proto:object_detector_options_proto_inc", + "//tensorflow_lite_support/cc/task/vision/utils:score_calibration", + "//tensorflow_lite_support/metadata:metadata_schema_cc", + "//tensorflow_lite_support/metadata/cc:metadata_extractor", + "@com_google_absl//absl/container:flat_hash_set", + "@com_google_absl//absl/memory", + "@com_google_absl//absl/status", + "@com_google_absl//absl/strings", + "@com_google_absl//absl/strings:str_format", + "@com_google_glog//:glog", + "@org_tensorflow//tensorflow/lite/c:common", + "@org_tensorflow//tensorflow/lite/core/api", + ], +) + +cc_library_with_tflite( + name = "object_detector_impl", srcs = ["object_detector.cc"], hdrs = ["object_detector.h"], tflite_deps = [ @@ -23,6 +62,7 @@ cc_library_with_tflite( "//tensorflow_lite_support/cc/task/core:tflite_engine", "//tensorflow_lite_support/cc/task/vision/core:base_vision_task_api", ], + visibility = ["//visibility:private"], deps = [ "//tensorflow_lite_support/cc:common", "//tensorflow_lite_support/cc/port:status_macros", @@ -35,7 +75,7 @@ cc_library_with_tflite( "//tensorflow_lite_support/cc/task/vision/proto:class_proto_inc", "//tensorflow_lite_support/cc/task/vision/proto:detections_proto_inc", "//tensorflow_lite_support/cc/task/vision/proto:object_detector_options_proto_inc", - "//tensorflow_lite_support/cc/task/vision/utils:frame_buffer_utils", + "//tensorflow_lite_support/cc/task/vision/utils:frame_buffer_utils_h", "//tensorflow_lite_support/cc/task/vision/utils:score_calibration", "//tensorflow_lite_support/metadata:metadata_schema_cc", "//tensorflow_lite_support/metadata/cc:metadata_extractor", @@ -58,6 +98,47 @@ cc_library_with_tflite( # https://github.com/tensorflow/tflite-support/blob/a58a4f9225c411fa9ba29f821523e6e283988d23/tensorflow_lite_support/acceleration/configuration/BUILD#L11 cc_library_with_tflite( name = "image_classifier", + hdrs = ["image_classifier.h"], + more_deps = [ + "//tensorflow_lite_support/cc/task/vision/utils:frame_buffer_utils", # buildcleaner: keep + ], + tflite_deps = [ + ":image_classifier_impl", + "@org_tensorflow//tensorflow/lite/kernels:builtin_ops", + "//tensorflow_lite_support/cc/task/core:task_api_factory", + "//tensorflow_lite_support/cc/task/core:tflite_engine", + "//tensorflow_lite_support/cc/task/vision/core:base_vision_task_api", + ], + deps = [ + "//tensorflow_lite_support/cc:common", + "//tensorflow_lite_support/cc/port:integral_types", + "//tensorflow_lite_support/cc/port:status_macros", + "//tensorflow_lite_support/cc/port:statusor", + "//tensorflow_lite_support/cc/task/core:external_file_handler", + "//tensorflow_lite_support/cc/task/core:task_utils", + "//tensorflow_lite_support/cc/task/vision/core:classification_head", + "//tensorflow_lite_support/cc/task/vision/core:frame_buffer", + "//tensorflow_lite_support/cc/task/vision/core:label_map_item", + "//tensorflow_lite_support/cc/task/vision/proto:bounding_box_proto_inc", + "//tensorflow_lite_support/cc/task/vision/proto:class_proto_inc", + "//tensorflow_lite_support/cc/task/vision/proto:classifications_proto_inc", + "//tensorflow_lite_support/cc/task/vision/proto:image_classifier_options_proto_inc", + "//tensorflow_lite_support/cc/task/vision/utils:score_calibration", + "//tensorflow_lite_support/metadata:metadata_schema_cc", + "//tensorflow_lite_support/metadata/cc:metadata_extractor", + "@com_google_absl//absl/algorithm:container", + "@com_google_absl//absl/container:flat_hash_set", + "@com_google_absl//absl/status", + "@com_google_absl//absl/strings", + "@com_google_absl//absl/strings:str_format", + "@flatbuffers", + "@org_tensorflow//tensorflow/lite/c:common", + "@org_tensorflow//tensorflow/lite/core/api", + ], +) + +cc_library_with_tflite( + name = "image_classifier_impl", srcs = ["image_classifier.cc"], hdrs = ["image_classifier.h"], tflite_deps = [ @@ -66,6 +147,7 @@ cc_library_with_tflite( "//tensorflow_lite_support/cc/task/core:tflite_engine", "//tensorflow_lite_support/cc/task/vision/core:base_vision_task_api", ], + visibility = ["//visibility:private"], deps = [ "//tensorflow_lite_support/cc:common", "//tensorflow_lite_support/cc/port:integral_types", @@ -80,7 +162,7 @@ cc_library_with_tflite( "//tensorflow_lite_support/cc/task/vision/proto:class_proto_inc", "//tensorflow_lite_support/cc/task/vision/proto:classifications_proto_inc", "//tensorflow_lite_support/cc/task/vision/proto:image_classifier_options_proto_inc", - "//tensorflow_lite_support/cc/task/vision/utils:frame_buffer_utils", + "//tensorflow_lite_support/cc/task/vision/utils:frame_buffer_utils_h", "//tensorflow_lite_support/cc/task/vision/utils:score_calibration", "//tensorflow_lite_support/metadata:metadata_schema_cc", "//tensorflow_lite_support/metadata/cc:metadata_extractor", @@ -103,6 +185,43 @@ cc_library_with_tflite( # https://github.com/tensorflow/tflite-support/blob/a58a4f9225c411fa9ba29f821523e6e283988d23/tensorflow_lite_support/acceleration/configuration/BUILD#L11 cc_library_with_tflite( name = "image_segmenter", + hdrs = ["image_segmenter.h"], + more_deps = [ + "//tensorflow_lite_support/cc/task/vision/utils:frame_buffer_utils", # build_cleaner: keep + ], + tflite_deps = [ + ":image_segmenter_impl", + "@org_tensorflow//tensorflow/lite/kernels:builtin_ops", + "//tensorflow_lite_support/cc/task/core:tflite_engine", + "//tensorflow_lite_support/cc/task/core:task_api_factory", + "//tensorflow_lite_support/cc/task/vision/core:base_vision_task_api", + ], + deps = [ + "//tensorflow_lite_support/cc:common", + "//tensorflow_lite_support/cc/port:integral_types", + "//tensorflow_lite_support/cc/port:status_macros", + "//tensorflow_lite_support/cc/port:statusor", + "//tensorflow_lite_support/cc/task/core:external_file_handler", + "//tensorflow_lite_support/cc/task/core:task_utils", + "//tensorflow_lite_support/cc/task/vision/core:frame_buffer", + "//tensorflow_lite_support/cc/task/vision/core:label_map_item", + "//tensorflow_lite_support/cc/task/vision/proto:bounding_box_proto_inc", + "//tensorflow_lite_support/cc/task/vision/proto:image_segmenter_options_proto_inc", + "//tensorflow_lite_support/cc/task/vision/proto:segmentations_proto_inc", + "//tensorflow_lite_support/metadata:metadata_schema_cc", + "//tensorflow_lite_support/metadata/cc:metadata_extractor", + "@com_google_absl//absl/memory", + "@com_google_absl//absl/status", + "@com_google_absl//absl/strings", + "@com_google_absl//absl/strings:str_format", + "@flatbuffers", + "@org_tensorflow//tensorflow/lite/c:common", + "@org_tensorflow//tensorflow/lite/core/api", + ], +) + +cc_library_with_tflite( + name = "image_segmenter_impl", srcs = ["image_segmenter.cc"], hdrs = ["image_segmenter.h"], tflite_deps = [ @@ -111,6 +230,7 @@ cc_library_with_tflite( "//tensorflow_lite_support/cc/task/core:task_api_factory", "//tensorflow_lite_support/cc/task/vision/core:base_vision_task_api", ], + visibility = ["//visibility:private"], deps = [ "//tensorflow_lite_support/cc:common", "//tensorflow_lite_support/cc/port:integral_types", @@ -123,7 +243,7 @@ cc_library_with_tflite( "//tensorflow_lite_support/cc/task/vision/proto:bounding_box_proto_inc", "//tensorflow_lite_support/cc/task/vision/proto:image_segmenter_options_proto_inc", "//tensorflow_lite_support/cc/task/vision/proto:segmentations_proto_inc", - "//tensorflow_lite_support/cc/task/vision/utils:frame_buffer_utils", + "//tensorflow_lite_support/cc/task/vision/utils:frame_buffer_utils_h", "//tensorflow_lite_support/metadata:metadata_schema_cc", "//tensorflow_lite_support/metadata/cc:metadata_extractor", "@com_google_absl//absl/memory", @@ -144,6 +264,40 @@ cc_library_with_tflite( # https://github.com/tensorflow/tflite-support/blob/a58a4f9225c411fa9ba29f821523e6e283988d23/tensorflow_lite_support/acceleration/configuration/BUILD#L11 cc_library_with_tflite( name = "image_embedder", + hdrs = ["image_embedder.h"], + more_deps = [ + "//tensorflow_lite_support/cc/task/vision/utils:frame_buffer_utils", + ], + tflite_deps = [ + ":image_embedder_impl", + "@org_tensorflow//tensorflow/lite/kernels:builtin_ops", + "//tensorflow_lite_support/cc/task/core:task_api_factory", + "//tensorflow_lite_support/cc/task/core:tflite_engine", + "//tensorflow_lite_support/cc/task/vision/core:base_vision_task_api", + "//tensorflow_lite_support/cc/task/processor:embedding_postprocessor", + ], + deps = [ + "//tensorflow_lite_support/cc:common", + "//tensorflow_lite_support/cc/port:integral_types", + "//tensorflow_lite_support/cc/port:status_macros", + "//tensorflow_lite_support/cc/port:statusor", + "//tensorflow_lite_support/cc/task/core:external_file_handler", + "//tensorflow_lite_support/cc/task/vision/core:frame_buffer", + "//tensorflow_lite_support/cc/task/vision/proto:bounding_box_proto_inc", + "//tensorflow_lite_support/cc/task/vision/proto:embeddings_proto_inc", + "//tensorflow_lite_support/cc/task/vision/proto:image_embedder_options_proto_inc", + "@com_google_absl//absl/container:node_hash_set", + "@com_google_absl//absl/memory", + "@com_google_absl//absl/status", + "@com_google_absl//absl/strings", + "@com_google_absl//absl/strings:str_format", + "@org_tensorflow//tensorflow/lite/c:common", + "@org_tensorflow//tensorflow/lite/core/api:op_resolver", + ], +) + +cc_library_with_tflite( + name = "image_embedder_impl", srcs = ["image_embedder.cc"], hdrs = ["image_embedder.h"], tflite_deps = [ @@ -153,6 +307,7 @@ cc_library_with_tflite( "//tensorflow_lite_support/cc/task/vision/core:base_vision_task_api", "//tensorflow_lite_support/cc/task/processor:embedding_postprocessor", ], + visibility = ["//visibility:private"], deps = [ "//tensorflow_lite_support/cc:common", "//tensorflow_lite_support/cc/port:integral_types", @@ -163,7 +318,7 @@ cc_library_with_tflite( "//tensorflow_lite_support/cc/task/vision/proto:bounding_box_proto_inc", "//tensorflow_lite_support/cc/task/vision/proto:embeddings_proto_inc", "//tensorflow_lite_support/cc/task/vision/proto:image_embedder_options_proto_inc", - "//tensorflow_lite_support/cc/task/vision/utils:frame_buffer_utils", + "//tensorflow_lite_support/cc/task/vision/utils:frame_buffer_utils_h", "@com_google_absl//absl/container:node_hash_set", "@com_google_absl//absl/memory", "@com_google_absl//absl/status", @@ -182,6 +337,37 @@ cc_library_with_tflite( # https://github.com/tensorflow/tflite-support/blob/a58a4f9225c411fa9ba29f821523e6e283988d23/tensorflow_lite_support/acceleration/configuration/BUILD#L11 cc_library_with_tflite( name = "image_searcher", + hdrs = ["image_searcher.h"], + more_deps = [ + "//tensorflow_lite_support/cc/task/vision/utils:frame_buffer_utils", # buildcleaner:keep + ], + tflite_deps = [ + ":image_searcher_impl", + "@org_tensorflow//tensorflow/lite/kernels:builtin_ops", + "//tensorflow_lite_support/cc/task/core:task_api_factory", + "//tensorflow_lite_support/cc/task/core:tflite_engine", + "//tensorflow_lite_support/cc/task/processor:search_postprocessor", + "//tensorflow_lite_support/cc/task/vision/core:base_vision_task_api", + ], + deps = [ + "//tensorflow_lite_support/cc/port:status_macros", + "//tensorflow_lite_support/cc/port:statusor", + "//tensorflow_lite_support/cc/task/processor/proto:embedding_options_cc_proto", + "//tensorflow_lite_support/cc/task/processor/proto:search_options_cc_proto", + "//tensorflow_lite_support/cc/task/processor/proto:search_result_cc_proto", + "//tensorflow_lite_support/cc/task/vision/core:frame_buffer", + "//tensorflow_lite_support/cc/task/vision/proto:bounding_box_proto_inc", + "//tensorflow_lite_support/cc/task/vision/proto:image_searcher_options_cc_proto", + "@com_google_absl//absl/memory", + "@com_google_absl//absl/status", + "@com_google_absl//absl/strings", + "@org_tensorflow//tensorflow/lite/c:common", + "@org_tensorflow//tensorflow/lite/core/api:op_resolver", + ], +) + +cc_library_with_tflite( + name = "image_searcher_impl", srcs = ["image_searcher.cc"], hdrs = ["image_searcher.h"], tflite_deps = [ @@ -191,6 +377,7 @@ cc_library_with_tflite( "//tensorflow_lite_support/cc/task/processor:search_postprocessor", "//tensorflow_lite_support/cc/task/vision/core:base_vision_task_api", ], + visibility = ["//visibility:private"], deps = [ "//tensorflow_lite_support/cc/port:status_macros", "//tensorflow_lite_support/cc/port:statusor", @@ -200,7 +387,7 @@ cc_library_with_tflite( "//tensorflow_lite_support/cc/task/vision/core:frame_buffer", "//tensorflow_lite_support/cc/task/vision/proto:bounding_box_proto_inc", "//tensorflow_lite_support/cc/task/vision/proto:image_searcher_options_cc_proto", - "//tensorflow_lite_support/cc/task/vision/utils:frame_buffer_utils", + "//tensorflow_lite_support/cc/task/vision/utils:frame_buffer_utils_h", "@com_google_absl//absl/memory", "@com_google_absl//absl/status", "@com_google_absl//absl/strings", -- cgit v1.2.3