Switch MediaPipe Tasks Python and Java base layer to use MediaPipeBuiltinOpResolver by default.
PiperOrigin-RevId: 477927852
This commit is contained in:
parent
3816951b8c
commit
af2ad1abbe
|
@ -28,10 +28,10 @@ cc_library_with_tflite(
|
|||
],
|
||||
tflite_deps = [
|
||||
"//mediapipe/tasks/cc/core:model_resources_cache",
|
||||
"@org_tensorflow//tensorflow/lite/core/shims:builtin_ops",
|
||||
],
|
||||
deps = [
|
||||
"//mediapipe/java/com/google/mediapipe/framework/jni:mediapipe_framework_jni",
|
||||
"//mediapipe/tasks/cc/core:mediapipe_builtin_op_resolver",
|
||||
] + select({
|
||||
"//conditions:default": ["//third_party/java/jdk:jni"],
|
||||
"//mediapipe:android": [],
|
||||
|
|
|
@ -34,10 +34,10 @@ cc_library_with_tflite(
|
|||
}),
|
||||
tflite_deps = [
|
||||
"//mediapipe/tasks/cc/core:model_resources_cache",
|
||||
"@org_tensorflow//tensorflow/lite/core/shims:builtin_ops",
|
||||
],
|
||||
deps = [
|
||||
"//mediapipe/java/com/google/mediapipe/framework/jni:mediapipe_framework_jni",
|
||||
"//mediapipe/tasks/cc/core:mediapipe_builtin_op_resolver",
|
||||
] + select({
|
||||
"//conditions:default": [],
|
||||
"//mediapipe:android": [],
|
||||
|
|
|
@ -17,11 +17,13 @@
|
|||
#include <utility>
|
||||
|
||||
#include "mediapipe/java/com/google/mediapipe/framework/jni/graph_service_jni.h"
|
||||
#include "mediapipe/tasks/cc/core/mediapipe_builtin_op_resolver.h"
|
||||
#include "mediapipe/tasks/cc/core/model_resources_cache.h"
|
||||
#include "tensorflow/lite/core/shims/cc/kernels/register.h"
|
||||
|
||||
namespace {
|
||||
using ::mediapipe::tasks::core::kModelResourcesCacheService;
|
||||
using ::mediapipe::tasks::core::MediaPipeBuiltinOpResolver;
|
||||
using ::mediapipe::tasks::core::ModelResourcesCache;
|
||||
using HandleType = std::shared_ptr<ModelResourcesCache>*;
|
||||
} // namespace
|
||||
|
@ -29,7 +31,7 @@ using HandleType = std::shared_ptr<ModelResourcesCache>*;
|
|||
JNIEXPORT jlong JNICALL MODEL_RESOURCES_CACHE_METHOD(
|
||||
nativeCreateModelResourcesCache)(JNIEnv* env, jobject thiz) {
|
||||
auto ptr = std::make_shared<ModelResourcesCache>(
|
||||
absl::make_unique<tflite_shims::ops::builtin::BuiltinOpResolver>());
|
||||
absl::make_unique<MediaPipeBuiltinOpResolver>());
|
||||
HandleType handle = new std::shared_ptr<ModelResourcesCache>(std::move(ptr));
|
||||
return reinterpret_cast<jlong>(handle);
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ pybind_library(
|
|||
"//mediapipe/framework/api2:builder",
|
||||
"//mediapipe/framework/port:parse_text_proto",
|
||||
"//mediapipe/python/pybind:util",
|
||||
"//mediapipe/tasks/cc/core:mediapipe_builtin_op_resolver",
|
||||
"//mediapipe/tasks/cc/core:task_runner",
|
||||
"@org_tensorflow//tensorflow/lite/core/api:op_resolver",
|
||||
"@pybind11_protobuf//pybind11_protobuf:native_proto_caster",
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include "mediapipe/framework/calculator.pb.h"
|
||||
#include "mediapipe/python/pybind/util.h"
|
||||
#include "mediapipe/tasks/cc/core/mediapipe_builtin_op_resolver.h"
|
||||
#include "mediapipe/tasks/cc/core/task_runner.h"
|
||||
#include "pybind11/stl.h"
|
||||
#include "pybind11_protobuf/native_proto_caster.h"
|
||||
|
@ -75,7 +76,7 @@ mode) or not (synchronous mode).)doc");
|
|||
}
|
||||
auto task_runner = TaskRunner::Create(
|
||||
std::move(graph_config),
|
||||
absl::make_unique<tflite::ops::builtin::BuiltinOpResolver>(),
|
||||
absl::make_unique<core::MediaPipeBuiltinOpResolver>(),
|
||||
std::move(callback));
|
||||
RaisePyErrorIfNotOk(task_runner.status());
|
||||
return std::move(*task_runner);
|
||||
|
|
Loading…
Reference in New Issue
Block a user