Skip to content

Commit 28c31eb

Browse files
whhonecopybara-github
authored andcommitted
[mediapipe] build vision and image_generator tasks with exact dependencies
PiperOrigin-RevId: 730644662
1 parent bb31bd1 commit 28c31eb

File tree

5 files changed

+119
-80
lines changed

5 files changed

+119
-80
lines changed

mediapipe/tasks/java/com/google/mediapipe/tasks/mediapipe_tasks_aar.bzl

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -207,73 +207,6 @@ def mediapipe_tasks_core_aar(name, srcs, manifest):
207207
}),
208208
)
209209

210-
def mediapipe_tasks_vision_aar(name, srcs, native_library):
211-
"""Builds medaipipe tasks vision AAR.
212-
213-
Args:
214-
name: The bazel target name.
215-
srcs: MediaPipe Vision Tasks' source files.
216-
native_library: The native library that contains vision tasks' graph and calculators.
217-
"""
218-
219-
native.genrule(
220-
name = name + "tasks_manifest_generator",
221-
outs = ["AndroidManifest.xml"],
222-
cmd = """
223-
cat > $(OUTS) <<EOF
224-
<?xml version="1.0" encoding="utf-8"?>
225-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
226-
package="com.google.mediapipe.tasks.vision">
227-
<uses-sdk
228-
android:minSdkVersion="24"
229-
android:targetSdkVersion="34" />
230-
</manifest>
231-
EOF
232-
""",
233-
)
234-
235-
_mediapipe_tasks_aar(
236-
name = name,
237-
srcs = srcs,
238-
manifest = "AndroidManifest.xml",
239-
java_proto_lite_targets = _CORE_TASKS_JAVA_PROTO_LITE_TARGETS + _VISION_TASKS_JAVA_PROTO_LITE_TARGETS + [
240-
"//mediapipe/tasks/cc/vision/image_segmenter/calculators:tensors_to_segmentation_calculator_java_proto_lite",
241-
],
242-
native_library = native_library,
243-
)
244-
245-
def mediapipe_tasks_vision_image_generator_aar(name, srcs, native_library):
246-
"""Builds medaipipe tasks vision image generator AAR.
247-
248-
Args:
249-
name: The bazel target name.
250-
srcs: MediaPipe Vision Tasks' source files.
251-
native_library: The native library that contains image generator task's graph and calculators.
252-
"""
253-
254-
native.genrule(
255-
name = name + "tasks_manifest_generator",
256-
outs = ["AndroidManifest.xml"],
257-
cmd = """
258-
cat > $(OUTS) <<EOF
259-
<?xml version="1.0" encoding="utf-8"?>
260-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
261-
package="com.google.mediapipe.tasks.vision.imagegenerator">
262-
<uses-sdk
263-
android:minSdkVersion="24"
264-
android:targetSdkVersion="34" />
265-
</manifest>
266-
EOF
267-
""",
268-
)
269-
_mediapipe_tasks_aar(
270-
name = name,
271-
srcs = srcs,
272-
manifest = "AndroidManifest.xml",
273-
java_proto_lite_targets = _CORE_TASKS_JAVA_PROTO_LITE_TARGETS + _VISION_TASKS_IMAGE_GENERATOR_JAVA_PROTO_LITE_TARGETS,
274-
native_library = native_library,
275-
)
276-
277210
def _mediapipe_tasks_aar(name, srcs, manifest, java_proto_lite_targets, native_library):
278211
"""Builds medaipipe tasks AAR."""
279212
deps = java_proto_lite_targets + [native_library] + [
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.google.mediapipe.tasks.vision">
4+
<uses-sdk android:minSdkVersion="24"
5+
android:targetSdkVersion="34" />
6+
</manifest>

mediapipe/tasks/java/com/google/mediapipe/tasks/vision/BUILD

Lines changed: 65 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
load("//mediapipe/tasks/java/com/google/mediapipe/tasks:mediapipe_tasks_aar.bzl", "mediapipe_tasks_vision_aar")
15+
load("//mediapipe/tasks/java/com/google/mediapipe/tasks:mediapipe_tasks_aar.bzl", "mediapipe_build_aar_with_jni")
1616

1717
licenses(["notice"])
1818

@@ -462,13 +462,74 @@ android_library(
462462
],
463463
)
464464

