Skip to content

Commit

Permalink
Add python pip deps to WORKSPACE
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 682085450
  • Loading branch information
joezoug authored and copybara-github committed Oct 4, 2024
1 parent dab7439 commit a687684
Show file tree
Hide file tree
Showing 26 changed files with 324 additions and 23 deletions.
14 changes: 14 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 4 additions & 0 deletions mediapipe/model_maker/python/core/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
)
30 changes: 26 additions & 4 deletions mediapipe/model_maker/python/core/data/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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",
],
)
4 changes: 4 additions & 0 deletions mediapipe/model_maker/python/core/tasks/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
)

Expand All @@ -35,6 +36,7 @@ py_test(
deps = [
":custom_model",
"//mediapipe/model_maker/python/core/utils:test_util",
"@model_maker_pip_deps//tensorflow",
],
)

Expand All @@ -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",
],
)

Expand All @@ -56,5 +59,6 @@ py_test(
deps = [
":classifier",
"//mediapipe/model_maker/python/core/utils:test_util",
"@model_maker_pip_deps//tensorflow",
],
)
42 changes: 38 additions & 4 deletions mediapipe/model_maker/python/core/utils/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
)

Expand All @@ -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",
],
)

Expand All @@ -52,6 +56,8 @@ py_test(
":model_util",
":quantization",
":test_util",
"@model_maker_pip_deps//absl/testing:parameterized",
"@model_maker_pip_deps//tensorflow",
],
)

Expand All @@ -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(
Expand All @@ -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",
],
)

Expand All @@ -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",
],
)

Expand All @@ -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",
],
)

######################################################################
Expand All @@ -113,20 +134,31 @@ 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(
name = "quantization",
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(
Expand All @@ -135,5 +167,7 @@ py_test(
deps = [
":quantization",
":test_util",
"@model_maker_pip_deps//absl/testing:parameterized",
"@model_maker_pip_deps//tensorflow",
],
)
34 changes: 33 additions & 1 deletion mediapipe/model_maker/python/text/text_classifier/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ py_test(
":hyperparameters",
":model_options",
":model_spec",
"@model_maker_pip_deps//tensorflow",
],
)

Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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",
],
)

Expand All @@ -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",
],
)

Expand All @@ -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",
],
)

Expand Down Expand Up @@ -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",
],
)

Expand All @@ -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",
],
)

Expand All @@ -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",
],
)

Expand Down
Loading

0 comments on commit a687684

Please sign in to comment.