diff --git a/mediapipe/python/BUILD b/mediapipe/python/BUILD index 9fe21ab9e..33667d18e 100644 --- a/mediapipe/python/BUILD +++ b/mediapipe/python/BUILD @@ -86,7 +86,7 @@ cc_library( name = "builtin_task_graphs", deps = [ "//mediapipe/tasks/cc/vision/object_detector:object_detector_graph", - "//mediapipe/tasks/cc/vision/image_classification:image_classifier_graph", + "//mediapipe/tasks/cc/vision/image_classifier:image_classifier_graph", ], ) diff --git a/mediapipe/tasks/python/components/proto/BUILD b/mediapipe/tasks/python/components/proto/BUILD new file mode 100644 index 000000000..7814ec675 --- /dev/null +++ b/mediapipe/tasks/python/components/proto/BUILD @@ -0,0 +1,29 @@ +# Copyright 2022 The MediaPipe Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Placeholder for internal Python strict library compatibility macro. + +package(default_visibility = ["//mediapipe/tasks:internal"]) + +licenses(["notice"]) + +py_library( + name = "classifier_options", + srcs = ["classifier_options.py"], + deps = [ + "//mediapipe/tasks/cc/components/proto:classifier_options_py_pb2", + "//mediapipe/tasks/python/core:optional_dependencies", + ], +) + diff --git a/mediapipe/tasks/python/components/classifier_options.py b/mediapipe/tasks/python/components/proto/classifier_options.py similarity index 100% rename from mediapipe/tasks/python/components/classifier_options.py rename to mediapipe/tasks/python/components/proto/classifier_options.py diff --git a/mediapipe/tasks/python/test/vision/image_classification_test.py b/mediapipe/tasks/python/test/vision/image_classification_test.py index 0d7f9e7f0..08d850dab 100644 --- a/mediapipe/tasks/python/test/vision/image_classification_test.py +++ b/mediapipe/tasks/python/test/vision/image_classification_test.py @@ -99,11 +99,11 @@ class ImageClassifierTest(parameterized.TestCase): expected_classification_result): # Creates classifier. if model_file_type is ModelFileType.FILE_NAME: - base_options = _BaseOptions(file_name=self.model_path) + base_options = _BaseOptions(model_asset_path=self.model_path) elif model_file_type is ModelFileType.FILE_CONTENT: with open(self.model_path, 'rb') as f: model_content = f.read() - base_options = _BaseOptions(file_content=model_content) + base_options = _BaseOptions(model_asset_buffer=model_content) else: # Should never happen raise ValueError('model_file_type is invalid.') diff --git a/mediapipe/tasks/python/vision/BUILD b/mediapipe/tasks/python/vision/BUILD index 40caf129f..5e5bfe3ba 100644 --- a/mediapipe/tasks/python/vision/BUILD +++ b/mediapipe/tasks/python/vision/BUILD @@ -46,8 +46,8 @@ py_library( "//mediapipe/python:_framework_bindings", "//mediapipe/python:packet_creator", "//mediapipe/python:packet_getter", - "//mediapipe/tasks/cc/vision/image_classification:image_classifier_options_py_pb2", - "//mediapipe/tasks/python/components:classifier_options", + "//mediapipe/tasks/cc/vision/image_classifier/proto:image_classifier_options_py_pb2", + "//mediapipe/tasks/python/components/proto:classifier_options", "//mediapipe/tasks/python/components/containers:classifications", "//mediapipe/tasks/python/core:base_options", "//mediapipe/tasks/python/core:optional_dependencies", diff --git a/mediapipe/tasks/python/vision/image_classification.py b/mediapipe/tasks/python/vision/image_classification.py index f08da9f2b..c240ffedf 100644 --- a/mediapipe/tasks/python/vision/image_classification.py +++ b/mediapipe/tasks/python/vision/image_classification.py @@ -21,8 +21,8 @@ from mediapipe.python import packet_getter from mediapipe.python._framework_bindings import image as image_module from mediapipe.python._framework_bindings import packet as packet_module from mediapipe.python._framework_bindings import task_runner as task_runner_module -from mediapipe.tasks.cc.vision.image_classification import image_classifier_options_pb2 -from mediapipe.tasks.python.components import classifier_options +from mediapipe.tasks.cc.vision.image_classifier.proto import image_classifier_options_pb2 +from mediapipe.tasks.python.components.proto import classifier_options from mediapipe.tasks.python.components.containers import classifications as classifications_module from mediapipe.tasks.python.core import base_options as base_options_module from mediapipe.tasks.python.core import task_info as task_info_module @@ -104,7 +104,7 @@ class ImageClassifier(base_vision_task_api.BaseVisionTaskApi): file such as invalid file path. RuntimeError: If other types of error occurred. """ - base_options = _BaseOptions(file_name=model_path) + base_options = _BaseOptions(model_asset_path=model_path) options = ImageClassifierOptions( base_options=base_options, running_mode=_RunningMode.IMAGE) return cls.create_from_options(options)