Internal change
PiperOrigin-RevId: 508533812
This commit is contained in:
parent
1f848c4d69
commit
1eb54bdaa6
|
@ -35,6 +35,21 @@ cc_library(
|
|||
],
|
||||
)
|
||||
|
||||
cc_test(
|
||||
name = "base_options_test",
|
||||
srcs = ["base_options_test.cc"],
|
||||
data = [
|
||||
"//mediapipe/tasks/testdata/core:test_models",
|
||||
],
|
||||
deps = [
|
||||
":base_options",
|
||||
":utils",
|
||||
"//mediapipe/framework/port:gtest",
|
||||
"//mediapipe/tasks/cc/core/proto:external_file_cc_proto",
|
||||
"@com_google_googletest//:gtest_main",
|
||||
],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "external_file_handler",
|
||||
srcs = ["external_file_handler.cc"],
|
||||
|
|
|
@ -33,8 +33,8 @@ proto::BaseOptions ConvertBaseOptionsToProto(BaseOptions* base_options) {
|
|||
base_options->model_asset_path);
|
||||
}
|
||||
if (base_options->model_asset_buffer) {
|
||||
base_options_proto.mutable_model_asset()->mutable_file_content()->swap(
|
||||
*base_options->model_asset_buffer.release());
|
||||
base_options_proto.mutable_model_asset()->set_file_content(
|
||||
std::move(*base_options->model_asset_buffer));
|
||||
}
|
||||
if (base_options->model_asset_descriptor_meta.fd > 0) {
|
||||
auto* file_descriptor_meta_proto = base_options_proto.mutable_model_asset()
|
||||
|
|
30
mediapipe/tasks/cc/core/base_options_test.cc
Normal file
30
mediapipe/tasks/cc/core/base_options_test.cc
Normal file
|
@ -0,0 +1,30 @@
|
|||
#include "mediapipe/tasks/cc/core/base_options.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "mediapipe/framework/port/gmock.h"
|
||||
#include "mediapipe/framework/port/gtest.h"
|
||||
#include "mediapipe/tasks/cc/core/proto/external_file.pb.h"
|
||||
#include "mediapipe/tasks/cc/core/utils.h"
|
||||
|
||||
constexpr char kTestModelBundlePath[] =
|
||||
"mediapipe/tasks/testdata/core/dummy_gesture_recognizer.task";
|
||||
|
||||
namespace mediapipe {
|
||||
namespace tasks {
|
||||
namespace core {
|
||||
namespace {
|
||||
|
||||
TEST(BaseOptionsTest, ConverBaseOptionsToProtoWithFile) {
|
||||
BaseOptions base_options;
|
||||
base_options.model_asset_buffer =
|
||||
std::make_unique<std::string>(LoadBinaryContent(kTestModelBundlePath));
|
||||
proto::BaseOptions proto = ConvertBaseOptionsToProto(&base_options);
|
||||
EXPECT_TRUE(proto.has_model_asset());
|
||||
EXPECT_TRUE(proto.model_asset().has_file_content());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace core
|
||||
} // namespace tasks
|
||||
} // namespace mediapipe
|
Loading…
Reference in New Issue
Block a user