From a6876843f0c519057f03e1bcb694168470fc9566 Mon Sep 17 00:00:00 2001 From: Joe Zou Date: Thu, 3 Oct 2024 16:57:53 -0700 Subject: [PATCH] Add python pip deps to WORKSPACE PiperOrigin-RevId: 682085450 --- WORKSPACE | 14 +++++ mediapipe/model_maker/python/core/BUILD | 4 ++ mediapipe/model_maker/python/core/data/BUILD | 30 ++++++++-- mediapipe/model_maker/python/core/tasks/BUILD | 4 ++ mediapipe/model_maker/python/core/utils/BUILD | 42 ++++++++++++-- .../python/text/text_classifier/BUILD | 34 +++++++++++- .../model_maker/python/vision/core/BUILD | 17 +++++- .../python/vision/face_stylizer/BUILD | 8 ++- .../python/vision/gesture_recognizer/BUILD | 14 ++++- .../python/vision/image_classifier/BUILD | 18 +++++- .../python/vision/object_detector/BUILD | 55 +++++++++++++++++-- mediapipe/model_maker/requirements_bazel.txt | 10 ++++ mediapipe/tasks/python/audio/core/BUILD | 3 + .../tasks/python/components/containers/BUILD | 2 + mediapipe/tasks/python/components/utils/BUILD | 5 +- mediapipe/tasks/python/genai/bundler/BUILD | 5 +- mediapipe/tasks/python/genai/converter/BUILD | 1 + mediapipe/tasks/python/metadata/BUILD | 7 ++- mediapipe/tasks/python/test/BUILD | 2 + mediapipe/tasks/python/test/audio/BUILD | 6 ++ mediapipe/tasks/python/test/audio/core/BUILD | 7 ++- mediapipe/tasks/python/test/metadata/BUILD | 9 ++- .../test/metadata/metadata_writers/BUILD | 16 +++++- mediapipe/tasks/python/test/text/BUILD | 2 + mediapipe/tasks/python/test/vision/BUILD | 30 ++++++++++ mediapipe/tasks/python/vision/BUILD | 2 + 26 files changed, 324 insertions(+), 23 deletions(-) create mode 100644 mediapipe/model_maker/requirements_bazel.txt diff --git a/WORKSPACE b/WORKSPACE index 877dffb131..d353b0fe2e 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -69,6 +69,20 @@ http_archive( load("@rules_python//python:repositories.bzl", "py_repositories") py_repositories() +load("@rules_python//python:pip.bzl", "pip_parse") +pip_parse( + name = "mediapipe_pip_deps", + requirements_lock = "@//:requirements.txt", +) +load("@mediapipe_pip_deps//:requirements.bzl", mp_install_deps = "install_deps") +mp_install_deps() +pip_parse( + name = "model_maker_pip_deps", + requirements_lock = "@//mediapipe/model_maker:requirements_bazel.txt", +) +load("@model_maker_pip_deps//:requirements.bzl", mm_install_deps = "install_deps") +mm_install_deps() + http_archive( name = "rules_android_ndk", sha256 = "d230a980e0d3a42b85d5fce2cb17ec3ac52b88d2cff5aaf86bae0f05b48adc55", diff --git a/mediapipe/model_maker/python/core/BUILD b/mediapipe/model_maker/python/core/BUILD index a73e545d3e..d0ef8dcecb 100644 --- a/mediapipe/model_maker/python/core/BUILD +++ b/mediapipe/model_maker/python/core/BUILD @@ -24,4 +24,8 @@ licenses(["notice"]) py_library( name = "hyperparameters", srcs = ["hyperparameters.py"], + deps = [ + "@model_maker_pip_deps//tensorflow", + "@model_maker_pip_deps//tensorflow_models/official/common:distribute_utils", + ], ) diff --git a/mediapipe/model_maker/python/core/data/BUILD b/mediapipe/model_maker/python/core/data/BUILD index 4364b77441..a5ea2e1099 100644 --- a/mediapipe/model_maker/python/core/data/BUILD +++ b/mediapipe/model_maker/python/core/data/BUILD @@ -22,19 +22,29 @@ package(default_visibility = ["//mediapipe:__subpackages__"]) py_library( name = "data_util", srcs = ["data_util.py"], + deps = [ + "@model_maker_pip_deps//cv2", + "@model_maker_pip_deps//numpy", + "@model_maker_pip_deps//tensorflow", + ], ) py_test( name = "data_util_test", srcs = ["data_util_test.py"], data = ["//mediapipe/model_maker/python/core/data/testdata"], - deps = [":data_util"], + deps = [ + ":data_util", + "@model_maker_pip_deps//absl/flags", + "@model_maker_pip_deps//tensorflow", + ], ) py_library( name = "dataset", srcs = ["dataset.py"], srcs_version = "PY3", + deps = ["@model_maker_pip_deps//tensorflow"], ) py_test( @@ -43,28 +53,40 @@ py_test( deps = [ ":dataset", "//mediapipe/model_maker/python/core/utils:test_util", + "@model_maker_pip_deps//numpy", + "@model_maker_pip_deps//tensorflow", ], ) py_library( name = "classification_dataset", srcs = ["classification_dataset.py"], - deps = [":dataset"], + deps = [ + ":dataset", + "@model_maker_pip_deps//tensorflow", + ], ) py_test( name = "classification_dataset_test", srcs = ["classification_dataset_test.py"], - deps = [":classification_dataset"], + deps = [ + ":classification_dataset", + "@model_maker_pip_deps//tensorflow", + ], ) py_library( name = "cache_files", srcs = ["cache_files.py"], + deps = ["@model_maker_pip_deps//tensorflow"], ) py_test( name = "cache_files_test", srcs = ["cache_files_test.py"], - deps = [":cache_files"], + deps = [ + ":cache_files", + "@model_maker_pip_deps//tensorflow", + ], ) diff --git a/mediapipe/model_maker/python/core/tasks/BUILD b/mediapipe/model_maker/python/core/tasks/BUILD index 818d78feb1..af3eaf5f7a 100644 --- a/mediapipe/model_maker/python/core/tasks/BUILD +++ b/mediapipe/model_maker/python/core/tasks/BUILD @@ -26,6 +26,7 @@ py_library( "//mediapipe/model_maker/python/core/data:dataset", "//mediapipe/model_maker/python/core/utils:model_util", "//mediapipe/model_maker/python/core/utils:quantization", + "@model_maker_pip_deps//tensorflow", ], ) @@ -35,6 +36,7 @@ py_test( deps = [ ":custom_model", "//mediapipe/model_maker/python/core/utils:test_util", + "@model_maker_pip_deps//tensorflow", ], ) @@ -47,6 +49,7 @@ py_library( "//mediapipe/model_maker/python/core/data:classification_dataset", "//mediapipe/model_maker/python/core/data:dataset", "//mediapipe/model_maker/python/core/utils:model_util", + "@model_maker_pip_deps//tensorflow", ], ) @@ -56,5 +59,6 @@ py_test( deps = [ ":classifier", "//mediapipe/model_maker/python/core/utils:test_util", + "@model_maker_pip_deps//tensorflow", ], ) diff --git a/mediapipe/model_maker/python/core/utils/BUILD b/mediapipe/model_maker/python/core/utils/BUILD index 3d5057491a..f71fa73701 100644 --- a/mediapipe/model_maker/python/core/utils/BUILD +++ b/mediapipe/model_maker/python/core/utils/BUILD @@ -33,6 +33,8 @@ py_library( deps = [ ":model_util", "//mediapipe/model_maker/python/core/data:dataset", + "@model_maker_pip_deps//numpy", + "@model_maker_pip_deps//tensorflow", ], ) @@ -42,6 +44,8 @@ py_library( deps = [ ":quantization", "//mediapipe/model_maker/python/core/data:dataset", + "@model_maker_pip_deps//numpy", + "@model_maker_pip_deps//tensorflow", ], ) @@ -52,6 +56,8 @@ py_test( ":model_util", ":quantization", ":test_util", + "@model_maker_pip_deps//absl/testing:parameterized", + "@model_maker_pip_deps//tensorflow", ], ) @@ -65,12 +71,18 @@ py_test( srcs = ["file_util_test.py"], data = [":testdata"], tags = ["requires-net:external"], - deps = [":file_util"], + deps = [ + ":file_util", + "@model_maker_pip_deps//absl/testing:absltest", + ], ) py_library( name = "hub_loader", srcs = ["hub_loader.py"], + deps = [ + "@model_maker_pip_deps//tensorflow_hub", + ], ) py_test( @@ -80,6 +92,8 @@ py_test( deps = [ ":hub_loader", "//mediapipe/tasks/python/test:test_utils", + "@model_maker_pip_deps//absl/testing:parameterized", + "@model_maker_pip_deps//tensorflow", ], ) @@ -90,6 +104,9 @@ py_library( deps = [ ":file_util", ":model_util", + "@model_maker_pip_deps//numpy", + "@model_maker_pip_deps//tensorflow", + "@model_maker_pip_deps//tensorflow_models/official/modeling:tf_utils", ], ) @@ -99,7 +116,11 @@ py_test( tags = [ "requires-net:external", ], - deps = [":loss_functions"], + deps = [ + ":loss_functions", + "@model_maker_pip_deps//absl/testing:parameterized", + "@model_maker_pip_deps//tensorflow", + ], ) ###################################################################### @@ -113,12 +134,20 @@ py_test( py_library( name = "metrics", srcs = ["metrics.py"], + deps = [ + "@model_maker_pip_deps//tensorflow", + ], ) py_test( name = "metrics_test", srcs = ["metrics_test.py"], - deps = [":metrics"], + deps = [ + ":metrics", + "@model_maker_pip_deps//absl/testing:parameterized", + "@model_maker_pip_deps//numpy", + "@model_maker_pip_deps//tensorflow", + ], ) py_library( @@ -126,7 +155,10 @@ py_library( srcs = ["quantization.py"], srcs_version = "PY3", visibility = ["//visibility:public"], - deps = ["//mediapipe/model_maker/python/core/data:dataset"], + deps = [ + "//mediapipe/model_maker/python/core/data:dataset", + "@model_maker_pip_deps//tensorflow", + ], ) py_test( @@ -135,5 +167,7 @@ py_test( deps = [ ":quantization", ":test_util", + "@model_maker_pip_deps//absl/testing:parameterized", + "@model_maker_pip_deps//tensorflow", ], ) diff --git a/mediapipe/model_maker/python/text/text_classifier/BUILD b/mediapipe/model_maker/python/text/text_classifier/BUILD index 5e8e0846b4..3ee1261100 100644 --- a/mediapipe/model_maker/python/text/text_classifier/BUILD +++ b/mediapipe/model_maker/python/text/text_classifier/BUILD @@ -78,6 +78,7 @@ py_test( ":hyperparameters", ":model_options", ":model_spec", + "@model_maker_pip_deps//tensorflow", ], ) @@ -87,18 +88,25 @@ py_library( deps = [ "//mediapipe/model_maker/python/core/data:cache_files", "//mediapipe/model_maker/python/core/data:classification_dataset", + "@model_maker_pip_deps//tensorflow", ], ) py_test( name = "dataset_test", srcs = ["dataset_test.py"], - deps = [":dataset"], + deps = [ + ":dataset", + "@model_maker_pip_deps//tensorflow", + ], ) py_library( name = "model_with_tokenizer", srcs = ["model_with_tokenizer.py"], + deps = [ + "@model_maker_pip_deps//tensorflow", + ], ) py_test( @@ -110,12 +118,19 @@ py_test( ":model_spec", ":model_with_tokenizer", "//mediapipe/model_maker/python/core/utils:hub_loader", + "@model_maker_pip_deps//tensorflow", + "@model_maker_pip_deps//tensorflow_hub", ], ) py_library( name = "bert_tokenizer", srcs = ["bert_tokenizer.py"], + deps = [ + "@model_maker_pip_deps//tensorflow", + "@model_maker_pip_deps//tensorflow_models/official/nlp/tools:tokenization", + "@model_maker_pip_deps//tensorflow_text", + ], ) py_test( @@ -125,6 +140,9 @@ py_test( deps = [ ":bert_tokenizer", ":model_spec", + "@model_maker_pip_deps//absl/testing:parameterized", + "@model_maker_pip_deps//tensorflow", + "@model_maker_pip_deps//tensorflow_hub", ], ) @@ -135,6 +153,8 @@ py_library( ":bert_tokenizer", ":dataset", "//mediapipe/model_maker/python/core/data:cache_files", + "@model_maker_pip_deps//tensorflow", + "@model_maker_pip_deps//tensorflow_hub", ], ) @@ -148,6 +168,9 @@ py_test( ":model_spec", ":preprocessor", "//mediapipe/model_maker/python/core/data:cache_files", + "@model_maker_pip_deps//absl/testing:parameterized", + "@model_maker_pip_deps//numpy", + "@model_maker_pip_deps//tensorflow", ], ) @@ -182,6 +205,9 @@ py_library( "//mediapipe/model_maker/python/core/utils:quantization", "//mediapipe/tasks/python/metadata/metadata_writers:metadata_writer", "//mediapipe/tasks/python/metadata/metadata_writers:text_classifier", + "@model_maker_pip_deps//tensorflow", + "@model_maker_pip_deps//tensorflow_addons", + "@model_maker_pip_deps//tensorflow_hub", ], ) @@ -202,6 +228,8 @@ py_test( ":text_classifier_import", "//mediapipe/model_maker/python/core/utils:loss_functions", "//mediapipe/tasks/python/test:test_utils", + "@model_maker_pip_deps//absl/testing:parameterized", + "@model_maker_pip_deps//tensorflow", ], ) @@ -211,6 +239,10 @@ py_library( deps = [ ":text_classifier_import", "//mediapipe/model_maker/python/core/utils:quantization", + "@model_maker_pip_deps//absl:app", + "@model_maker_pip_deps//absl/flags", + "@model_maker_pip_deps//absl/logging", + "@model_maker_pip_deps//tensorflow", ], ) diff --git a/mediapipe/model_maker/python/vision/core/BUILD b/mediapipe/model_maker/python/vision/core/BUILD index a5d4b08f86..4a7968eb7c 100644 --- a/mediapipe/model_maker/python/vision/core/BUILD +++ b/mediapipe/model_maker/python/vision/core/BUILD @@ -24,17 +24,27 @@ package(default_visibility = [ py_library( name = "image_preprocessing", srcs = ["image_preprocessing.py"], + deps = [ + "@model_maker_pip_deps//tensorflow", + ], ) py_test( name = "image_preprocessing_test", srcs = ["image_preprocessing_test.py"], - deps = [":image_preprocessing"], + deps = [ + ":image_preprocessing", + "@model_maker_pip_deps//numpy", + "@model_maker_pip_deps//tensorflow", + ], ) py_library( name = "image_utils", srcs = ["image_utils.py"], + deps = [ + "@model_maker_pip_deps//tensorflow", + ], ) py_test( @@ -43,10 +53,15 @@ py_test( deps = [ ":image_utils", ":test_utils", + "@model_maker_pip_deps//tensorflow", ], ) py_library( name = "test_utils", srcs = ["test_utils.py"], + deps = [ + "@model_maker_pip_deps//numpy", + "@model_maker_pip_deps//tensorflow", + ], ) diff --git a/mediapipe/model_maker/python/vision/face_stylizer/BUILD b/mediapipe/model_maker/python/vision/face_stylizer/BUILD index 5c74cf9c46..207a2f3432 100644 --- a/mediapipe/model_maker/python/vision/face_stylizer/BUILD +++ b/mediapipe/model_maker/python/vision/face_stylizer/BUILD @@ -48,7 +48,10 @@ py_library( py_test( name = "model_spec_test", srcs = ["model_spec_test.py"], - deps = [":model_spec"], + deps = [ + ":model_spec", + "@model_maker_pip_deps//tensorflow", + ], ) py_library( @@ -70,6 +73,7 @@ py_library( "//mediapipe/python:_framework_bindings", "//mediapipe/tasks/python/core:base_options", "//mediapipe/tasks/python/vision:face_aligner", + "@model_maker_pip_deps//tensorflow", ], ) @@ -87,6 +91,8 @@ py_library( "//mediapipe/model_maker/python/core/utils:model_util", "//mediapipe/model_maker/python/vision/core:image_preprocessing", "//mediapipe/tasks/python/metadata/metadata_writers:face_stylizer", + "@model_maker_pip_deps//numpy", + "@model_maker_pip_deps//tensorflow", ], ) diff --git a/mediapipe/model_maker/python/vision/gesture_recognizer/BUILD b/mediapipe/model_maker/python/vision/gesture_recognizer/BUILD index 5c67089f7f..5b06e82c8e 100644 --- a/mediapipe/model_maker/python/vision/gesture_recognizer/BUILD +++ b/mediapipe/model_maker/python/vision/gesture_recognizer/BUILD @@ -47,6 +47,7 @@ py_library( "//mediapipe/python:_framework_bindings", "//mediapipe/tasks/python/core:base_options", "//mediapipe/tasks/python/vision:hand_landmarker", + "@model_maker_pip_deps//tensorflow", ], ) @@ -64,6 +65,8 @@ py_test( ":dataset", "//mediapipe/tasks/python/test:test_utils", "//mediapipe/tasks/python/vision:hand_landmarker", + "@model_maker_pip_deps//absl/testing:parameterized", + "@model_maker_pip_deps//tensorflow", ], ) @@ -103,6 +106,7 @@ py_library( "//mediapipe/model_maker/python/core/utils:loss_functions", "//mediapipe/model_maker/python/core/utils:model_util", "//mediapipe/tasks/python/metadata/metadata_writers:metadata_writer", + "@model_maker_pip_deps//tensorflow", ], ) @@ -131,6 +135,7 @@ py_library( deps = [ "//mediapipe/tasks/python/metadata/metadata_writers:metadata_writer", "//mediapipe/tasks/python/metadata/metadata_writers:model_asset_bundle_utils", + "@model_maker_pip_deps//tensorflow:tensorflow_no_contrib", ], ) @@ -152,6 +157,7 @@ py_test( ":model_options", "//mediapipe/model_maker/python/core/utils:test_util", "//mediapipe/tasks/python/test:test_utils", + "@model_maker_pip_deps//tensorflow", ], ) @@ -163,6 +169,7 @@ py_test( ":metadata_writer", "//mediapipe/tasks/python/metadata/metadata_writers:metadata_writer", "//mediapipe/tasks/python/test:test_utils", + "@model_maker_pip_deps//tensorflow:tensorflow_no_contrib", ], ) @@ -172,5 +179,10 @@ py_binary( data = [":testdata"], python_version = "PY3", tags = ["requires-net:external"], - deps = [":gesture_recognizer_import"], + deps = [ + ":gesture_recognizer_import", + "@model_maker_pip_deps//absl:app", + "@model_maker_pip_deps//absl/flags", + "@model_maker_pip_deps//absl/logging", + ], ) diff --git a/mediapipe/model_maker/python/vision/image_classifier/BUILD b/mediapipe/model_maker/python/vision/image_classifier/BUILD index 67899d1168..e328d82ed3 100644 --- a/mediapipe/model_maker/python/vision/image_classifier/BUILD +++ b/mediapipe/model_maker/python/vision/image_classifier/BUILD @@ -47,7 +47,11 @@ py_library( py_test( name = "model_spec_test", srcs = ["model_spec_test.py"], - deps = [":model_spec"], + deps = [ + ":model_spec", + "@model_maker_pip_deps//absl/testing:parameterized", + "@model_maker_pip_deps//tensorflow", + ], ) py_library( @@ -56,6 +60,7 @@ py_library( deps = [ "//mediapipe/model_maker/python/core/data:classification_dataset", "//mediapipe/model_maker/python/vision/core:image_utils", + "@model_maker_pip_deps//tensorflow", ], ) @@ -66,6 +71,8 @@ py_test( ":dataset", "//mediapipe/model_maker/python/vision/core:image_utils", "//mediapipe/model_maker/python/vision/core:test_utils", + "@model_maker_pip_deps//numpy", + "@model_maker_pip_deps//tensorflow", ], ) @@ -108,6 +115,8 @@ py_library( "//mediapipe/model_maker/python/vision/core:image_preprocessing", "//mediapipe/tasks/python/metadata/metadata_writers:image_classifier", "//mediapipe/tasks/python/metadata/metadata_writers:metadata_writer", + "@model_maker_pip_deps//tensorflow", + "@model_maker_pip_deps//tensorflow_hub", ], ) @@ -121,6 +130,9 @@ py_library( ":image_classifier_import", ":model_options", "//mediapipe/tasks/python/test:test_utils", + "@model_maker_pip_deps//absl/testing:parameterized", + "@model_maker_pip_deps//numpy", + "@model_maker_pip_deps//tensorflow", ], ) @@ -144,5 +156,9 @@ py_binary( deps = [ ":image_classifier_import", "//mediapipe/model_maker/python/core/utils:quantization", + "@model_maker_pip_deps//absl:app", + "@model_maker_pip_deps//absl/flags", + "@model_maker_pip_deps//absl/logging", + "@model_maker_pip_deps//tensorflow", ], ) diff --git a/mediapipe/model_maker/python/vision/object_detector/BUILD b/mediapipe/model_maker/python/vision/object_detector/BUILD index c0acccf850..e8150e849a 100644 --- a/mediapipe/model_maker/python/vision/object_detector/BUILD +++ b/mediapipe/model_maker/python/vision/object_detector/BUILD @@ -39,7 +39,12 @@ py_binary( data = [":testdata"], python_version = "PY3", tags = ["requires-net:external"], - deps = [":object_detector_import"], + deps = [ + ":object_detector_import", + "@model_maker_pip_deps//absl:app", + "@model_maker_pip_deps//absl/flags", + "@model_maker_pip_deps//absl/logging", + ], ) filegroup( @@ -56,6 +61,8 @@ py_library( ":dataset_util", "//mediapipe/model_maker/python/core/data:cache_files", "//mediapipe/model_maker/python/core/data:classification_dataset", + "@model_maker_pip_deps//tensorflow", + "@model_maker_pip_deps//tensorflow_models/official/vision/dataloaders:tf_example_decoder", ], ) @@ -68,13 +75,18 @@ py_test( "//mediapipe/model_maker/python/vision/core:image_utils", "//mediapipe/model_maker/python/vision/core:test_utils", "//mediapipe/tasks/python/test:test_utils", + "@model_maker_pip_deps//tensorflow", ], ) py_library( name = "dataset_util", srcs = ["dataset_util.py"], - deps = ["//mediapipe/model_maker/python/core/data:cache_files"], + deps = [ + "//mediapipe/model_maker/python/core/data:cache_files", + "@model_maker_pip_deps//tensorflow", + "@model_maker_pip_deps//tensorflow_models/official/vision/data:tfrecord_lib", + ], ) py_test( @@ -85,18 +97,28 @@ py_test( ":dataset_util", "//mediapipe/model_maker/python/vision/core:test_utils", "//mediapipe/tasks/python/test:test_utils", + "@model_maker_pip_deps//tensorflow", ], ) py_library( name = "detection", srcs = ["detection.py"], + deps = [ + "@model_maker_pip_deps//tensorflow_models/official/vision/serving:detection", + ], ) py_test( name = "detection_test", srcs = ["detection_test.py"], - deps = [":detection"], + deps = [ + ":detection", + "@model_maker_pip_deps//tensorflow", + "@model_maker_pip_deps//tensorflow_models/official/core:config_definitions", + "@model_maker_pip_deps//tensorflow_models/official/vision/configs", + "@model_maker_pip_deps//tensorflow_models/official/vision/serving:detection", + ], ) py_library( @@ -110,7 +132,14 @@ py_library( py_library( name = "preprocessor", srcs = ["preprocessor.py"], - deps = [":model_spec"], + deps = [ + ":model_spec", + "@model_maker_pip_deps//tensorflow", + "@model_maker_pip_deps//tensorflow_models/official/vision/dataloaders:utils", + "@model_maker_pip_deps//tensorflow_models/official/vision/ops:anchor", + "@model_maker_pip_deps//tensorflow_models/official/vision/ops:box_ops", + "@model_maker_pip_deps//tensorflow_models/official/vision/ops:preprocess_ops", + ], ) py_test( @@ -120,6 +149,8 @@ py_test( ":model_spec", ":preprocessor", "//mediapipe/model_maker/python/vision/core:test_utils", + "@model_maker_pip_deps//absl/testing:parameterized", + "@model_maker_pip_deps//tensorflow", ], ) @@ -130,6 +161,16 @@ py_library( ":detection", ":model_options", ":model_spec", + "@model_maker_pip_deps//tensorflow", + "@model_maker_pip_deps//tensorflow_models/official/core:config_definitions", + "@model_maker_pip_deps//tensorflow_models/official/projects/qat/vision/configs:common", + "@model_maker_pip_deps//tensorflow_models/official/projects/qat/vision/modeling:factory", + "@model_maker_pip_deps//tensorflow_models/official/vision/configs", + "@model_maker_pip_deps//tensorflow_models/official/vision/losses:focal_loss", + "@model_maker_pip_deps//tensorflow_models/official/vision/losses:loss_utils", + "@model_maker_pip_deps//tensorflow_models/official/vision/modeling:factory", + "@model_maker_pip_deps//tensorflow_models/official/vision/modeling:retinanet_model", + "@model_maker_pip_deps//tensorflow_models/official/vision/modeling/layers:detection_generator", ], ) @@ -152,6 +193,8 @@ py_test( ":model_spec", ":preprocessor", "//mediapipe/tasks/python/test:test_utils", + "@model_maker_pip_deps//numpy", + "@model_maker_pip_deps//tensorflow", ], ) @@ -183,6 +226,8 @@ py_library( "//mediapipe/tasks/python/metadata/metadata_writers:metadata_info", "//mediapipe/tasks/python/metadata/metadata_writers:metadata_writer", "//mediapipe/tasks/python/metadata/metadata_writers:object_detector", + "@model_maker_pip_deps//tensorflow", + "@model_maker_pip_deps//tensorflow_models/official/vision/evaluation:coco_evaluator", ], ) @@ -195,6 +240,8 @@ py_test( deps = [ ":object_detector_import", "//mediapipe/tasks/python/test:test_utils", + "@model_maker_pip_deps//absl/testing:parameterized", + "@model_maker_pip_deps//tensorflow", ], ) diff --git a/mediapipe/model_maker/requirements_bazel.txt b/mediapipe/model_maker/requirements_bazel.txt new file mode 100644 index 0000000000..1fc0309629 --- /dev/null +++ b/mediapipe/model_maker/requirements_bazel.txt @@ -0,0 +1,10 @@ +absl-py +numpy<2 +opencv-python +tensorflow>=2.10,<2.16 +tensorflow-addons +tensorflow-datasets +tensorflow-hub +tensorflow-model-optimization<0.8.0 +tensorflow-text +tf-models-official>=2.13.2,<2.16.0 diff --git a/mediapipe/tasks/python/audio/core/BUILD b/mediapipe/tasks/python/audio/core/BUILD index b3c0076da7..aaa15274ff 100644 --- a/mediapipe/tasks/python/audio/core/BUILD +++ b/mediapipe/tasks/python/audio/core/BUILD @@ -26,6 +26,9 @@ py_library( py_library( name = "audio_record", srcs = ["audio_record.py"], + deps = [ + "@mediapipe_pip_deps//numpy", + ], ) py_library( diff --git a/mediapipe/tasks/python/components/containers/BUILD b/mediapipe/tasks/python/components/containers/BUILD index 8c80decb2a..c6da3dc8e1 100644 --- a/mediapipe/tasks/python/components/containers/BUILD +++ b/mediapipe/tasks/python/components/containers/BUILD @@ -21,6 +21,7 @@ licenses(["notice"]) py_library( name = "audio_data", srcs = ["audio_data.py"], + deps = ["@mediapipe_pip_deps//numpy"], ) py_library( @@ -112,5 +113,6 @@ py_library( deps = [ "//mediapipe/tasks/cc/components/containers/proto:embeddings_py_pb2", "//mediapipe/tasks/python/core:optional_dependencies", + "@mediapipe_pip_deps//numpy", ], ) diff --git a/mediapipe/tasks/python/components/utils/BUILD b/mediapipe/tasks/python/components/utils/BUILD index 64231fde03..b7ba04a53e 100644 --- a/mediapipe/tasks/python/components/utils/BUILD +++ b/mediapipe/tasks/python/components/utils/BUILD @@ -23,5 +23,8 @@ licenses(["notice"]) py_library( name = "cosine_similarity", srcs = ["cosine_similarity.py"], - deps = ["//mediapipe/tasks/python/components/containers:embedding_result"], + deps = [ + "//mediapipe/tasks/python/components/containers:embedding_result", + "@mediapipe_pip_deps//numpy", + ], ) diff --git a/mediapipe/tasks/python/genai/bundler/BUILD b/mediapipe/tasks/python/genai/bundler/BUILD index 2e54bb7409..982c887c19 100644 --- a/mediapipe/tasks/python/genai/bundler/BUILD +++ b/mediapipe/tasks/python/genai/bundler/BUILD @@ -33,5 +33,8 @@ py_test( name = "llm_bundler_test", srcs = ["llm_bundler_test.py"], srcs_version = "PY3", - deps = [":llm_bundler"], + deps = [ + ":llm_bundler", + "@mediapipe_pip_deps//absl/testing:absltest", + ], ) diff --git a/mediapipe/tasks/python/genai/converter/BUILD b/mediapipe/tasks/python/genai/converter/BUILD index f5ac209c8c..2913bbffad 100644 --- a/mediapipe/tasks/python/genai/converter/BUILD +++ b/mediapipe/tasks/python/genai/converter/BUILD @@ -44,6 +44,7 @@ py_library( ":converter_factory", ":quantization_util", "//mediapipe/python:_framework_bindings", + "@mediapipe_pip_deps//numpy", ], ) diff --git a/mediapipe/tasks/python/metadata/BUILD b/mediapipe/tasks/python/metadata/BUILD index 4aef7bd34e..6f772cc223 100644 --- a/mediapipe/tasks/python/metadata/BUILD +++ b/mediapipe/tasks/python/metadata/BUILD @@ -27,6 +27,7 @@ py_library( "//mediapipe/tasks/metadata:schema_py", "//mediapipe/tasks/python/metadata/flatbuffers_lib:_pywrap_flatbuffers", "@flatbuffers//:runtime_py", + "@mediapipe_pip_deps//numpy", ], ) @@ -36,5 +37,9 @@ py_binary( visibility = [ "//visibility:public", ], - deps = [":metadata"], + deps = [ + ":metadata", + "@mediapipe_pip_deps//absl:app", + "@mediapipe_pip_deps//absl/flags", + ], ) diff --git a/mediapipe/tasks/python/test/BUILD b/mediapipe/tasks/python/test/BUILD index fe02e8cdf2..19f419022b 100644 --- a/mediapipe/tasks/python/test/BUILD +++ b/mediapipe/tasks/python/test/BUILD @@ -30,5 +30,7 @@ py_library( deps = [ "//mediapipe/python:_framework_bindings", "@com_google_protobuf//:protobuf_python", + "@mediapipe_pip_deps//absl/flags", + "@mediapipe_pip_deps//six", ], ) diff --git a/mediapipe/tasks/python/test/audio/BUILD b/mediapipe/tasks/python/test/audio/BUILD index 48f7bffe4e..64e81761a0 100644 --- a/mediapipe/tasks/python/test/audio/BUILD +++ b/mediapipe/tasks/python/test/audio/BUILD @@ -33,6 +33,9 @@ py_test( "//mediapipe/tasks/python/components/containers:classification_result", "//mediapipe/tasks/python/core:base_options", "//mediapipe/tasks/python/test:test_utils", + "@mediapipe_pip_deps//absl/testing:absltest", + "@mediapipe_pip_deps//absl/testing:parameterized", + "@mediapipe_pip_deps//numpy", ], ) @@ -50,5 +53,8 @@ py_test( "//mediapipe/tasks/python/components/containers:audio_data", "//mediapipe/tasks/python/core:base_options", "//mediapipe/tasks/python/test:test_utils", + "@mediapipe_pip_deps//absl/testing:absltest", + "@mediapipe_pip_deps//absl/testing:parameterized", + "@mediapipe_pip_deps//numpy", ], ) diff --git a/mediapipe/tasks/python/test/audio/core/BUILD b/mediapipe/tasks/python/test/audio/core/BUILD index b7a8d6e1f0..88148f4a27 100644 --- a/mediapipe/tasks/python/test/audio/core/BUILD +++ b/mediapipe/tasks/python/test/audio/core/BUILD @@ -21,5 +21,10 @@ licenses(["notice"]) py_test( name = "audio_record_test", srcs = ["audio_record_test.py"], - deps = ["//mediapipe/tasks/python/audio/core:audio_record"], + deps = [ + "//mediapipe/tasks/python/audio/core:audio_record", + "@mediapipe_pip_deps//absl/testing:absltest", + "@mediapipe_pip_deps//absl/testing:parameterized", + "@mediapipe_pip_deps//numpy", + ], ) diff --git a/mediapipe/tasks/python/test/metadata/BUILD b/mediapipe/tasks/python/test/metadata/BUILD index ba72daf93c..01ad7f1af3 100644 --- a/mediapipe/tasks/python/test/metadata/BUILD +++ b/mediapipe/tasks/python/test/metadata/BUILD @@ -19,6 +19,9 @@ py_test( "//mediapipe/tasks/python/metadata", "//mediapipe/tasks/python/test:test_utils", "@flatbuffers//:runtime_py", + "@mediapipe_pip_deps//absl/testing:absltest", + "@mediapipe_pip_deps//absl/testing:parameterized", + "@mediapipe_pip_deps//six", ], ) @@ -27,5 +30,9 @@ py_test( srcs = ["metadata_parser_test.py"], python_version = "PY3", srcs_version = "PY2AND3", - deps = ["//mediapipe/tasks/python/metadata"], + deps = [ + "//mediapipe/tasks/python/metadata", + "@mediapipe_pip_deps//absl/testing:absltest", + "@mediapipe_pip_deps//absl/testing:parameterized", + ], ) diff --git a/mediapipe/tasks/python/test/metadata/metadata_writers/BUILD b/mediapipe/tasks/python/test/metadata/metadata_writers/BUILD index 863cc1a64a..71bba3b978 100644 --- a/mediapipe/tasks/python/test/metadata/metadata_writers/BUILD +++ b/mediapipe/tasks/python/test/metadata/metadata_writers/BUILD @@ -22,6 +22,8 @@ py_test( "//mediapipe/tasks/python/metadata/metadata_writers:metadata_info", "//mediapipe/tasks/python/test:test_utils", "@flatbuffers//:runtime_py", + "@mediapipe_pip_deps//absl/testing:absltest", + "@mediapipe_pip_deps//absl/testing:parameterized", ], ) @@ -37,6 +39,7 @@ py_test( "//mediapipe/tasks/python/metadata/metadata_writers:metadata_info", "//mediapipe/tasks/python/metadata/metadata_writers:metadata_writer", "//mediapipe/tasks/python/test:test_utils", + "@mediapipe_pip_deps//absl/testing:absltest", ], ) @@ -53,6 +56,8 @@ py_test( "//mediapipe/tasks/python/metadata/metadata_writers:image_classifier", "//mediapipe/tasks/python/metadata/metadata_writers:metadata_writer", "//mediapipe/tasks/python/test:test_utils", + "@mediapipe_pip_deps//absl/testing:absltest", + "@mediapipe_pip_deps//absl/testing:parameterized", ], ) @@ -67,13 +72,17 @@ py_test( "//mediapipe/tasks/python/metadata/metadata_writers:metadata_writer", "//mediapipe/tasks/python/metadata/metadata_writers:text_classifier", "//mediapipe/tasks/python/test:test_utils", + "@mediapipe_pip_deps//absl/testing:absltest", ], ) py_test( name = "model_asset_bundle_utils_test", srcs = ["model_asset_bundle_utils_test.py"], - deps = ["//mediapipe/tasks/python/metadata/metadata_writers:model_asset_bundle_utils"], + deps = [ + "//mediapipe/tasks/python/metadata/metadata_writers:model_asset_bundle_utils", + "@mediapipe_pip_deps//absl/testing:absltest", + ], ) py_test( @@ -90,6 +99,8 @@ py_test( "//mediapipe/tasks/python/metadata/metadata_writers:metadata_writer", "//mediapipe/tasks/python/metadata/metadata_writers:object_detector", "//mediapipe/tasks/python/test:test_utils", + "@mediapipe_pip_deps//absl/testing:absltest", + "@mediapipe_pip_deps//absl/testing:parameterized", ], ) @@ -105,6 +116,7 @@ py_test( "//mediapipe/tasks/python/metadata/metadata_writers:image_segmenter", "//mediapipe/tasks/python/metadata/metadata_writers:metadata_writer", "//mediapipe/tasks/python/test:test_utils", + "@mediapipe_pip_deps//absl/testing:absltest", ], ) @@ -118,5 +130,7 @@ py_test( deps = [ "//mediapipe/tasks/python/metadata/metadata_writers:face_stylizer", "//mediapipe/tasks/python/test:test_utils", + "@mediapipe_pip_deps//absl/testing:absltest", + "@mediapipe_pip_deps//absl/testing:parameterized", ], ) diff --git a/mediapipe/tasks/python/test/text/BUILD b/mediapipe/tasks/python/test/text/BUILD index 624e79f44c..cff2aa01aa 100644 --- a/mediapipe/tasks/python/test/text/BUILD +++ b/mediapipe/tasks/python/test/text/BUILD @@ -30,5 +30,7 @@ py_test( "//mediapipe/tasks/python/core:base_options", "//mediapipe/tasks/python/test:test_utils", "//mediapipe/tasks/python/text:language_detector", + "@mediapipe_pip_deps//absl/testing:absltest", + "@mediapipe_pip_deps//absl/testing:parameterized", ], ) diff --git a/mediapipe/tasks/python/test/vision/BUILD b/mediapipe/tasks/python/test/vision/BUILD index 7572d46bd3..062421df0b 100644 --- a/mediapipe/tasks/python/test/vision/BUILD +++ b/mediapipe/tasks/python/test/vision/BUILD @@ -36,6 +36,9 @@ py_test( "//mediapipe/tasks/python/vision:object_detector", "//mediapipe/tasks/python/vision/core:image_processing_options", "//mediapipe/tasks/python/vision/core:vision_task_running_mode", + "@mediapipe_pip_deps//absl/testing:absltest", + "@mediapipe_pip_deps//absl/testing:parameterized", + "@mediapipe_pip_deps//numpy", ], ) @@ -57,6 +60,9 @@ py_test( "//mediapipe/tasks/python/vision:image_classifier", "//mediapipe/tasks/python/vision/core:image_processing_options", "//mediapipe/tasks/python/vision/core:vision_task_running_mode", + "@mediapipe_pip_deps//absl/testing:absltest", + "@mediapipe_pip_deps//absl/testing:parameterized", + "@mediapipe_pip_deps//numpy", ], ) @@ -77,6 +83,9 @@ py_test( "//mediapipe/tasks/python/vision:image_embedder", "//mediapipe/tasks/python/vision/core:image_processing_options", "//mediapipe/tasks/python/vision/core:vision_task_running_mode", + "@mediapipe_pip_deps//absl/testing:absltest", + "@mediapipe_pip_deps//absl/testing:parameterized", + "@mediapipe_pip_deps//numpy", ], ) @@ -94,6 +103,9 @@ py_test( "//mediapipe/tasks/python/test:test_utils", "//mediapipe/tasks/python/vision:image_segmenter", "//mediapipe/tasks/python/vision/core:vision_task_running_mode", + "@mediapipe_pip_deps//absl/testing:absltest", + "@mediapipe_pip_deps//absl/testing:parameterized", + "@mediapipe_pip_deps//numpy", ], ) @@ -118,6 +130,8 @@ py_test( "//mediapipe/tasks/python/vision/core:image_processing_options", "//mediapipe/tasks/python/vision/core:vision_task_running_mode", "@com_google_protobuf//:protobuf_python", + "@mediapipe_pip_deps//absl/testing:absltest", + "@mediapipe_pip_deps//absl/testing:parameterized", ], ) @@ -143,6 +157,9 @@ py_test( "//mediapipe/tasks/python/vision/core:image_processing_options", "//mediapipe/tasks/python/vision/core:vision_task_running_mode", "@com_google_protobuf//:protobuf_python", + "@mediapipe_pip_deps//absl/testing:absltest", + "@mediapipe_pip_deps//absl/testing:parameterized", + "@mediapipe_pip_deps//numpy", ], ) @@ -167,6 +184,9 @@ py_test( "//mediapipe/tasks/python/vision/core:image_processing_options", "//mediapipe/tasks/python/vision/core:vision_task_running_mode", "@com_google_protobuf//:protobuf_python", + "@mediapipe_pip_deps//absl/testing:absltest", + "@mediapipe_pip_deps//absl/testing:parameterized", + "@mediapipe_pip_deps//numpy", ], ) @@ -191,6 +211,9 @@ py_test( "//mediapipe/tasks/python/vision/core:image_processing_options", "//mediapipe/tasks/python/vision/core:vision_task_running_mode", "@com_google_protobuf//:protobuf_python", + "@mediapipe_pip_deps//absl/testing:absltest", + "@mediapipe_pip_deps//absl/testing:parameterized", + "@mediapipe_pip_deps//numpy", ], ) @@ -212,6 +235,9 @@ py_test( "//mediapipe/tasks/python/vision/core:image_processing_options", "//mediapipe/tasks/python/vision/core:vision_task_running_mode", "@com_google_protobuf//:protobuf_python", + "@mediapipe_pip_deps//absl/testing:absltest", + "@mediapipe_pip_deps//absl/testing:parameterized", + "@mediapipe_pip_deps//numpy", ], ) @@ -230,6 +256,8 @@ py_test( "//mediapipe/tasks/python/test:test_utils", "//mediapipe/tasks/python/vision:face_aligner", "//mediapipe/tasks/python/vision/core:image_processing_options", + "@mediapipe_pip_deps//absl/testing:absltest", + "@mediapipe_pip_deps//absl/testing:parameterized", ], ) @@ -247,5 +275,7 @@ py_test( "//mediapipe/tasks/python/test:test_utils", "//mediapipe/tasks/python/vision:face_stylizer", "//mediapipe/tasks/python/vision/core:image_processing_options", + "@mediapipe_pip_deps//absl/testing:absltest", + "@mediapipe_pip_deps//absl/testing:parameterized", ], ) diff --git a/mediapipe/tasks/python/vision/BUILD b/mediapipe/tasks/python/vision/BUILD index 473f0b5798..c620990794 100644 --- a/mediapipe/tasks/python/vision/BUILD +++ b/mediapipe/tasks/python/vision/BUILD @@ -194,6 +194,7 @@ py_library( "//mediapipe/tasks/python/vision/core:base_vision_task_api", "//mediapipe/tasks/python/vision/core:image_processing_options", "//mediapipe/tasks/python/vision/core:vision_task_running_mode", + "@mediapipe_pip_deps//numpy", ], ) @@ -239,6 +240,7 @@ py_library( "//mediapipe/tasks/python/vision/core:base_vision_task_api", "//mediapipe/tasks/python/vision/core:image_processing_options", "//mediapipe/tasks/python/vision/core:vision_task_running_mode", + "@mediapipe_pip_deps//numpy", ], )