Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug Fix: iOS Duplicate Symbols Between MLImage and Vision Task Library #892

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions tensorflow_lite_support/ios/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,19 @@ strip_api_include_path_prefix(
"//tensorflow_lite_support/ios/task/text/qa:Sources/TFLBertQuestionAnswerer.h",
"//tensorflow_lite_support/ios/task/vision:sources/TFLImageClassifier.h",
"//tensorflow_lite_support/ios/task/vision:sources/TFLObjectDetector.h",
"//tensorflow_lite_support/ios/task/vision:sources/TFLImageSegmenter.h",
"//tensorflow_lite_support/ios/task/vision:sources/TFLImageSegmenter.h",
"//tensorflow_lite_support/ios/task/vision:sources/TFLImageSearcher.h",
"//tensorflow_lite_support/ios:sources/TFLCommon.h",
"//tensorflow_lite_support/ios/task/core:sources/TFLBaseOptions.h",
"//tensorflow_lite_support/ios/task/core:sources/TFLExternalFile.h",
"//tensorflow_lite_support/ios/task/processor:sources/TFLEmbeddingOptions.h",
"//tensorflow_lite_support/ios/task/processor:sources/TFLSearchOptions.h",
"//tensorflow_lite_support/ios/task/processor:sources/TFLClassificationOptions.h",
"//tensorflow_lite_support/ios/task/processor:sources/TFLCategory.h",
"//tensorflow_lite_support/ios/task/processor:sources/TFLClassificationResult.h",
"//tensorflow_lite_support/ios/task/processor:sources/TFLDetectionResult.h",
"//tensorflow_lite_support/ios/task/processor:sources/TFLSegmentationResult.h",
"//tensorflow_lite_support/odml/ios/image:apis/GMLImage.h",
"//tensorflow_lite_support/ios/task/processor:sources/TFLSegmentationResult.h",
"//tensorflow_lite_support/ios/task/processor:sources/TFLSearchResult.h",
"//tensorflow_lite_support/ios/task/audio/core:sources/TFLAudioFormat.h",
"//tensorflow_lite_support/ios/task/audio/core:sources/TFLFloatBuffer.h",
"//tensorflow_lite_support/ios/task/audio/core/audio_record:sources/TFLAudioRecord.h",
Expand Down Expand Up @@ -153,6 +157,10 @@ objc_library(
hdrs = [
"sources/TFLCommonCppUtils.h",
],
copts = [
"-ObjC++",
"-std=c++17",
],
module_name = "TFLCommonCppUtils",
deps = [
":TFLCommon",
Expand All @@ -168,24 +176,30 @@ objc_library(
ios_static_framework(
name = "TensorFlowLiteTaskVision_framework",
hdrs = [
":GMLImage.h",
":TFLBaseOptions.h",
":TFLExternalFile.h",
":TFLSearchOptions.h",
":TFLEmbeddingOptions.h",
":TFLCategory.h",
":TFLClassificationOptions.h",
":TFLClassificationResult.h",
":TFLCommon.h",
":TFLDetectionResult.h",
":TFLImageClassifier.h",
":TFLImageSegmenter.h",
":TFLImageSearcher.h",
":TFLObjectDetector.h",
":TFLSegmentationResult.h",
":TFLSearchResult.h"

],
bundle_name = "TensorFlowLiteTaskVision",
minimum_os_version = TFL_TASK_MINIMUM_OS_VERSION,
deps = [
"//tensorflow_lite_support/ios/task/vision:TFLImageClassifier",
"//tensorflow_lite_support/ios/task/vision:TFLImageSegmenter",
"//tensorflow_lite_support/ios/task/vision:TFLObjectDetector",
"//tensorflow_lite_support/ios/task/vision:TFLImageSearcher",
],
)

Expand Down Expand Up @@ -213,6 +227,7 @@ ios_static_framework(
":TFLAudioRecord.h",
":TFLAudioTensor.h",
":TFLBaseOptions.h",
":TFLExternalFile.h",
":TFLCategory.h",
":TFLClassificationOptions.h",
":TFLClassificationResult.h",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ Pod::Spec.new do |s|
s.library = 'c++'
s.frameworks = 'CoreMedia', 'Accelerate'
s.vendored_frameworks = 'Frameworks/TensorFlowLiteTaskVision.framework'
end
s.dependency 'MLImage', '~> 1.0.0-beta3'
end
2 changes: 1 addition & 1 deletion tensorflow_lite_support/ios/task/core/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ objc_library(
hdrs = [
"sources/TFLBaseOptions+CppHelpers.h",
],
module_name = "TFLBaseOptionsHelpers",
module_name = "TFLBaseOptionsCppHelpers",
deps = [
"//tensorflow_lite_support/cc/task/core/proto:base_options_proto_inc",
"//tensorflow_lite_support/ios/task/core:TFLBaseOptions",
Expand Down
12 changes: 7 additions & 5 deletions tensorflow_lite_support/ios/task/vision/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ objc_library(
"//tensorflow_lite_support/ios/task/processor:TFLClassificationResult",
"//tensorflow_lite_support/ios/task/processor:TFLClassificationResultHelpers",
"//tensorflow_lite_support/ios/task/vision/utils:GMLImageUtils",
"//tensorflow_lite_support/odml/ios/image:MLImage",
"//tensorflow_lite_support/ios/third_party_frameworks:MLImage",
],
)

Expand All @@ -46,8 +46,8 @@ objc_library(
"//tensorflow_lite_support/ios/task/processor:TFLClassificationOptionsHelpers",
"//tensorflow_lite_support/ios/task/processor:TFLDetectionResult",
"//tensorflow_lite_support/ios/task/processor:TFLDetectionResultHelpers",
"//tensorflow_lite_support/ios/task/vision/utils:GMLImageUtils",
"//tensorflow_lite_support/odml/ios/image:MLImage",
"//tensorflow_lite_support/ios/task/vision/utils:GMLImageUtils",
"//tensorflow_lite_support/ios/third_party_frameworks:MLImage",
],
)

Expand All @@ -69,7 +69,7 @@ objc_library(
"//tensorflow_lite_support/ios/task/processor:TFLSegmentationResult",
"//tensorflow_lite_support/ios/task/processor:TFLSegmentationResultHelpers",
"//tensorflow_lite_support/ios/task/vision/utils:GMLImageUtils",
"//tensorflow_lite_support/odml/ios/image:MLImage",
"//tensorflow_lite_support/ios/third_party_frameworks:MLImage",
],
)

Expand All @@ -95,5 +95,7 @@ objc_library(
"//tensorflow_lite_support/ios/task/processor:TFLSearchOptionsHelpers",
"//tensorflow_lite_support/ios/task/processor:TFLSearchResultHelpers",
"//tensorflow_lite_support/ios/task/vision/utils:GMLImageCppUtils",
],
"//tensorflow_lite_support/ios/third_party_frameworks:MLImage",
],

)
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#import "tensorflow_lite_support/ios/task/core/sources/TFLBaseOptions.h"
#import "tensorflow_lite_support/ios/task/processor/sources/TFLClassificationOptions.h"
#import "tensorflow_lite_support/ios/task/processor/sources/TFLClassificationResult.h"
#import "tensorflow_lite_support/odml/ios/image/apis/GMLImage.h"
#import <MLImage/MLImage.h>

NS_ASSUME_NONNULL_BEGIN

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#import "tensorflow_lite_support/ios/task/processor/sources/TFLEmbeddingOptions.h"
#import "tensorflow_lite_support/ios/task/processor/sources/TFLSearchOptions.h"
#import "tensorflow_lite_support/ios/task/processor/sources/TFLSearchResult.h"
#import "tensorflow_lite_support/odml/ios/image/apis/GMLImage.h"
#import <MLImage/MLImage.h>

NS_ASSUME_NONNULL_BEGIN

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#import <Foundation/Foundation.h>
#import "tensorflow_lite_support/ios/task/core/sources/TFLBaseOptions.h"
#import "tensorflow_lite_support/ios/task/processor/sources/TFLSegmentationResult.h"
#import "tensorflow_lite_support/odml/ios/image/apis/GMLImage.h"
#import <MLImage/GMLImage.h>

NS_ASSUME_NONNULL_BEGIN

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#import "tensorflow_lite_support/ios/task/core/sources/TFLBaseOptions.h"
#import "tensorflow_lite_support/ios/task/processor/sources/TFLClassificationOptions.h"
#import "tensorflow_lite_support/ios/task/processor/sources/TFLDetectionResult.h"
#import "tensorflow_lite_support/odml/ios/image/apis/GMLImage.h"
#import <MLImage/MLImage.h>

NS_ASSUME_NONNULL_BEGIN

Expand Down
6 changes: 3 additions & 3 deletions tensorflow_lite_support/ios/task/vision/utils/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ objc_library(
deps = [
"//tensorflow_lite_support/c/task/vision/core:frame_buffer",
"//tensorflow_lite_support/ios:TFLCommonUtils",
"//tensorflow_lite_support/odml/ios/image:MLImage",
],
"//tensorflow_lite_support/ios/third_party_frameworks:MLImage",
],
)

objc_library(
Expand All @@ -41,7 +41,7 @@ objc_library(
"//tensorflow_lite_support/cc/task/vision/core:frame_buffer",
"//tensorflow_lite_support/cc/task/vision/utils:frame_buffer_common_utils",
"//tensorflow_lite_support/ios:TFLCommonCppUtils",
"//tensorflow_lite_support/odml/ios/image:MLImage",
"//tensorflow_lite_support/ios/third_party_frameworks:MLImage",
"@com_google_absl//absl/strings:str_format",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "tensorflow_lite_support/cc/task/vision/core/frame_buffer.h"

#import "tensorflow_lite_support/odml/ios/image/apis/GMLImage.h"
#import <MLImage/MLImage.h>

NS_ASSUME_NONNULL_BEGIN

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "tensorflow_lite_support/c/task/vision/core/frame_buffer.h"

#import "tensorflow_lite_support/odml/ios/image/apis/GMLImage.h"
#import <MLImage/MLImage.h>

NS_ASSUME_NONNULL_BEGIN

Expand Down
10 changes: 10 additions & 0 deletions tensorflow_lite_support/ios/third_party_frameworks/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package(
default_visibility = ["//tensorflow_lite_support:internal"],
licenses = ["notice"], # Apache 2.0
)
load("@build_bazel_rules_apple//apple:apple.bzl", "apple_static_framework_import")

apple_static_framework_import(
name = "MLImage",
framework_imports = glob(["MLImage.framework/**"]),
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// Copyright 2021 Google LLC. 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.

#import <CoreMedia/CoreMedia.h>
#import <CoreVideo/CoreVideo.h>
#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

/** Types of image sources. */
typedef NSInteger GMLImageSourceType NS_TYPED_ENUM NS_SWIFT_NAME(MLImageSourceType);
/** Image source is a `UIImage`. */
static const GMLImageSourceType GMLImageSourceTypeImage = 0;
/** Image source is a `CVPixelBuffer`. */
static const GMLImageSourceType GMLImageSourceTypePixelBuffer = 1;
/** Image source is a `CMSampleBuffer`. */
static const GMLImageSourceType GMLImageSourceTypeSampleBuffer = 2;

/** An image used in on-device machine learning. */
NS_SWIFT_NAME(MLImage)
@interface GMLImage : NSObject

/** Width of the image in pixels. */
@property(nonatomic, readonly) CGFloat width;

/** Height of the image in pixels. */
@property(nonatomic, readonly) CGFloat height;

/**
* The display orientation of the image. If `imageSourceType` is `.image`, the default value is
* `image.imageOrientation`; otherwise the default value is `.up`.
*/
@property(nonatomic) UIImageOrientation orientation;

/** The type of the image source. */
@property(nonatomic, readonly) GMLImageSourceType imageSourceType;

/** The source image. `nil` if `imageSourceType` is not `.image`. */
@property(nonatomic, readonly, nullable) UIImage *image;

/** The source pixel buffer. `nil` if `imageSourceType` is not `.pixelBuffer`. */
@property(nonatomic, readonly, nullable) CVPixelBufferRef pixelBuffer;

/** The source sample buffer. `nil` if `imageSourceType` is not `.sampleBuffer`. */
@property(nonatomic, readonly, nullable) CMSampleBufferRef sampleBuffer;

/**
* Initializes an `MLImage` object with the given image.
*
* @param image The image to use as the source. Its `CGImage` property must not be `NULL`.
* @return A new `MLImage` instance with the given image as the source. `nil` if the given `image`
* is `nil` or invalid.
*/
- (nullable instancetype)initWithImage:(UIImage *)image NS_DESIGNATED_INITIALIZER;

/**
* Initializes an `MLImage` object with the given pixel buffer.
*
* @param pixelBuffer The pixel buffer to use as the source. It will be retained by the new
* `MLImage` instance for the duration of its lifecycle.
* @return A new `MLImage` instance with the given pixel buffer as the source. `nil` if the given
* pixel buffer is `nil` or invalid.
*/
- (nullable instancetype)initWithPixelBuffer:(CVPixelBufferRef)pixelBuffer
NS_DESIGNATED_INITIALIZER;

/**
* Initializes an `MLImage` object with the given sample buffer.
*
* @param sampleBuffer The sample buffer to use as the source. It will be retained by the new
* `MLImage` instance for the duration of its lifecycle. The sample buffer must be based on a
* pixel buffer (not compressed data). In practice, it should be the video output of the camera
* on an iOS device, not other arbitrary types of `CMSampleBuffer`s.
* @return A new `MLImage` instance with the given sample buffer as the source. `nil` if the given
* sample buffer is `nil` or invalid.
*/
- (nullable instancetype)initWithSampleBuffer:(CMSampleBufferRef)sampleBuffer
NS_DESIGNATED_INITIALIZER;

/** Unavailable. */
- (instancetype)init NS_UNAVAILABLE;

@end

NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#import "GMLImage.h"
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
framework module MLImage {
umbrella header "MLImage.h"
export *
module * { export * }
link framework "CoreGraphics"
link framework "CoreMedia"
link framework "CoreVideo"
link framework "UIKit"
}