diff --git a/.bazelversion b/.bazelversion index f3b5af39e..f22d756da 100644 --- a/.bazelversion +++ b/.bazelversion @@ -1 +1 @@ -6.1.1 +6.5.0 diff --git a/README.md b/README.md index e928bac86..2ab26644b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # MediaPipe Unity Plugin -This is a Unity (>= 2021.3) [Native Plugin](https://docs.unity3d.com/Manual/NativePlugins.html) to use [MediaPipe](https://github.com/google/mediapipe) (0.10.14). +This is a Unity (>= 2021.3) [Native Plugin](https://docs.unity3d.com/Manual/NativePlugins.html) to use [MediaPipe](https://github.com/google/mediapipe) (0.10.20). The goal of this project is to port the MediaPipe API (C++) _one by one_ to C# so that it can be called from Unity.\ This approach may sacrifice performance when you need to call multiple APIs in a loop, but it gives you the flexibility to use MediaPipe instead. diff --git a/WORKSPACE b/WORKSPACE index cd1d47461..754790555 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -2,6 +2,12 @@ workspace(name = "mediapipe_api") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +# Protobuf expects an //external:python_headers target +bind( + name = "python_headers", + actual = "@local_config_python//:python_headers", +) + http_archive( name = "bazel_skylib", sha256 = "74d544d96f4a5bb630d465ca8bbcfe231e3594e5aae57e1edbf17a6eb3ca2506", @@ -10,9 +16,13 @@ http_archive( "https://github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz", ], ) + load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") + bazel_skylib_workspace() + load("@bazel_skylib//lib:versions.bzl", "versions") + versions.check(minimum_bazel_version = "6.1.1") # mediapipe @@ -28,247 +38,322 @@ http_archive( "@//third_party:mediapipe_extension.diff", "@//third_party:mediapipe_workaround.diff", ], - sha256 = "9d46fa5363f5c4e11c3d1faec71b0746f15c5aab7b5460d0e5655d7af93c6957", - strip_prefix = "mediapipe-0.10.14", - urls = ["https://github.com/google/mediapipe/archive/v0.10.14.tar.gz"], + sha256 = "ae0abfc544a37a46f46e20f73010ddbe43cf12b0853701b763d3df1ab986dd36", + strip_prefix = "mediapipe-0.10.20", + urls = ["https://github.com/google/mediapipe/archive/v0.10.20.tar.gz"], ) # ABSL on 2023-10-18 http_archive( name = "com_google_absl", - urls = [ - "https://github.com/abseil/abseil-cpp/archive//9687a8ea750bfcddf790372093245a1d041b21a3.tar.gz", + patch_args = [ + "-p1", ], patches = [ "@mediapipe//third_party:com_google_absl_windows_patch.diff", ], - patch_args = [ - "-p1", - ], - strip_prefix = "abseil-cpp-9687a8ea750bfcddf790372093245a1d041b21a3", sha256 = "f841f78243f179326f2a80b719f2887c38fe226d288ecdc46e2aa091e6aa43bc", + strip_prefix = "abseil-cpp-9687a8ea750bfcddf790372093245a1d041b21a3", + urls = ["https://github.com/abseil/abseil-cpp/archive//9687a8ea750bfcddf790372093245a1d041b21a3.tar.gz"], ) -http_archive( - name = "rules_cc", - strip_prefix = "rules_cc-2f8c04c04462ab83c545ab14c0da68c3b4c96191", - # The commit can be updated if the build passes. Last updated 6/23/22. - urls = ["https://github.com/bazelbuild/rules_cc/archive/2f8c04c04462ab83c545ab14c0da68c3b4c96191.zip"], -) +load("//third_party:android_configure.bzl", "android_configure") -# cf. https://github.com/bazelbuild/rules_foreign_cc/issues/1051 -http_archive( - name = "rules_foreign_cc", - sha256 = "6041f1374ff32ba711564374ad8e007aef77f71561a7ce784123b9b4b88614fc", - strip_prefix = "rules_foreign_cc-0.8.0", - url = "https://github.com/bazelbuild/rules_foreign_cc/archive/0.8.0.tar.gz", -) +android_configure(name = "local_config_android") -load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies") +load("@local_config_android//:android_configure.bzl", "android_workspace") -rules_foreign_cc_dependencies() +android_workspace() http_archive( - name = "com_google_protobuf", - sha256 = "87407cd28e7a9c95d9f61a098a53cf031109d451a7763e7dd1253abf8b4df422", - strip_prefix = "protobuf-3.19.1", - urls = ["https://github.com/protocolbuffers/protobuf/archive/v3.19.1.tar.gz"], - patches = [ - "@mediapipe//third_party:com_google_protobuf_fixes.diff" - ], + name = "build_bazel_rules_apple", patch_args = [ "-p1", ], -) - -http_archive( - name = "cpuinfo", - sha256 = "a615cac78fad03952cc3e1fd231ce789a8df6e81a5957b64350cb8200364b385", - strip_prefix = "cpuinfo-d6860c477c99f1fce9e28eb206891af3c0e1a1d7", - urls = [ - "https://github.com/pytorch/cpuinfo/archive/d6860c477c99f1fce9e28eb206891af3c0e1a1d7.zip" + patches = [ + # Bypass checking ios unit test runner when building MP ios applications. + "@mediapipe//third_party:build_bazel_rules_apple_bypass_test_runner_check.diff", + # https://github.com/bazelbuild/rules_apple/commit/95b1305255dc29874cacc3dc7fdc017f16d8dbe8 + "@mediapipe//third_party:build_bazel_rules_apple_multi_arch_split_with_new_transition.diff", ], + sha256 = "3e2c7ae0ddd181c4053b6491dad1d01ae29011bc322ca87eea45957c76d3a0c3", + url = "https://github.com/bazelbuild/rules_apple/releases/download/2.1.0/rules_apple.2.1.0.tar.gz", ) -# XNNPACK on 2024-03-27. http_archive( - name = "XNNPACK", - # `curl -L | shasum -a 256` - sha256 = "179a680ef85deb5380b850f2551b214e00835c232f5b197dedf7c011a6adf5a6", - strip_prefix = "XNNPACK-2fe25b859581a34e77b48b06c640ac1a5a58612e", - url = "https://github.com/google/XNNPACK/archive/2fe25b859581a34e77b48b06c640ac1a5a58612e.zip", + name = "com_google_protobuf", + patch_args = [ + "-p1", + ], + patches = [ + "@mediapipe//third_party:com_google_protobuf_fixes.diff", + ], + sha256 = "87407cd28e7a9c95d9f61a098a53cf031109d451a7763e7dd1253abf8b4df422", + strip_prefix = "protobuf-3.19.1", + urls = ["https://github.com/protocolbuffers/protobuf/archive/v3.19.1.tar.gz"], ) -# TODO: This is an are indirect depedency. We should factor it out. +# GoogleTest/GoogleMock framework. Used by most unit-tests. +# Last updated 2021-07-02. http_archive( - name = "pthreadpool", - sha256 = "a4cf06de57bfdf8d7b537c61f1c3071bce74e57524fe053e0bbd2332feca7f95", - strip_prefix = "pthreadpool-4fe0e1e183925bf8cfa6aae24237e724a96479b8", - urls = ["https://github.com/Maratyszcza/pthreadpool/archive/4fe0e1e183925bf8cfa6aae24237e724a96479b8.zip"], + name = "com_google_googletest", + sha256 = "de682ea824bfffba05b4e33b67431c247397d6175962534305136aa06f92e049", + strip_prefix = "googletest-4ec4cd23f486bf70efcc5d2caa40f24368f752e3", + urls = ["https://github.com/google/googletest/archive/4ec4cd23f486bf70efcc5d2caa40f24368f752e3.zip"], ) -load("//third_party:android_configure.bzl", "android_configure") - -android_configure(name = "local_config_android") - -load("@local_config_android//:android_configure.bzl", "android_workspace") - -android_workspace() - # Load Zlib before initializing TensorFlow and the iOS build rules to guarantee # that the target @zlib//:mini_zlib is available http_archive( name = "zlib", build_file = "@mediapipe//third_party:zlib.BUILD", + patch_args = [ + "-p1", + ], + patches = [ + "@mediapipe//third_party:zlib.diff", + ], sha256 = "b3a24de97a8fdbc835b9833169501030b8977031bcb54b3b3ac13740f846ab30", strip_prefix = "zlib-1.2.13", url = "http://zlib.net/fossils/zlib-1.2.13.tar.gz", - patches = [ - "@mediapipe//third_party:zlib.diff", +) + +# gflags needed by glog +http_archive( + name = "com_github_gflags_gflags", + sha256 = "19713a36c9f32b33df59d1c79b4958434cb005b5b47dc5400a7a4b078111d9b5", + strip_prefix = "gflags-2.2.2", + url = "https://github.com/gflags/gflags/archive/v2.2.2.zip", +) + +# 2020-08-21 +http_archive( + name = "com_github_glog_glog", + sha256 = "8a83bf982f37bb70825df71a9709fa90ea9f4447fb3c099e1d720a439d88bad6", + strip_prefix = "glog-0.6.0", + urls = [ + "https://github.com/google/glog/archive/v0.6.0.tar.gz", ], +) + +http_archive( + name = "com_github_glog_glog_no_gflags", + build_file = "@mediapipe//third_party:glog_no_gflags.BUILD", patch_args = [ "-p1", ], + patches = [ + "@mediapipe//third_party:com_github_glog_glog.diff", + ], + sha256 = "8a83bf982f37bb70825df71a9709fa90ea9f4447fb3c099e1d720a439d88bad6", + strip_prefix = "glog-0.6.0", + urls = [ + "https://github.com/google/glog/archive/v0.6.0.tar.gz", + ], ) -# iOS basic build deps. +# 2023-06-05 +# This version of Glog is required for Windows support, but currently causes +# crashes on some Android devices. http_archive( - name = "build_bazel_apple_support", + name = "com_github_glog_glog_windows", patch_args = [ "-p1", ], patches = [ - "@//third_party:build_bazel_apple_support_transitions.diff" + "@mediapipe//third_party:com_github_glog_glog.diff", + "@mediapipe//third_party:com_github_glog_glog_windows_patch.diff", ], - sha256 = "9f7bb62c3ae889e0eae8c18458fd8764e2e537687d9a1d85885d6af980e4fc31", + sha256 = "170d08f80210b82d95563f4723a15095eff1aad1863000e8eeb569c96a98fefb", + strip_prefix = "glog-3a0d4d22c5ae0b9a2216988411cfa6bf860cc372", urls = [ - "https://github.com/bazelbuild/apple_support/releases/download/1.6.0/apple_support.1.6.0.tar.gz", + "https://github.com/google/glog/archive/3a0d4d22c5ae0b9a2216988411cfa6bf860cc372.zip", ], ) -# iOS basic build deps. +# Needed by TensorFlow http_archive( - name = "build_bazel_rules_apple", - sha256 = "3e2c7ae0ddd181c4053b6491dad1d01ae29011bc322ca87eea45957c76d3a0c3", - url = "https://github.com/bazelbuild/rules_apple/releases/download/2.1.0/rules_apple.2.1.0.tar.gz", - patches = [ - # Bypass checking ios unit test runner when building MP ios applications. - "@mediapipe//third_party:build_bazel_rules_apple_bypass_test_runner_check.diff", - "@//third_party:build_bazel_rules_apple_validation.diff", + name = "io_bazel_rules_closure", + sha256 = "e0a111000aeed2051f29fcc7a3f83be3ad8c6c93c186e64beb1ad313f0c7f9f9", + strip_prefix = "rules_closure-cf1e44edb908e9616030cc83d085989b8e6cd6df", + urls = [ + "http://mirror.tensorflow.org/github.com/bazelbuild/rules_closure/archive/cf1e44edb908e9616030cc83d085989b8e6cd6df.tar.gz", + "https://github.com/bazelbuild/rules_closure/archive/cf1e44edb908e9616030cc83d085989b8e6cd6df.tar.gz", # 2019-04-04 ], +) + +# XNNPACK on 2024-11-18 +http_archive( + name = "XNNPACK", + # `curl -L | shasum -a 256` + sha256 = "af30fe2b301330a7e19cd422acf22991de3c1f5d91dda58e9ee67544d608fa51", + strip_prefix = "XNNPACK-dc1549a7141c7a9496ae160bb27b8700f0f6e1f1", + url = "https://github.com/google/XNNPACK/archive/dc1549a7141c7a9496ae160bb27b8700f0f6e1f1.zip", +) + +# KleidiAI is needed to get the best possible performance out of XNNPack +http_archive( + name = "KleidiAI", + sha256 = "ad37707084a6d4ff41be10cbe8540c75bea057ba79d0de6c367c1bfac6ba0852", + strip_prefix = "kleidiai-40a926833857fb64786e02f97703e42b1537cb57", + urls = [ + "https://gitlab.arm.com/kleidi/kleidiai/-/archive/40a926833857fb64786e02f97703e42b1537cb57/kleidiai-40a926833857fb64786e02f97703e42b1537cb57.zip" + ], +) + +http_archive( + name = "cpuinfo", + sha256 = "e2bd8049d29dfbed675a0bc7c01947f8b8bd3f17f706b827d3f6c1e5c64dd8c3", + strip_prefix = "cpuinfo-8df44962d437a0477f07ba6b8843d0b6a48646a4", + urls = [ + "https://github.com/pytorch/cpuinfo/archive/8df44962d437a0477f07ba6b8843d0b6a48646a4.zip", + ], +) + +# TF on 2024-09-24 +_TENSORFLOW_GIT_COMMIT = "5329ec8dd396487982ef3e743f98c0195af39a6b" + +# curl -L https://github.com/tensorflow/tensorflow/archive/.tar.gz | shasum -a 256 +_TENSORFLOW_SHA256 = "eb1f8d740d59ea3dee91108ab1fc19d91c4e9ac2fd17d9ab86d865c3c43d81c9" + +http_archive( + name = "org_tensorflow", patch_args = [ "-p1", ], + patches = [ + "@mediapipe//third_party:org_tensorflow_c_api_experimental.diff", + # Diff is generated with a script, don't update it manually. + "@mediapipe//third_party:org_tensorflow_custom_ops.diff", + # Works around Bazel issue with objc_library. + # See https://github.com/bazelbuild/bazel/issues/19912 + "@mediapipe//third_party:org_tensorflow_objc_build_fixes.diff", + ], + sha256 = _TENSORFLOW_SHA256, + strip_prefix = "tensorflow-%s" % _TENSORFLOW_GIT_COMMIT, + urls = [ + "https://github.com/tensorflow/tensorflow/archive/%s.tar.gz" % _TENSORFLOW_GIT_COMMIT, + ], +) + +load("@org_tensorflow//tensorflow:workspace3.bzl", "tf_workspace3") + +tf_workspace3() + +# Initialize hermetic Python +load("@org_tensorflow//third_party/xla/third_party/py:python_init_rules.bzl", "python_init_rules") + +python_init_rules() + +load("@org_tensorflow//third_party/xla/third_party/py:python_init_repositories.bzl", "python_init_repositories") + +python_init_repositories( + default_python_version = "system", + local_wheel_dist_folder = "dist", + local_wheel_inclusion_list = ["mediapipe*"], + local_wheel_workspaces = ["@mediapipe//:WORKSPACE"], + requirements = { + "3.9": "@mediapipe//:requirements_lock.txt", + "3.10": "@mediapipe//:requirements_lock_3_10.txt", + "3.11": "@mediapipe//:requirements_lock_3_11.txt", + "3.12": "@mediapipe//:requirements_lock_3_12.txt", + }, +) + +load("@org_tensorflow//third_party/xla/third_party/py:python_init_toolchains.bzl", "python_init_toolchains") + +python_init_toolchains() + +load("@org_tensorflow//third_party/xla/third_party/py:python_init_pip.bzl", "python_init_pip") + +python_init_pip() + +load("@pypi//:requirements.bzl", "install_deps") + +install_deps() +# End hermetic Python initialization + +load("@org_tensorflow//tensorflow:workspace2.bzl", "tf_workspace2") + +tf_workspace2() + +http_archive( + name = "rules_foreign_cc", + sha256 = "a2e6fb56e649c1ee79703e99aa0c9d13c6cc53c8d7a0cbb8797ab2888bbc99a3", + strip_prefix = "rules_foreign_cc-0.12.0", + url = "https://github.com/bazelbuild/rules_foreign_cc/releases/download/0.12.0/rules_foreign_cc-0.12.0.tar.gz", +) + +load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies") + +rules_foreign_cc_dependencies() + +load("@bazel_features//:deps.bzl", "bazel_features_deps") + +bazel_features_deps() + +# TODO: This is an are indirect dependency. We should factor it out. +http_archive( + name = "pthreadpool", + sha256 = "a4cf06de57bfdf8d7b537c61f1c3071bce74e57524fe053e0bbd2332feca7f95", + strip_prefix = "pthreadpool-4fe0e1e183925bf8cfa6aae24237e724a96479b8", + urls = ["https://github.com/Maratyszcza/pthreadpool/archive/4fe0e1e183925bf8cfa6aae24237e724a96479b8.zip"], ) load( "@build_bazel_rules_apple//apple:repositories.bzl", "apple_rules_dependencies", ) + apple_rules_dependencies() load( "@build_bazel_rules_swift//swift:repositories.bzl", "swift_rules_dependencies", ) + swift_rules_dependencies() load( "@build_bazel_rules_swift//swift:extras.bzl", "swift_rules_extra_dependencies", ) + swift_rules_extra_dependencies() load( "@build_bazel_apple_support//lib:repositories.bzl", "apple_support_dependencies", ) + apple_support_dependencies() -# GoogleTest/GoogleMock framework. Used by most unit-tests. -# Last updated 2021-07-02. -http_archive( - name = "com_google_googletest", - urls = ["https://github.com/google/googletest/archive/4ec4cd23f486bf70efcc5d2caa40f24368f752e3.zip"], - strip_prefix = "googletest-4ec4cd23f486bf70efcc5d2caa40f24368f752e3", - sha256 = "de682ea824bfffba05b4e33b67431c247397d6175962534305136aa06f92e049", -) +# This is used to select all contents of the archives for CMake-based packages to give CMake access to them. +all_content = """filegroup(name = "all", srcs = glob(["**"]), visibility = ["//visibility:public"])""" # Google Benchmark library v1.6.1 released on 2022-01-10. http_archive( name = "com_google_benchmark", - urls = ["https://github.com/google/benchmark/archive/refs/tags/v1.6.1.tar.gz"], - strip_prefix = "benchmark-1.6.1", - sha256 = "6132883bc8c9b0df5375b16ab520fac1a85dc9e4cf5be59480448ece74b278d4", build_file = "@mediapipe//third_party:benchmark.BUILD", -) - -# gflags needed by glog -http_archive( - name = "com_github_gflags_gflags", - strip_prefix = "gflags-2.2.2", - sha256 = "19713a36c9f32b33df59d1c79b4958434cb005b5b47dc5400a7a4b078111d9b5", - url = "https://github.com/gflags/gflags/archive/v2.2.2.zip", -) - -# 2020-08-21 -http_archive( - name = "com_github_glog_glog", - strip_prefix = "glog-0.6.0", - sha256 = "8a83bf982f37bb70825df71a9709fa90ea9f4447fb3c099e1d720a439d88bad6", - urls = [ - "https://github.com/google/glog/archive/v0.6.0.tar.gz", - ], -) -http_archive( - name = "com_github_glog_glog_no_gflags", - strip_prefix = "glog-0.6.0", - sha256 = "8a83bf982f37bb70825df71a9709fa90ea9f4447fb3c099e1d720a439d88bad6", - build_file = "@mediapipe//third_party:glog_no_gflags.BUILD", - urls = [ - "https://github.com/google/glog/archive/v0.6.0.tar.gz", - ], - patches = [ - "@mediapipe//third_party:com_github_glog_glog.diff", - ], - patch_args = [ - "-p1", - ], -) - -# 2023-06-05 -# This version of Glog is required for Windows support, but currently causes -# crashes on some Android devices. -http_archive( - name = "com_github_glog_glog_windows", - strip_prefix = "glog-3a0d4d22c5ae0b9a2216988411cfa6bf860cc372", - sha256 = "170d08f80210b82d95563f4723a15095eff1aad1863000e8eeb569c96a98fefb", - urls = [ - "https://github.com/google/glog/archive/3a0d4d22c5ae0b9a2216988411cfa6bf860cc372.zip", - ], - patches = [ - "@mediapipe//third_party:com_github_glog_glog.diff", - "@mediapipe//third_party:com_github_glog_glog_windows_patch.diff", - ], - patch_args = [ - "-p1", - ], + sha256 = "6132883bc8c9b0df5375b16ab520fac1a85dc9e4cf5be59480448ece74b278d4", + strip_prefix = "benchmark-1.6.1", + urls = ["https://github.com/google/benchmark/archive/refs/tags/v1.6.1.tar.gz"], ) # easyexif http_archive( name = "easyexif", - url = "https://github.com/mayanklahiri/easyexif/archive/master.zip", - strip_prefix = "easyexif-master", build_file = "@mediapipe//third_party:easyexif.BUILD", + strip_prefix = "easyexif-master", + url = "https://github.com/mayanklahiri/easyexif/archive/master.zip", ) # libyuv http_archive( name = "libyuv", + build_file = "@mediapipe//third_party:libyuv.BUILD", # Error: operand type mismatch for `vbroadcastss' caused by commit 8a13626e42f7fdcf3a6acbb0316760ee54cda7d8. urls = ["https://chromium.googlesource.com/libyuv/libyuv/+archive/2525698acba9bf9b701ba6b4d9584291a1f62257.tar.gz"], - build_file = "@mediapipe//third_party:libyuv.BUILD", ) # Note: protobuf-javalite is no longer released as a separate download, it's included in the main Java download. @@ -281,38 +366,43 @@ http_archive( ) load("@mediapipe//third_party/flatbuffers:workspace.bzl", flatbuffers = "repo") + flatbuffers() http_archive( name = "com_google_audio_tools", - strip_prefix = "multichannel-audio-tools-1f6b1319f13282eda6ff1317be13de67f4723860", - urls = ["https://github.com/google/multichannel-audio-tools/archive/1f6b1319f13282eda6ff1317be13de67f4723860.zip"], - sha256 = "fe346e1aee4f5069c4cbccb88706a9a2b2b4cf98aeb91ec1319be77e07dd7435", - repo_mapping = {"@com_github_glog_glog" : "@com_github_glog_glog_no_gflags"}, + patch_args = ["-p1"], # TODO: Fix this in AudioTools directly patches = ["@mediapipe//third_party:com_google_audio_tools_fixes.diff"], - patch_args = ["-p1"] + repo_mapping = {"@com_github_glog_glog": "@com_github_glog_glog_no_gflags"}, + sha256 = "fe346e1aee4f5069c4cbccb88706a9a2b2b4cf98aeb91ec1319be77e07dd7435", + strip_prefix = "multichannel-audio-tools-1f6b1319f13282eda6ff1317be13de67f4723860", + urls = ["https://github.com/google/multichannel-audio-tools/archive/1f6b1319f13282eda6ff1317be13de67f4723860.zip"], ) http_archive( name = "pffft", + build_file = "@mediapipe//third_party:pffft.BUILD", strip_prefix = "jpommier-pffft-7c3b5a7dc510", urls = ["https://bitbucket.org/jpommier/pffft/get/7c3b5a7dc510.zip"], - build_file = "@mediapipe//third_party:pffft.BUILD", ) # Sentencepiece http_archive( name = "com_google_sentencepiece", - strip_prefix = "sentencepiece-0.1.96", add_prefix = "sentencepiece", + build_file = "@mediapipe//third_party:sentencepiece.BUILD", + patch_args = [ + "-d", + "sentencepiece", + "-p1", + ], + patches = ["@mediapipe//third_party:com_google_sentencepiece.diff"], sha256 = "8409b0126ebd62b256c685d5757150cf7fcb2b92a2f2b98efb3f38fc36719754", + strip_prefix = "sentencepiece-0.1.96", urls = [ - "https://github.com/google/sentencepiece/archive/refs/tags/v0.1.96.zip" + "https://github.com/google/sentencepiece/archive/refs/tags/v0.1.96.zip", ], - build_file = "@mediapipe//third_party:sentencepiece.BUILD", - patches = ["@mediapipe//third_party:com_google_sentencepiece.diff"], - patch_args = ["-d", "sentencepiece", "-p1"], ) http_archive( @@ -327,17 +417,17 @@ http_archive( http_archive( name = "org_tensorflow_text", - sha256 = "f64647276f7288d1b1fe4c89581d51404d0ce4ae97f2bcc4c19bd667549adca8", - strip_prefix = "text-2.2.0", - urls = [ - "https://github.com/tensorflow/text/archive/v2.2.0.zip", - ], + patch_args = ["-p1"], patches = [ "@mediapipe//third_party:tensorflow_text_remove_tf_deps.diff", "@mediapipe//third_party:tensorflow_text_a0f49e63.diff", ], - patch_args = ["-p1"], repo_mapping = {"@com_google_re2": "@com_googlesource_code_re2"}, + sha256 = "f64647276f7288d1b1fe4c89581d51404d0ce4ae97f2bcc4c19bd667549adca8", + strip_prefix = "text-2.2.0", + urls = [ + "https://github.com/tensorflow/text/archive/v2.2.0.zip", + ], ) http_archive( @@ -352,15 +442,15 @@ http_archive( # Point to the commit that deprecates the usage of Eigen::MappedSparseMatrix. http_archive( name = "ceres_solver", - url = "https://github.com/ceres-solver/ceres-solver/archive/123fba61cf2611a3c8bddc9d91416db26b10b558.zip", - patches = [ - "@mediapipe//third_party:ceres_solver_compatibility_fixes.diff", - ], patch_args = [ "-p1", ], + patches = [ + "@mediapipe//third_party:ceres_solver_compatibility_fixes.diff", + ], + sha256 = "8b7b16ceb363420e0fd499576daf73fa338adb0b1449f58bea7862766baa1ac7", strip_prefix = "ceres-solver-123fba61cf2611a3c8bddc9d91416db26b10b558", - sha256 = "8b7b16ceb363420e0fd499576daf73fa338adb0b1449f58bea7862766baa1ac7" + url = "https://github.com/ceres-solver/ceres-solver/archive/123fba61cf2611a3c8bddc9d91416db26b10b558.zip", ) http_archive( @@ -410,10 +500,9 @@ new_local_repository( http_archive( name = "android_opencv", build_file = "@mediapipe//third_party:opencv_android.BUILD", - sha256 = "cdb0e190c3734edd4052a3535d9e4310af912a9f70a421b1621711942a1028d5", strip_prefix = "OpenCV-android-sdk", type = "zip", - url = "https://github.com/opencv/opencv/releases/download/3.4.3/opencv-3.4.3-android-sdk.zip", + url = "https://github.com/opencv/opencv/releases/download/4.10.0/opencv-4.10.0-android-sdk.zip", ) # After OpenCV 3.2.0, the pre-compiled opencv2.framework has google protobuf symbols, which will @@ -422,8 +511,8 @@ http_archive( # '-DBUILD_PROTOBUF=OFF -DBUILD_opencv_dnn=OFF'. http_archive( name = "ios_opencv", - sha256 = "7dd536d06f59e6e1156b546bd581523d8df92ce83440002885ec5abc06558de2", build_file = "@mediapipe//third_party:opencv_ios.BUILD", + sha256 = "7dd536d06f59e6e1156b546bd581523d8df92ce83440002885ec5abc06558de2", type = "zip", url = "https://github.com/opencv/opencv/releases/download/3.2.0/opencv-3.2.0-ios-framework.zip", ) @@ -438,81 +527,67 @@ http_archive( # Task libraries are built. http_archive( name = "ios_opencv_source", - sha256 = "a61e7a4618d353140c857f25843f39b2abe5f451b018aab1604ef0bc34cd23d5", build_file = "@mediapipe//third_party:opencv_ios_source.BUILD", + sha256 = "a61e7a4618d353140c857f25843f39b2abe5f451b018aab1604ef0bc34cd23d5", type = "zip", url = "https://github.com/opencv/opencv/archive/refs/tags/4.5.3.zip", ) http_archive( name = "stblib", - strip_prefix = "stb-b42009b3b9d4ca35bc703f5310eedc74f584be58", - sha256 = "13a99ad430e930907f5611325ec384168a958bf7610e63e60e2fd8e7b7379610", - urls = ["https://github.com/nothings/stb/archive/b42009b3b9d4ca35bc703f5310eedc74f584be58.tar.gz"], build_file = "@mediapipe//third_party:stblib.BUILD", - patches = [ - "@mediapipe//third_party:stb_image_impl.diff" - ], patch_args = [ "-p1", ], + patches = [ + "@mediapipe//third_party:stb_image_impl.diff", + ], + sha256 = "13a99ad430e930907f5611325ec384168a958bf7610e63e60e2fd8e7b7379610", + strip_prefix = "stb-b42009b3b9d4ca35bc703f5310eedc74f584be58", + urls = ["https://github.com/nothings/stb/archive/b42009b3b9d4ca35bc703f5310eedc74f584be58.tar.gz"], ) -# More iOS deps. - http_archive( name = "google_toolbox_for_mac", - url = "https://github.com/google/google-toolbox-for-mac/archive/v2.2.1.zip", + build_file = "@mediapipe//third_party:google_toolbox_for_mac.BUILD", sha256 = "e3ac053813c989a88703556df4dc4466e424e30d32108433ed6beaec76ba4fdc", strip_prefix = "google-toolbox-for-mac-2.2.1", - build_file = "@mediapipe//third_party:google_toolbox_for_mac.BUILD", + url = "https://github.com/google/google-toolbox-for-mac/archive/v2.2.1.zip", ) -# Needed by TensorFlow -http_archive( - name = "io_bazel_rules_closure", - sha256 = "e0a111000aeed2051f29fcc7a3f83be3ad8c6c93c186e64beb1ad313f0c7f9f9", - strip_prefix = "rules_closure-cf1e44edb908e9616030cc83d085989b8e6cd6df", - urls = [ - "http://mirror.tensorflow.org/github.com/bazelbuild/rules_closure/archive/cf1e44edb908e9616030cc83d085989b8e6cd6df.tar.gz", - "https://github.com/bazelbuild/rules_closure/archive/cf1e44edb908e9616030cc83d085989b8e6cd6df.tar.gz", # 2019-04-04 - ], +# Hermetic CUDA +load( + "@org_tensorflow//third_party/gpus/cuda/hermetic:cuda_json_init_repository.bzl", + "cuda_json_init_repository", ) -# TensorFlow repo should always go after the other external dependencies. -# TF on 2024-05-09. -_TENSORFLOW_GIT_COMMIT = "8038e44ea38bb889095afaaf6ad05e94adaed8d2" -# curl -L https://github.com/tensorflow/tensorflow/archive/8038e44ea38bb889095afaaf6ad05e94adaed8d2.tar.gz | shasum -a 256 -_TENSORFLOW_SHA256 = "a00c1503a879eb21c349941bbee54aef8d557d7d2ab770e76fb26668d75aa6e0" -http_archive( - name = "org_tensorflow", - urls = [ - "https://github.com/tensorflow/tensorflow/archive/%s.tar.gz" % _TENSORFLOW_GIT_COMMIT, - ], - patches = [ - "@mediapipe//third_party:org_tensorflow_system_python.diff", - # Diff is generated with a script, don't update it manually. - "@mediapipe//third_party:org_tensorflow_custom_ops.diff", - # Works around Bazel issue with objc_library. - # See https://github.com/bazelbuild/bazel/issues/19912 - "@mediapipe//third_party:org_tensorflow_objc_build_fixes.diff", - # Restores scores for text pipelines, which return different results - # with subgraph reshaping - "@mediapipe//third_party:org_tensorflow_disable_subgraph_reshaping.diff", - # See https://github.com/tensorflow/tensorflow/issues/69036 - "@//third_party:org_tensorflow_windows_workaround.diff", - ], - patch_args = [ - "-p1", - ], - strip_prefix = "tensorflow-%s" % _TENSORFLOW_GIT_COMMIT, - sha256 = _TENSORFLOW_SHA256, +cuda_json_init_repository() + +load( + "@cuda_redist_json//:distributions.bzl", + "CUDA_REDISTRIBUTIONS", + "CUDNN_REDISTRIBUTIONS", +) +load( + "@org_tensorflow//third_party/gpus/cuda/hermetic:cuda_redist_init_repositories.bzl", + "cuda_redist_init_repositories", + "cudnn_redist_init_repository", ) -load("@org_tensorflow//tensorflow:workspace3.bzl", "tf_workspace3") -tf_workspace3() -load("@org_tensorflow//tensorflow:workspace2.bzl", "tf_workspace2") -tf_workspace2() +cuda_redist_init_repositories( + cuda_redistributions = CUDA_REDISTRIBUTIONS, +) + +cudnn_redist_init_repository( + cudnn_redistributions = CUDNN_REDISTRIBUTIONS, +) + +load( + "@org_tensorflow//third_party/gpus/cuda/hermetic:cuda_configure.bzl", + "cuda_configure", +) + +cuda_configure(name = "local_config_cuda") # Edge TPU http_archive( @@ -523,10 +598,13 @@ http_archive( "https://github.com/google-coral/libedgetpu/archive/3164995622300286ef2bb14d7fdc2792dae045b7.tar.gz", ], ) + load("@libedgetpu//:workspace.bzl", "libedgetpu_dependencies") + libedgetpu_dependencies() load("@coral_crosstool//:configure.bzl", "cc_crosstool") + cc_crosstool(name = "crosstool") # Node dependencies @@ -537,11 +615,14 @@ http_archive( ) load("@build_bazel_rules_nodejs//:repositories.bzl", "build_bazel_rules_nodejs_dependencies") + build_bazel_rules_nodejs_dependencies() # fetches nodejs, npm, and yarn load("@build_bazel_rules_nodejs//:index.bzl", "node_repositories", "yarn_install") + node_repositories() + yarn_install( name = "npm", package_json = "@mediapipe//:package.json", @@ -563,18 +644,24 @@ http_archive( urls = ["https://github.com/protocolbuffers/protobuf-javascript/archive/refs/tags/v3.21.2.tar.gz"], ) -load("@rules_proto_grpc//:repositories.bzl", "rules_proto_grpc_toolchains", "rules_proto_grpc_repos") +load("@rules_proto_grpc//:repositories.bzl", "rules_proto_grpc_repos", "rules_proto_grpc_toolchains") + rules_proto_grpc_toolchains() + rules_proto_grpc_repos() load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains") + rules_proto_dependencies() + rules_proto_toolchains() load("@mediapipe//third_party:external_files.bzl", "external_files") + external_files() load("@mediapipe//third_party:wasm_files.bzl", "wasm_files") + wasm_files() # Halide @@ -587,39 +674,53 @@ new_local_repository( http_archive( name = "linux_halide", + build_file = "@mediapipe//third_party:halide.BUILD", sha256 = "d290fadf3f358c94aacf43c883de6468bb98883e26116920afd491ec0e440cd2", strip_prefix = "Halide-15.0.1-x86-64-linux", urls = ["https://github.com/halide/Halide/releases/download/v15.0.1/Halide-15.0.1-x86-64-linux-4c63f1befa1063184c5982b11b6a2cc17d4e5815.tar.gz"], - build_file = "@mediapipe//third_party:halide.BUILD", ) http_archive( name = "macos_x86_64_halide", + build_file = "@mediapipe//third_party:halide.BUILD", sha256 = "48ff073ac1aee5c4aca941a4f043cac64b38ba236cdca12567e09d803594a61c", strip_prefix = "Halide-15.0.1-x86-64-osx", urls = ["https://github.com/halide/Halide/releases/download/v15.0.1/Halide-15.0.1-x86-64-osx-4c63f1befa1063184c5982b11b6a2cc17d4e5815.tar.gz"], - build_file = "@mediapipe//third_party:halide.BUILD", ) http_archive( name = "macos_arm_64_halide", + build_file = "@mediapipe//third_party:halide.BUILD", sha256 = "db5d20d75fa7463490fcbc79c89f0abec9c23991f787c8e3e831fff411d5395c", strip_prefix = "Halide-15.0.1-arm-64-osx", urls = ["https://github.com/halide/Halide/releases/download/v15.0.1/Halide-15.0.1-arm-64-osx-4c63f1befa1063184c5982b11b6a2cc17d4e5815.tar.gz"], - build_file = "@mediapipe//third_party:halide.BUILD", ) http_archive( name = "windows_halide", + build_file = "@mediapipe//third_party:halide.BUILD", sha256 = "61fd049bd75ee918ac6c30d0693aac6048f63f8d1fc4db31001573e58eae8dae", strip_prefix = "Halide-15.0.1-x86-64-windows", urls = ["https://github.com/halide/Halide/releases/download/v15.0.1/Halide-15.0.1-x86-64-windows-4c63f1befa1063184c5982b11b6a2cc17d4e5815.zip"], - build_file = "@mediapipe//third_party:halide.BUILD", ) http_archive( name = "com_github_nlohmann_json", + build_file = "@mediapipe//third_party:nlohmann.BUILD", sha256 = "6bea5877b1541d353bd77bdfbdb2696333ae5ed8f9e8cc22df657192218cad91", urls = ["https://github.com/nlohmann/json/releases/download/v3.9.1/include.zip"], - build_file = "@//third_party:nlohmann.BUILD", +) + +http_archive( + name = "skia", + sha256 = "038d4a21f9c72d71ab49e3a7d7677b39585329465d093a4260b6c73d2f3984d6", + strip_prefix = "skia-ac75382cb971d2f5465b4608a74561ecb68599c5", + urls = ["https://github.com/google/skia/archive/ac75382cb971d2f5465b4608a74561ecb68599c5.zip"], +) + +http_archive( + name = "skia_user_config", + sha256 = "038d4a21f9c72d71ab49e3a7d7677b39585329465d093a4260b6c73d2f3984d6", + strip_prefix = "skia-ac75382cb971d2f5465b4608a74561ecb68599c5/include/config", + urls = ["https://github.com/google/skia/archive/ac75382cb971d2f5465b4608a74561ecb68599c5.zip"], ) diff --git a/docker/linux/x86_64/Dockerfile b/docker/linux/x86_64/Dockerfile index 5cfb1db1a..bd82b16c9 100644 --- a/docker/linux/x86_64/Dockerfile +++ b/docker/linux/x86_64/Dockerfile @@ -143,6 +143,7 @@ ARG ANDROID_NDK_VERSION ENV ANDROID_HOME /opt/android ENV ANDROID_NDK_HOME /opt/android/ndk/${ANDROID_NDK_VERSION} ENV PYTHON_BIN_PATH /usr/bin/python3.9 +ENV HERMETIC_PYTHON_VERSION 3.9 COPY packages.config . COPY .bazelrc . diff --git a/docker/windows/x86_64/Dockerfile b/docker/windows/x86_64/Dockerfile index 7868b01d9..01dff3459 100644 --- a/docker/windows/x86_64/Dockerfile +++ b/docker/windows/x86_64/Dockerfile @@ -115,6 +115,7 @@ ENV ANDROID_HOME C:\Android ENV ANDROID_NDK_HOME ${ANDROID_HOME}\ndk\${ANDROID_NDK_VERSION} ENV PYTHON_INSTALL_PATH=C:\Python ENV PYTHON_BIN_PATH=${PYTHON_INSTALL_PATH}\python.exe +ENV HERMETIC_PYTHON_VERSION 3.9 # Install Bazel and NuGet RUN setx path "C:\bin;%PYTHON_INSTALL_PATH%;%PYTHON_INSTALL_PATH%\Scripts;%PATH%" && ` diff --git a/third_party/mediapipe_extension.diff b/third_party/mediapipe_extension.diff index 26f54d221..6b7a483ca 100644 --- a/third_party/mediapipe_extension.diff +++ b/third_party/mediapipe_extension.diff @@ -1,79 +1,5 @@ -diff --git a/mediapipe/BUILD b/mediapipe/BUILD -index 90edc8a5..adea5964 100644 ---- a/mediapipe/BUILD -+++ b/mediapipe/BUILD -@@ -196,6 +196,31 @@ config_setting_and_platform( - visibility = ["//visibility:public"], - ) - -+config_setting( -+ name = "emscripten", -+ values = {"crosstool_top": "@emsdk//emscripten_toolchain:everything"}, -+ visibility = ["//visibility:public"], -+) -+ -+config_setting( -+ name = "emscripten_wasm", -+ values = { -+ "crosstool_top": "@emsdk//emscripten_toolchain:everything", -+ "cpu": "wasm", -+ }, -+ visibility = ["//visibility:public"], -+) -+ -+config_setting( -+ name = "emscripten_wasmsimd", -+ values = { -+ "crosstool_top": "@emsdk//emscripten_toolchain:everything", -+ "cpu": "wasm", -+ "copt": "-msimd128", -+ }, -+ visibility = ["//visibility:public"], -+) -+ - exports_files( - ["provisioning_profile.mobileprovision"], - visibility = ["//visibility:public"], -diff --git a/mediapipe/calculators/tensor/BUILD b/mediapipe/calculators/tensor/BUILD -index bda2ce82..a2f200b5 100644 ---- a/mediapipe/calculators/tensor/BUILD -+++ b/mediapipe/calculators/tensor/BUILD -@@ -69,6 +69,7 @@ selects.config_setting_group( - name = "compute_shader_unavailable", - match_any = [ - "//mediapipe/gpu:disable_gpu", -+ "//mediapipe:emscripten", - ], - ) - -@@ -1462,6 +1463,11 @@ cc_library( - "//mediapipe/gpu:gpu_buffer", - "//mediapipe/gpu:gpu_service", - ], -+ "//mediapipe:emscripten": [ -+ ":image_to_tensor_converter_gl_texture", -+ "//mediapipe/gpu:gl_calculator_helper", -+ "//mediapipe/gpu:gpu_buffer", -+ ], - "//conditions:default": [ - ":image_to_tensor_converter_gl_buffer", - "//mediapipe/gpu:gl_calculator_helper", -diff --git a/mediapipe/gpu/BUILD b/mediapipe/gpu/BUILD -index 7e0c45b3..9b4ead93 100644 ---- a/mediapipe/gpu/BUILD -+++ b/mediapipe/gpu/BUILD -@@ -169,6 +169,9 @@ cc_library( - "//mediapipe:macos": [ - "gl_context_nsgl.cc", - ], -+ "//mediapipe:emscripten": [ -+ "gl_context_webgl.cc", -+ ], - }), - hdrs = ["gl_context.h"], - copts = select({ diff --git a/mediapipe/gpu/gl_context_webgl.cc b/mediapipe/gpu/gl_context_webgl.cc -index 7560fca0..e24865e6 100644 +index 93324fe2..27a1ab9a 100644 --- a/mediapipe/gpu/gl_context_webgl.cc +++ b/mediapipe/gpu/gl_context_webgl.cc @@ -52,6 +52,10 @@ absl::Status GlContext::CreateContextInternal( @@ -88,19 +14,18 @@ index 7560fca0..e24865e6 100644 emscripten_webgl_init_context_attributes(&attrs); attrs.explicitSwapControl = 0; diff --git a/mediapipe/gpu/gl_scaler_calculator.cc b/mediapipe/gpu/gl_scaler_calculator.cc -index 5ab6dedc..d4cd312d 100644 +index 8288496b..7ebc54fc 100644 --- a/mediapipe/gpu/gl_scaler_calculator.cc +++ b/mediapipe/gpu/gl_scaler_calculator.cc -@@ -12,6 +12,8 @@ +@@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +// Modified to enable to specify the target GpuBuffer -+ + #include "absl/status/statusor.h" #include "mediapipe/framework/calculator_framework.h" #include "mediapipe/framework/formats/image.h" - #include "mediapipe/framework/port/ret_check.h" -@@ -69,6 +71,7 @@ using Image = mediapipe::Image; +@@ -72,6 +73,7 @@ using Image = mediapipe::Image; // existing calculator options, depending on field merge_fields. // OUTPUT_DIMENSIONS: the output width and height in pixels. // ROTATION: the counterclockwise rotation angle in degrees. @@ -108,15 +33,15 @@ index 5ab6dedc..d4cd312d 100644 // These can also be specified as options. // To enable horizontal or vertical flip, specify them in options. // The flipping is applied after rotation. -@@ -96,6 +99,7 @@ class GlScalerCalculator : public CalculatorBase { +@@ -102,6 +104,7 @@ class GlScalerCalculator : public CalculatorBase { + absl::StatusOr GetInputGpuBuffer(CalculatorContext* cc); - private: GlCalculatorHelper helper_; + GpuBuffer dst_buffer_; int dst_width_ = 0; int dst_height_ = 0; float dst_scale_ = -1.f; -@@ -134,6 +138,9 @@ absl::Status GlScalerCalculator::GetContract(CalculatorContract* cc) { +@@ -140,6 +143,9 @@ absl::Status GlScalerCalculator::GetContract(CalculatorContract* cc) { } MP_RETURN_IF_ERROR(GlCalculatorHelper::UpdateContract(cc)); @@ -126,7 +51,7 @@ index 5ab6dedc..d4cd312d 100644 if (cc->InputSidePackets().HasTag(kOptionsTag)) { cc->InputSidePackets().Tag(kOptionsTag).Set(); } -@@ -202,6 +209,11 @@ absl::Status GlScalerCalculator::Open(CalculatorContext* cc) { +@@ -208,6 +214,11 @@ absl::Status GlScalerCalculator::Open(CalculatorContext* cc) { dst_width_ = dimensions[0]; dst_height_ = dimensions[1]; } @@ -138,7 +63,7 @@ index 5ab6dedc..d4cd312d 100644 if (cc->InputSidePackets().HasTag(kRotationTag)) { rotation_ccw = cc->InputSidePackets().Tag(kRotationTag).Get(); } -@@ -212,7 +224,7 @@ absl::Status GlScalerCalculator::Open(CalculatorContext* cc) { +@@ -230,7 +241,7 @@ absl::StatusOr GlScalerCalculator::GetInputGpuBuffer( } absl::Status GlScalerCalculator::Process(CalculatorContext* cc) { @@ -147,7 +72,7 @@ index 5ab6dedc..d4cd312d 100644 if (cc->Inputs().Tag(kOutputDimensionsTag).IsEmpty()) { // OUTPUT_DIMENSIONS input stream is specified, but value is missing. return absl::OkStatus(); -@@ -294,9 +306,18 @@ absl::Status GlScalerCalculator::Process(CalculatorContext* cc) { +@@ -309,9 +320,18 @@ absl::Status GlScalerCalculator::Process(CalculatorContext* cc) { MakePacket(left_right_padding).At(cc->InputTimestamp())); } diff --git a/third_party/mediapipe_model_path.diff b/third_party/mediapipe_model_path.diff index b2809a134..9a9295de2 100644 --- a/third_party/mediapipe_model_path.diff +++ b/third_party/mediapipe_model_path.diff @@ -1,8 +1,8 @@ diff --git a/mediapipe/util/BUILD b/mediapipe/util/BUILD -index 2e08210e..8e79e6e2 100644 +index d8cccf0b..3b468aac 100644 --- a/mediapipe/util/BUILD +++ b/mediapipe/util/BUILD -@@ -195,14 +195,8 @@ cc_library( +@@ -251,15 +251,8 @@ cc_library( srcs = [ "resource_util.cc", "resource_util_internal.h", @@ -12,6 +12,7 @@ index 2e08210e..8e79e6e2 100644 - "//mediapipe/framework:android_no_jni": ["resource_util_loonix.cc"], - "//mediapipe:ios": ["resource_util_apple.cc"], - "//mediapipe:macos": ["resource_util_default.cc"], +- "//mediapipe:emscripten": ["resource_util_emscripten.cc"], - "//mediapipe:windows": ["resource_util_windows.cc"], - }), + "resource_util_unity.cc", @@ -19,11 +20,10 @@ index 2e08210e..8e79e6e2 100644 hdrs = [ "resource_util.h", ], -@@ -227,25 +221,7 @@ cc_library( - "//mediapipe/framework/port:statusor", - "@com_google_absl//absl/log:absl_log", +@@ -287,25 +280,7 @@ cc_library( + "@com_google_absl//absl/status:statusor", "@com_google_absl//absl/strings", -- "@com_google_absl//absl/strings:str_format", + "@com_google_absl//absl/strings:str_format", - ] + select({ - "//conditions:default": [ - "@com_google_absl//absl/flags:flag", @@ -34,6 +34,7 @@ index 2e08210e..8e79e6e2 100644 - ], - "//mediapipe/framework:android_no_jni": [], - "//mediapipe:ios": [], +- "//mediapipe:emscripten": [], - "//mediapipe:macos": [ - "@com_google_absl//absl/flags:flag", - ], @@ -81,17 +82,18 @@ index 38636f32..55d62a2f 100644 + } // namespace mediapipe diff --git a/mediapipe/util/resource_util_custom.h b/mediapipe/util/resource_util_custom.h -index e74af8b2..6ba61715 100644 +index e74af8b2..e746f91f 100644 --- a/mediapipe/util/resource_util_custom.h +++ b/mediapipe/util/resource_util_custom.h -@@ -4,18 +4,25 @@ +@@ -3,6 +3,7 @@ + #include ++#include "absl/status/statusor.h" #include "mediapipe/framework/port/status.h" -+#include "mediapipe/framework/port/statusor.h" namespace mediapipe { - +@@ -10,12 +11,18 @@ namespace mediapipe { typedef std::function ResourceProviderFn; @@ -125,12 +127,12 @@ index 8ae127a2..91ffc9a5 100644 #endif // MEDIAPIPE_UTIL_RESOURCE_UTIL_INTERNAL_H_ diff --git a/mediapipe/util/resource_util_unity.cc b/mediapipe/util/resource_util_unity.cc new file mode 100644 -index 00000000..946be0d4 +index 00000000..890c03ef --- /dev/null +++ b/mediapipe/util/resource_util_unity.cc @@ -0,0 +1,21 @@ ++#include "absl/status/statusor.h" +#include "mediapipe/framework/port/file_helpers.h" -+#include "mediapipe/framework/port/statusor.h" + +namespace mediapipe { + @@ -151,7 +153,7 @@ index 00000000..946be0d4 +} // namespace internal +} // namespace mediapipe diff --git a/third_party/external_files.bzl b/third_party/external_files.bzl -index a3893b5f..c04ddc99 100644 +index 7a04fd8c..003671b3 100644 --- a/third_party/external_files.bzl +++ b/third_party/external_files.bzl @@ -250,6 +250,12 @@ def external_files(): @@ -235,7 +237,7 @@ index a3893b5f..c04ddc99 100644 http_file( name = "com_google_mediapipe_face_geometry_expected_out_pbtxt", sha256 = "4a4ed08055a5bc9281472dd60180d11f0cdc9a15fa1788d87a58af3d06b2c6e4", -@@ -1144,6 +1204,24 @@ def external_files(): +@@ -1192,6 +1252,24 @@ def external_files(): urls = ["https://storage.googleapis.com/mediapipe-assets/pose_landmarker.task?generation=1681244249587900"], ) @@ -260,7 +262,7 @@ index a3893b5f..c04ddc99 100644 http_file( name = "com_google_mediapipe_pose_landmark_full_tflite", sha256 = "e9a5c5cb17f736fafd4c2ec1da3b3d331d6edbe8a0d32395855aeb2cdfd64b9f", -@@ -1300,6 +1378,12 @@ def external_files(): +@@ -1348,6 +1426,12 @@ def external_files(): urls = ["https://storage.googleapis.com/mediapipe-assets/selfie_segmentation.tflite?generation=1683332563830600"], ) diff --git a/third_party/mediapipe_opencv.diff b/third_party/mediapipe_opencv.diff index 8bd186cc2..d35a586f6 100644 --- a/third_party/mediapipe_opencv.diff +++ b/third_party/mediapipe_opencv.diff @@ -1,16 +1,8 @@ diff --git a/third_party/BUILD b/third_party/BUILD -index 78b83fa0..d2e758b3 100644 +index 6b00be7e..c9dc6e62 100644 --- a/third_party/BUILD +++ b/third_party/BUILD -@@ -14,7 +14,6 @@ - # - - load("@bazel_skylib//:bzl_library.bzl", "bzl_library") --load("@rules_foreign_cc//foreign_cc:cmake.bzl", "cmake") - - licenses(["notice"]) # Apache License 2.0 - -@@ -53,67 +52,9 @@ cc_library( +@@ -67,108 +67,9 @@ cc_library( }), ) @@ -23,6 +15,14 @@ index 78b83fa0..d2e758b3 100644 -) - -config_setting( +- name = "opencv_prebuilt_build", +- define_values = { +- "OPENCV": "prebuilt", +- }, +- visibility = ["//visibility:public"], +-) +- +-config_setting( - name = "opencv_ios_arm64_source_build", - define_values = { - "OPENCV": "source", @@ -65,11 +65,44 @@ index 78b83fa0..d2e758b3 100644 - "ios_multi_cpus": "sim_arm64,x86_64", - }, -) +- +-config_setting( +- name = "opencv_darwin_prebuild", +- define_values = { +- "OPENCV": "prebuilt", +- }, +- values = { +- "apple_platform_type": "macos", +- "cpu": "darwin", +- }, +-) +- +-config_setting( +- name = "opencv_darwin_arm64_prebuild", +- define_values = { +- "OPENCV": "prebuilt", +- }, +- values = { +- "apple_platform_type": "macos", +- "cpu": "darwin_arm64", +- }, +-) +- +-alias( +- name = "opencv_prebuilt", +- actual = select({ +- "//mediapipe:ios": "@ios_opencv//:opencv", +- ":opencv_darwin_prebuild": "//third_party/prebuilts:opencv_darwin", +- ":opencv_darwin_arm64_prebuild": "//third_party/prebuilts:opencv_darwin_arm64", +- "//conditions:default": ":opencv_cmake", +- }), +-) - alias( name = "opencv", - actual = select({ - ":opencv_source_build": ":opencv_cmake", +- ":opencv_prebuilt_build": ":opencv_prebuilt", - ":opencv_ios_sim_arm64_source_build": "@ios_opencv_source//:opencv", - ":opencv_ios_arm64_source_build": "@ios_opencv_source//:opencv", - ":opencv_ios_x86_64_source_build": "@ios_opencv_source//:opencv", @@ -79,7 +112,7 @@ index 78b83fa0..d2e758b3 100644 visibility = ["//visibility:public"], ) -@@ -129,132 +70,6 @@ bzl_library( +@@ -184,132 +85,6 @@ bzl_library( visibility = ["//visibility:private"], )