Use ABSL_LOG in MediaPipe.

This is needed in Chrome builds to avoid collisions with its own LOG.

PiperOrigin-RevId: 561436864
This commit is contained in:
MediaPipe Team
2023-08-30 13:43:49 -07:00
committed by Copybara-Service
parent f60da2120d
commit c92570f844
243 changed files with 1396 additions and 1087 deletions
@@ -199,6 +199,7 @@ cc_library(
"//mediapipe/util:label_map_cc_proto",
"//mediapipe/util:label_map_util",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/log:absl_log",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
@@ -20,6 +20,7 @@ limitations under the License.
#include <vector>
#include "absl/container/flat_hash_set.h"
#include "absl/log/absl_log.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_format.h"
@@ -336,7 +337,7 @@ absl::StatusOr<std::vector<int>> GetOutputTensorIndices(
int output_index = output_indices[i];
// If tensor name is not found, set the default output indices.
if (output_index == -1) {
LOG(WARNING) << absl::StrFormat(
ABSL_LOG(WARNING) << absl::StrFormat(
"You don't seem to be matching tensor names in metadata list. The "
"tensor name \"%s\" at index %d in the model metadata doesn't "
"match "
@@ -360,7 +361,7 @@ absl::StatusOr<std::vector<int>> GetOutputTensorIndices(
int output_index = output_indices[i];
// If tensor name is not found, set the default output indices.
if (output_index == -1) {
LOG(WARNING) << absl::StrFormat(
ABSL_LOG(WARNING) << absl::StrFormat(
"You don't seem to be matching tensor names in metadata list. The "
"tensor name \"%s\" at index %d in the model metadata doesn't "
"match "
+2 -2
View File
@@ -29,7 +29,7 @@ cc_library(
"//mediapipe/tasks/cc/core/proto:acceleration_cc_proto",
"//mediapipe/tasks/cc/core/proto:base_options_cc_proto",
"//mediapipe/tasks/cc/core/proto:external_file_cc_proto",
"@com_google_absl//absl/log",
"@com_google_absl//absl/log:absl_log",
"@com_google_absl//absl/memory",
"@org_tensorflow//tensorflow/lite/core/api:op_resolver",
"@org_tensorflow//tensorflow/lite/kernels:builtin_ops",
@@ -108,13 +108,13 @@ cc_library(
"//mediapipe/framework:subgraph",
"//mediapipe/framework/api2:builder",
"//mediapipe/framework/api2:port",
"//mediapipe/framework/port:logging",
"//mediapipe/tasks/cc:common",
"//mediapipe/tasks/cc/core/proto:acceleration_cc_proto",
"//mediapipe/tasks/cc/core/proto:base_options_cc_proto",
"//mediapipe/tasks/cc/core/proto:external_file_cc_proto",
"//mediapipe/tasks/cc/core/proto:inference_subgraph_cc_proto",
"//mediapipe/tasks/cc/core/proto:model_resources_calculator_cc_proto",
"@com_google_absl//absl/log:absl_log",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
+3 -3
View File
@@ -19,7 +19,7 @@ limitations under the License.
#include <string>
#include <variant>
#include "absl/log/log.h"
#include "absl/log/absl_log.h"
#include "mediapipe/calculators/tensor/inference_calculator.pb.h"
#include "mediapipe/tasks/cc/core/proto/acceleration.pb.h"
#include "mediapipe/tasks/cc/core/proto/base_options.pb.h"
@@ -58,8 +58,8 @@ void SetDelegateOptionsOrDie(const BaseOptions* base_options,
proto::BaseOptions& base_options_proto) {
if (base_options->delegate_options.has_value()) {
if (!std::holds_alternative<T>(*base_options->delegate_options)) {
LOG(FATAL) << "Specified Delegate type does not match the provided "
"delegate options.";
ABSL_LOG(FATAL) << "Specified Delegate type does not match the provided "
"delegate options.";
} else {
std::visit(
[&base_options_proto](const auto& delegate_options) {
+3 -3
View File
@@ -21,6 +21,7 @@ limitations under the License.
#include <utility>
#include <vector>
#include "absl/log/absl_log.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/ascii.h"
@@ -30,7 +31,6 @@ limitations under the License.
#include "mediapipe/framework/api2/builder.h"
#include "mediapipe/framework/api2/port.h"
#include "mediapipe/framework/calculator.pb.h"
#include "mediapipe/framework/port/logging.h"
#include "mediapipe/tasks/cc/common.h"
#include "mediapipe/tasks/cc/core/model_asset_bundle_resources.h"
#include "mediapipe/tasks/cc/core/model_resources.h"
@@ -165,7 +165,7 @@ absl::StatusOr<const ModelResources*> ModelTaskGraph::CreateModelResources(
if (!model_resources_cache_service.IsAvailable()) {
ASSIGN_OR_RETURN(auto local_model_resource,
ModelResources::Create("", std::move(external_file)));
LOG(WARNING)
ABSL_LOG(WARNING)
<< "A local ModelResources object is created. Please consider using "
"ModelResourcesCacheService to cache the created ModelResources "
"object in the CalculatorGraph.";
@@ -215,7 +215,7 @@ ModelTaskGraph::CreateModelAssetBundleResources(
auto local_model_asset_bundle_resource,
ModelAssetBundleResources::Create("", std::move(external_file)));
if (!has_file_pointer_meta) {
LOG(WARNING)
ABSL_LOG(WARNING)
<< "A local ModelResources object is created. Please consider using "
"ModelResourcesCacheService to cache the created ModelResources "
"object in the CalculatorGraph.";
+1
View File
@@ -36,6 +36,7 @@ cc_library(
"//mediapipe/tasks/cc/core/proto:external_file_cc_proto",
"@com_google_absl//absl/cleanup",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/log:absl_log",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@zlib//:zlib_minizip",
@@ -19,6 +19,7 @@ limitations under the License.
#include "absl/cleanup/cleanup.h"
#include "absl/container/flat_hash_map.h"
#include "absl/log/absl_log.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "contrib/minizip/ioapi.h"
@@ -63,7 +64,7 @@ absl::StatusOr<ZipFileInfo> GetCurrentZipFileInfo(const unzFile& zf) {
absl::Cleanup unzipper_closer = [zf]() {
auto status = UnzipErrorToStatus(unzCloseCurrentFile(zf));
if (!status.ok()) {
LOG(ERROR) << "Failed to close the current zip file: " << status;
ABSL_LOG(ERROR) << "Failed to close the current zip file: " << status;
}
};
if (method != Z_NO_COMPRESSION) {
@@ -125,7 +126,7 @@ absl::Status ExtractFilesfromZipFile(
}
absl::Cleanup unzipper_closer = [zf]() {
if (unzClose(zf) != UNZ_OK) {
LOG(ERROR) << "Unable to close zip archive.";
ABSL_LOG(ERROR) << "Unable to close zip archive.";
}
};
// Get number of files.
@@ -213,6 +213,7 @@ cc_library(
"//mediapipe/tasks/cc/vision/face_landmarker/proto:face_landmarker_graph_options_cc_proto",
"//mediapipe/tasks/cc/vision/face_landmarker/proto:face_landmarks_detector_graph_options_cc_proto",
"//mediapipe/util:graph_builder_utils",
"@com_google_absl//absl/log:absl_log",
"@com_google_absl//absl/strings:str_format",
],
alwayslink = 1,
@@ -18,6 +18,7 @@ limitations under the License.
#include <utility>
#include <vector>
#include "absl/log/absl_log.h"
#include "absl/strings/str_format.h"
#include "mediapipe/calculators/core/clip_vector_size_calculator.pb.h"
#include "mediapipe/calculators/core/concatenate_vector_calculator.h"
@@ -165,8 +166,8 @@ absl::Status SetSubTaskBaseOptions(const ModelAssetBundleResources& resources,
->mutable_base_options()
->mutable_acceleration()
->mutable_xnnpack();
LOG(WARNING) << "Face blendshape model contains CPU only ops. Sets "
<< "FaceBlendshapesGraph acceleration to Xnnpack.";
ABSL_LOG(WARNING) << "Face blendshape model contains CPU only ops. Sets "
<< "FaceBlendshapesGraph acceleration to Xnnpack.";
}
return absl::OkStatus();
@@ -124,6 +124,7 @@ cc_library(
"//mediapipe/tasks/cc/vision/gesture_recognizer/proto:hand_gesture_recognizer_graph_options_cc_proto",
"//mediapipe/tasks/cc/vision/hand_landmarker:hand_landmarks_detector_graph",
"//mediapipe/tasks/metadata:metadata_schema_cc",
"@com_google_absl//absl/log:absl_log",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
],
@@ -161,6 +162,7 @@ cc_library(
"//mediapipe/tasks/cc/vision/hand_landmarker/proto:hand_landmarker_graph_options_cc_proto",
"//mediapipe/tasks/cc/vision/hand_landmarker/proto:hand_landmarks_detector_graph_options_cc_proto",
"//mediapipe/tasks/metadata:metadata_schema_cc",
"@com_google_absl//absl/log:absl_log",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
],
@@ -17,6 +17,7 @@ limitations under the License.
#include <type_traits>
#include <vector>
#include "absl/log/absl_log.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "mediapipe/framework/api2/builder.h"
@@ -125,8 +126,8 @@ absl::Status SetSubTaskBaseOptions(const ModelAssetBundleResources& resources,
hand_gesture_recognizer_graph_options->mutable_base_options()
->mutable_acceleration()
->mutable_xnnpack();
LOG(WARNING) << "Hand Gesture Recognizer contains CPU only ops. Sets "
<< "HandGestureRecognizerGraph acceleration to Xnnpack.";
ABSL_LOG(WARNING) << "Hand Gesture Recognizer contains CPU only ops. Sets "
<< "HandGestureRecognizerGraph acceleration to Xnnpack.";
}
hand_gesture_recognizer_graph_options->mutable_base_options()
->set_use_stream_mode(options->base_options().use_stream_mode());
@@ -17,6 +17,7 @@ limitations under the License.
#include <type_traits>
#include <vector>
#include "absl/log/absl_log.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "mediapipe/calculators/tensor/tensors_to_classification_calculator.pb.h"
@@ -246,7 +247,7 @@ class SingleHandGestureRecognizerGraph : public core::ModelTaskGraph {
options->base_options(),
custom_gesture_classifier_graph_options->mutable_base_options());
} else {
LOG(INFO) << "Custom gesture classifier is not defined.";
ABSL_LOG(INFO) << "Custom gesture classifier is not defined.";
}
return absl::OkStatus();
}
@@ -48,7 +48,7 @@ cc_library(
"//mediapipe/framework/deps:file_helpers",
"//mediapipe/framework/formats:image_frame",
"//mediapipe/framework/formats:tensor",
"@com_google_absl//absl/log",
"@com_google_absl//absl/log:absl_log",
"@com_google_absl//absl/status",
],
alwayslink = 1,
@@ -61,7 +61,7 @@ cc_library(
"//mediapipe/framework:calculator_framework",
"//mediapipe/framework/api2:node",
"//mediapipe/framework/formats:tensor",
"@com_google_absl//absl/log",
"@com_google_absl//absl/log:absl_log",
"@com_google_absl//absl/log:check",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
@@ -18,7 +18,6 @@ limitations under the License.
#include <vector>
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "mediapipe/framework/api2/node.h"
@@ -23,7 +23,7 @@ limitations under the License.
#include <utility>
#include <vector>
#include "absl/log/log.h"
#include "absl/log/absl_log.h"
#include "absl/status/status.h"
#include "mediapipe/framework/api2/node.h"
#include "mediapipe/framework/api2/port.h"
@@ -96,6 +96,7 @@ cc_library(
"//mediapipe/util:graph_builder_utils",
"//mediapipe/util:label_map_cc_proto",
"//mediapipe/util:label_map_util",
"@com_google_absl//absl/log:absl_log",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings:str_format",
@@ -5,6 +5,7 @@
#include <utility>
#include <vector>
#include "absl/log/absl_log.h"
#include "absl/status/status.h"
#include "absl/strings/str_format.h"
#include "mediapipe/framework/port/status_macros.h"
@@ -367,19 +368,20 @@ absl::Status SegmentationPostprocessorGl::GlInit(
// TODO: We could skip this entirely if no confidence masks
// are being produced AND num_classes > 1, but num_classes is only
// known at runtime, so this would take a little extra refactoring.
LOG(INFO) << "SIGMOID activation function chosen on GPU";
ABSL_LOG(INFO) << "SIGMOID activation function chosen on GPU";
activation_fn = "vec4 out_value = 1.0 / (exp(-in_value) + 1.0);";
break;
case SegmenterOptions::SOFTMAX:
if (produce_confidence_masks) {
LOG(INFO) << "SOFTMAX activation function chosen on GPU";
ABSL_LOG(INFO) << "SOFTMAX activation function chosen on GPU";
} else {
LOG(INFO) << "SOFTMAX activation function chosen on GPU, but only "
<< "category mask produced, so not applying.";
ABSL_LOG(INFO)
<< "SOFTMAX activation function chosen on GPU, but only "
<< "category mask produced, so not applying.";
}
break;
case SegmenterOptions::NONE:
LOG(INFO) << "NONE activation function chosen on GPU";
ABSL_LOG(INFO) << "NONE activation function chosen on GPU";
break;
}
@@ -490,7 +492,7 @@ SegmentationPostprocessorGl::GetSegmentationResultGpu(
int input_width, input_height;
if (!tensor.ready_on_gpu()) {
LOG(WARNING) << "Tensor wasn't ready on GPU; using slow workaround.";
ABSL_LOG(WARNING) << "Tensor wasn't ready on GPU; using slow workaround.";
(void)tensor.GetCpuReadView();
}
@@ -507,7 +509,7 @@ SegmentationPostprocessorGl::GetSegmentationResultGpu(
const auto layout = tensor.GetOpenGlTexture2dReadView().GetLayoutDimensions(
tensor.shape(), &input_width, &input_height);
if (layout != Tensor::OpenGlTexture2dView::Layout::kAligned) {
LOG(ERROR) << "Tensor layout not kAligned! Cannot handle.";
ABSL_LOG(ERROR) << "Tensor layout not kAligned! Cannot handle.";
}
#endif // TASK_SEGMENTATION_USE_GLES_31_POSTPROCESSING
@@ -853,7 +855,7 @@ SegmentationPostprocessorGl::GetSegmentationResultGpu(
});
if (!status.ok()) {
LOG(ERROR) << "Error with rendering: " << status;
ABSL_LOG(ERROR) << "Error with rendering: " << status;
}
return image_outputs;
@@ -19,6 +19,7 @@ limitations under the License.
#include <type_traits>
#include <vector>
#include "absl/log/absl_log.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_format.h"
@@ -184,7 +185,7 @@ absl::Status ConfigureTensorsToSegmentationCalculator(
}
}
if (!found_activation_in_metadata) {
LOG(WARNING)
ABSL_LOG(WARNING)
<< "No activation type is found in model metadata. Use NONE for "
"ImageSegmenterGraph.";
}
@@ -21,6 +21,7 @@ limitations under the License.
#include <utility>
#include "absl/flags/flag.h"
#include "absl/log/absl_log.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/string_view.h"
@@ -105,17 +106,17 @@ MATCHER_P2(LandmarksMatches, expected_landmarks, toleration, "") {
for (int i = 0; i < arg.size(); i++) {
for (int j = 0; j < arg[i].landmarks.size(); j++) {
if (arg[i].landmarks.size() != expected_landmarks[i].landmarks.size()) {
LOG(INFO) << "sizes not equal";
ABSL_LOG(INFO) << "sizes not equal";
return false;
}
if (std::abs(arg[i].landmarks[j].x -
expected_landmarks[i].landmarks[j].x) > toleration ||
std::abs(arg[i].landmarks[j].y -
expected_landmarks[i].landmarks[j].y) > toleration) {
LOG(INFO) << DUMP_VARS(arg[i].landmarks[j].x,
expected_landmarks[i].landmarks[j].x);
LOG(INFO) << DUMP_VARS(arg[i].landmarks[j].y,
expected_landmarks[i].landmarks[j].y);
ABSL_LOG(INFO) << DUMP_VARS(arg[i].landmarks[j].x,
expected_landmarks[i].landmarks[j].x);
ABSL_LOG(INFO) << DUMP_VARS(arg[i].landmarks[j].y,
expected_landmarks[i].landmarks[j].y);
return false;
}
}
@@ -316,7 +317,7 @@ TEST_P(VideoModeTest, Succeeds) {
MP_ASSERT_OK_AND_ASSIGN(pose_landmarker_results,
pose_landmarker->DetectForVideo(image, i));
}
LOG(INFO) << i;
ABSL_LOG(INFO) << i;
ExpectPoseLandmarkerResultsCorrect(
pose_landmarker_results, expected_results, kLandmarksOnVideoAbsMargin);
}
+1 -1
View File
@@ -28,12 +28,12 @@ cc_library_with_tflite(
visibility = ["//visibility:public"],
deps = [
"//mediapipe/framework/port:integral_types",
"//mediapipe/framework/port:logging",
"//mediapipe/framework/port:status",
"//mediapipe/tasks/cc:common",
"//mediapipe/tasks/cc/metadata:metadata_extractor",
"//mediapipe/tasks/metadata:metadata_schema_cc",
"@com_google_absl//absl/algorithm:container",
"@com_google_absl//absl/log:absl_log",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
@@ -21,13 +21,13 @@ limitations under the License.
#include <type_traits>
#include "absl/algorithm/container.h"
#include "absl/log/absl_log.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_cat.h"
#include "absl/types/optional.h"
#include "flatbuffers/flatbuffers.h"
#include "mediapipe/framework/port/integral_types.h"
#include "mediapipe/framework/port/logging.h"
#include "mediapipe/framework/port/status_macros.h"
#include "mediapipe/tasks/cc/common.h"
#include "mediapipe/tasks/cc/metadata/metadata_extractor.h"
@@ -245,8 +245,9 @@ absl::StatusOr<ImageTensorSpecs> BuildInputImageTensorSpecs(
// TODO: Investigate if there is any better solutions support
// running inference with multiple subgraphs.
if (model.subgraphs()->size() != 1) {
LOG(WARNING) << "TFLite model has more than 1 subgraphs. Use subrgaph 0 as "
"the primary subgraph for inference";
ABSL_LOG(WARNING)
<< "TFLite model has more than 1 subgraphs. Use subrgaph 0 as "
"the primary subgraph for inference";
}
const auto* primary_subgraph = (*model.subgraphs())[0];
if (primary_subgraph->inputs()->size() != 1) {