From b9a9da5de54e34c3dff2a3232a5674ab4fbf9a78 Mon Sep 17 00:00:00 2001 From: Jiuqiang Tang Date: Mon, 1 May 2023 10:16:20 -0700 Subject: [PATCH] Ignore fetching face stylizer model when the graph doesn't output stylized face images. PiperOrigin-RevId: 528504312 --- .../cc/vision/face_stylizer/face_stylizer_graph.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/mediapipe/tasks/cc/vision/face_stylizer/face_stylizer_graph.cc b/mediapipe/tasks/cc/vision/face_stylizer/face_stylizer_graph.cc index 6f2777fc7..7bb2e9c8d 100644 --- a/mediapipe/tasks/cc/vision/face_stylizer/face_stylizer_graph.cc +++ b/mediapipe/tasks/cc/vision/face_stylizer/face_stylizer_graph.cc @@ -130,9 +130,11 @@ absl::Status SetSubTaskBaseOptions(const ModelAssetBundleResources& resources, face_landmarks_detector_graph_options->mutable_base_options() ->set_use_stream_mode(options->base_options().use_stream_mode()); - ASSIGN_OR_RETURN(const auto face_stylizer_file, - resources.GetFile(kFaceStylizerTFLiteName)); - SetExternalFile(face_stylizer_file, face_stylizer_external_file, is_copy); + if (face_stylizer_external_file) { + ASSIGN_OR_RETURN(const auto face_stylizer_file, + resources.GetFile(kFaceStylizerTFLiteName)); + SetExternalFile(face_stylizer_file, face_stylizer_external_file, is_copy); + } return absl::OkStatus(); } @@ -234,7 +236,7 @@ class FaceStylizerGraph : public core::ModelTaskGraph { MP_RETURN_IF_ERROR(SetSubTaskBaseOptions( *model_asset_bundle_resources, sc->MutableOptions(), - face_stylizer_external_file.get(), + output_stylized ? face_stylizer_external_file.get() : nullptr, !sc->Service(::mediapipe::tasks::core::kModelResourcesCacheService) .IsAvailable())); Graph graph;