465-
mediapipe_tasks_vision_aar(
466-
name = "tasks_vision",
465+
android_library(
466+
name = "tasks_vision_aar_library",
467467
srcs = glob(
468468
["**/*.java"],
469469
exclude = [
470470
"imagegenerator/**",
471471
],
472472
),
473-
native_library = ":libmediapipe_tasks_vision_jni_lib",
473+
manifest = "AndroidManifest.xml",
474+
deps = [
475+
":libmediapipe_tasks_vision_jni_lib",
476+
"//mediapipe/framework:calculator_java_proto_lite",
477+
"//mediapipe/framework:calculator_options_java_proto_lite",
478+
"//mediapipe/framework/formats:classification_java_proto_lite",
479+
"//mediapipe/framework/formats:detection_java_proto_lite",
480+
"//mediapipe/framework/formats:landmark_java_proto_lite",
481+
"//mediapipe/framework/formats:matrix_data_java_proto_lite",
482+
"//mediapipe/framework/formats:rect_java_proto_lite",
483+
"//mediapipe/java/com/google/mediapipe/framework:android_framework_no_mff",
484+
"//mediapipe/java/com/google/mediapipe/framework/image",
485+
"//mediapipe/tasks/cc/components/containers/proto:classifications_java_proto_lite",
486+
"//mediapipe/tasks/cc/components/containers/proto:embeddings_java_proto_lite",
487+
"//mediapipe/tasks/cc/components/processors/proto:classifier_options_java_proto_lite",
488+
"//mediapipe/tasks/cc/components/processors/proto:embedder_options_java_proto_lite",
489+
"//mediapipe/tasks/cc/core/proto:base_options_java_proto_lite",
490+
"//mediapipe/tasks/cc/vision/face_detector/proto:face_detector_graph_options_java_proto_lite",
491+
"//mediapipe/tasks/cc/vision/face_geometry/proto:face_geometry_java_proto_lite",
492+
"//mediapipe/tasks/cc/vision/face_landmarker/proto:face_landmarker_graph_options_java_proto_lite",
493+
"//mediapipe/tasks/cc/vision/face_landmarker/proto:face_landmarks_detector_graph_options_java_proto_lite",
494+
"//mediapipe/tasks/cc/vision/face_stylizer/proto:face_stylizer_graph_options_java_proto_lite",
495+
"//mediapipe/tasks/cc/vision/gesture_recognizer/proto:gesture_classifier_graph_options_java_proto_lite",
496+
"//mediapipe/tasks/cc/vision/gesture_recognizer/proto:gesture_recognizer_graph_options_java_proto_lite",
497+
"//mediapipe/tasks/cc/vision/gesture_recognizer/proto:hand_gesture_recognizer_graph_options_java_proto_lite",
498+
"//mediapipe/tasks/cc/vision/hand_detector/proto:hand_detector_graph_options_java_proto_lite",
499+
"//mediapipe/tasks/cc/vision/hand_landmarker/proto:hand_landmarker_graph_options_java_proto_lite",
500+
"//mediapipe/tasks/cc/vision/hand_landmarker/proto:hand_landmarks_detector_graph_options_java_proto_lite",
501+
"//mediapipe/tasks/cc/vision/holistic_landmarker/proto:holistic_landmarker_graph_options_java_proto_lite",
502+
"//mediapipe/tasks/cc/vision/image_classifier/proto:image_classifier_graph_options_java_proto_lite",
503+
"//mediapipe/tasks/cc/vision/image_embedder/proto:image_embedder_graph_options_java_proto_lite",
504+
"//mediapipe/tasks/cc/vision/image_segmenter/calculators:tensors_to_segmentation_calculator_java_proto_lite",
505+
"//mediapipe/tasks/cc/vision/image_segmenter/proto:image_segmenter_graph_options_java_proto_lite",
506+
"//mediapipe/tasks/cc/vision/image_segmenter/proto:segmenter_options_java_proto_lite",
507+
"//mediapipe/tasks/cc/vision/object_detector/proto:object_detector_options_java_proto_lite",
508+
"//mediapipe/tasks/cc/vision/pose_detector/proto:pose_detector_graph_options_java_proto_lite",
509+
"//mediapipe/tasks/cc/vision/pose_landmarker/proto:pose_landmarker_graph_options_java_proto_lite",
510+
"//mediapipe/tasks/cc/vision/pose_landmarker/proto:pose_landmarks_detector_graph_options_java_proto_lite",
511+
"//mediapipe/tasks/java/com/google/mediapipe/tasks/components/containers:category",
512+
"//mediapipe/tasks/java/com/google/mediapipe/tasks/components/containers:classificationresult",
513+
"//mediapipe/tasks/java/com/google/mediapipe/tasks/components/containers:connection",
514+
"//mediapipe/tasks/java/com/google/mediapipe/tasks/components/containers:detection",
515+
"//mediapipe/tasks/java/com/google/mediapipe/tasks/components/containers:embedding",
516+
"//mediapipe/tasks/java/com/google/mediapipe/tasks/components/containers:embeddingresult",
517+
"//mediapipe/tasks/java/com/google/mediapipe/tasks/components/containers:landmark",
518+
"//mediapipe/tasks/java/com/google/mediapipe/tasks/components/containers:normalized_landmark",
519+
"//mediapipe/tasks/java/com/google/mediapipe/tasks/components/containers:normalizedkeypoint",
520+
"//mediapipe/tasks/java/com/google/mediapipe/tasks/components/processors:classifieroptions",
521+
"//mediapipe/tasks/java/com/google/mediapipe/tasks/components/utils:cosinesimilarity",
522+
"//mediapipe/tasks/java/com/google/mediapipe/tasks/core:core_java",
523+
"//mediapipe/util:color_java_proto_lite",
524+
"//mediapipe/util:render_data_java_proto_lite",
525+
"//third_party:any_java_proto",
526+
"//third_party:autovalue",
527+
"@maven//:androidx_annotation_annotation",
528+
"@maven//:com_google_guava_guava",
529+
],
530+
)
531+
532+
mediapipe_build_aar_with_jni(
533+
name = "tasks_vision",
534+
android_library = ":tasks_vision_aar_library",
474535
)
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
package="com.google.mediapipe.tasks.vision.imagegenerator">
4-
5-
<uses-sdk android:minSdkVersion="24"
6-
android:targetSdkVersion="34" />
7-
3+
package="com.google.mediapipe.tasks.vision.imagegenerator">
4+
<uses-sdk android:minSdkVersion="24"
5+
android:targetSdkVersion="34" />
86
</manifest>

mediapipe/tasks/java/com/google/mediapipe/tasks/vision/imagegenerator/BUILD

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ load(
1616
"//mediapipe/framework/tool:mediapipe_files.bzl",
1717
"mediapipe_files",
1818
)
19-
load("//mediapipe/tasks/java/com/google/mediapipe/tasks:mediapipe_tasks_aar.bzl", "mediapipe_tasks_vision_image_generator_aar")
19+
load("//mediapipe/tasks/java/com/google/mediapipe/tasks:mediapipe_tasks_aar.bzl", "mediapipe_build_aar_with_jni")
2020

2121
licenses(["notice"])
2222

@@ -86,12 +86,53 @@ android_library(
8686
],
8787
)
8888

