Added support for setting delegate in MPPBaseOptions
This commit is contained in:
parent
bc035d9146
commit
91488f0e57
|
@ -16,6 +16,17 @@
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MediaPipe Tasks delegate.
|
||||||
|
*/
|
||||||
|
typedef NS_ENUM(NSUInteger, MPPDelegate) {
|
||||||
|
/** CPU. */
|
||||||
|
MPPDelegateCPU,
|
||||||
|
|
||||||
|
/** GPU. */
|
||||||
|
MPPDelegateGPU
|
||||||
|
} NS_SWIFT_NAME(Delegate);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the base options that is used for creation of any type of task. It has fields with
|
* Holds the base options that is used for creation of any type of task. It has fields with
|
||||||
* important information acceleration configuration, TFLite model source etc.
|
* important information acceleration configuration, TFLite model source etc.
|
||||||
|
@ -23,9 +34,17 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
NS_SWIFT_NAME(BaseOptions)
|
NS_SWIFT_NAME(BaseOptions)
|
||||||
@interface MPPBaseOptions : NSObject <NSCopying>
|
@interface MPPBaseOptions : NSObject <NSCopying>
|
||||||
|
|
||||||
/** The path to the model asset to open and mmap in memory. */
|
/**
|
||||||
|
* The absolute path to a model asset file (a tflite model or a model asset bundle file) stored in the app bundle.
|
||||||
|
*/
|
||||||
@property(nonatomic, copy) NSString *modelAssetPath;
|
@property(nonatomic, copy) NSString *modelAssetPath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Device delegate to run the MediaPipe pipeline. If the delegate is not set, the default
|
||||||
|
* delegate CPU is used.
|
||||||
|
*/
|
||||||
|
@property(nonatomic) MPPDelegate delegate;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_END
|
NS_ASSUME_NONNULL_END
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
MPPBaseOptions *baseOptions = [[MPPBaseOptions alloc] init];
|
MPPBaseOptions *baseOptions = [[MPPBaseOptions alloc] init];
|
||||||
|
|
||||||
baseOptions.modelAssetPath = self.modelAssetPath;
|
baseOptions.modelAssetPath = self.modelAssetPath;
|
||||||
|
baseOptions.delegate = self.delegate;
|
||||||
|
|
||||||
return baseOptions;
|
return baseOptions;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,19 @@ using BaseOptionsProto = ::mediapipe::tasks::core::proto::BaseOptions;
|
||||||
if (self.modelAssetPath) {
|
if (self.modelAssetPath) {
|
||||||
baseOptionsProto->mutable_model_asset()->set_file_name(self.modelAssetPath.UTF8String);
|
baseOptionsProto->mutable_model_asset()->set_file_name(self.modelAssetPath.UTF8String);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch (self.delegate) {
|
||||||
|
case MPPDelegateCPU: {
|
||||||
|
baseOptionsProto->mutable_acceleration()->mutable_tflite();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MPPDelegateGPU: {
|
||||||
|
baseOptionsProto->mutable_acceleration()->mutable_gpu();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user