89-
mediapipe_tasks_vision_image_generator_aar(
90-
name = "tasks_vision_image_generator",
89+
android_library(
90+
name = "tasks_vision_image_generator_aar_library",
9191
srcs = glob(["**/*.java"]) + [
9292
"//mediapipe/tasks/java/com/google/mediapipe/tasks/vision:core_java_src",
9393
"//mediapipe/tasks/java/com/google/mediapipe/tasks/vision:face_landmarker_java_src",
9494
"//mediapipe/tasks/java/com/google/mediapipe/tasks/vision:image_segmenter_java_src",
9595
],
96-
native_library = ":libmediapipe_tasks_vision_image_generator_jni_lib",
96+
manifest = "AndroidManifest.xml",
97+
deps = [
98+
":libmediapipe_tasks_vision_image_generator_jni_lib",
99+
"//mediapipe/framework:calculator_java_proto_lite",
100+
"//mediapipe/framework:calculator_options_java_proto_lite",
101+
"//mediapipe/framework/formats:classification_java_proto_lite",
102+
"//mediapipe/framework/formats:landmark_java_proto_lite",
103+
"//mediapipe/framework/formats:matrix_data_java_proto_lite",
104+
"//mediapipe/framework/formats:rect_java_proto_lite",
105+
"//mediapipe/java/com/google/mediapipe/framework:android_framework_no_mff",
106+
"//mediapipe/java/com/google/mediapipe/framework/image",
107+
"//mediapipe/tasks/cc/core/proto:base_options_java_proto_lite",
108+
"//mediapipe/tasks/cc/core/proto:external_file_java_proto_lite",
109+
"//mediapipe/tasks/cc/vision/face_detector/proto:face_detector_graph_options_java_proto_lite",
110+
"//mediapipe/tasks/cc/vision/face_geometry/proto:face_geometry_java_proto_lite",
111+
"//mediapipe/tasks/cc/vision/face_landmarker/proto:face_landmarker_graph_options_java_proto_lite",
112+
"//mediapipe/tasks/cc/vision/face_landmarker/proto:face_landmarks_detector_graph_options_java_proto_lite",
113+
"//mediapipe/tasks/cc/vision/image_generator/diffuser:stable_diffusion_iterate_calculator_java_proto_lite",
114+
"//mediapipe/tasks/cc/vision/image_generator/proto:conditioned_image_graph_options_java_proto_lite",
115+
"//mediapipe/tasks/cc/vision/image_generator/proto:control_plugin_graph_options_java_proto_lite",
116+
"//mediapipe/tasks/cc/vision/image_generator/proto:image_generator_graph_options_java_proto_lite",
117+
"//mediapipe/tasks/cc/vision/image_segmenter/calculators:tensors_to_segmentation_calculator_java_proto_lite",
118+
"//mediapipe/tasks/cc/vision/image_segmenter/proto:image_segmenter_graph_options_java_proto_lite",
119+
"//mediapipe/tasks/cc/vision/image_segmenter/proto:segmenter_options_java_proto_lite",
120+
"//mediapipe/tasks/java/com/google/mediapipe/tasks/components/containers:category",
121+
"//mediapipe/tasks/java/com/google/mediapipe/tasks/components/containers:connection",
122+
"//mediapipe/tasks/java/com/google/mediapipe/tasks/components/containers:normalized_landmark",
123+
"//mediapipe/tasks/java/com/google/mediapipe/tasks/core:core_java",
124+
"//mediapipe/tasks/java/com/google/mediapipe/tasks/vision:core_java",
125+
"//mediapipe/tasks/java/com/google/mediapipe/tasks/vision:facelandmarker",
126+
"//mediapipe/tasks/java/com/google/mediapipe/tasks/vision:imagesegmenter_java",
127+
"//third_party:any_java_proto",
128+
"//third_party:autovalue",
129+
"//third_party/java/protobuf:protobuf_lite",
130+
"@maven//:androidx_annotation_annotation",
131+
"@maven//:com_google_guava_guava",
132+
],
133+
)
134+
135+
mediapipe_build_aar_with_jni(
136+
name = "tasks_vision_image_generator",
137+
android_library = ":tasks_vision_image_generator_aar_library",
97138
)

0 commit comments

Comments
 (0)