|
| 1 | +// |
| 2 | +// CoremlEncoder.h |
| 3 | +// |
| 4 | +// This file was automatically generated and should not be edited. |
| 5 | +// |
| 6 | + |
| 7 | +#import <Foundation/Foundation.h> |
| 8 | +#import <CoreML/CoreML.h> |
| 9 | +#include <stdint.h> |
| 10 | +#include <os/log.h> |
| 11 | + |
| 12 | +NS_ASSUME_NONNULL_BEGIN |
| 13 | + |
| 14 | + |
| 15 | +/// Model Prediction Input Type |
| 16 | +API_AVAILABLE(macos(10.15), ios(13.0), watchos(6.0), tvos(13.0)) __attribute__((visibility("hidden"))) |
| 17 | +@interface CoremlEncoderInput : NSObject<MLFeatureProvider> |
| 18 | + |
| 19 | +/// melSegment as 1 × 80 × 3000 3-dimensional array of floats |
| 20 | +@property (readwrite, nonatomic, strong) MLMultiArray * melSegment; |
| 21 | +- (instancetype)init NS_UNAVAILABLE; |
| 22 | +- (instancetype)initWithMelSegment:(MLMultiArray *)melSegment NS_DESIGNATED_INITIALIZER; |
| 23 | + |
| 24 | +@end |
| 25 | + |
| 26 | + |
| 27 | +/// Model Prediction Output Type |
| 28 | +API_AVAILABLE(macos(10.15), ios(13.0), watchos(6.0), tvos(13.0)) __attribute__((visibility("hidden"))) |
| 29 | +@interface CoremlEncoderOutput : NSObject<MLFeatureProvider> |
| 30 | + |
| 31 | +/// output as multidimensional array of floats |
| 32 | +@property (readwrite, nonatomic, strong) MLMultiArray * output; |
| 33 | +- (instancetype)init NS_UNAVAILABLE; |
| 34 | +- (instancetype)initWithOutput:(MLMultiArray *)output NS_DESIGNATED_INITIALIZER; |
| 35 | + |
| 36 | +@end |
| 37 | + |
| 38 | + |
| 39 | +/// Class for model loading and prediction |
| 40 | +API_AVAILABLE(macos(10.15), ios(13.0), watchos(6.0), tvos(13.0)) __attribute__((visibility("hidden"))) |
| 41 | +@interface CoremlEncoder : NSObject |
| 42 | +@property (readonly, nonatomic, nullable) MLModel * model; |
| 43 | + |
| 44 | +/** |
| 45 | + URL of the underlying .mlmodelc directory. |
| 46 | +*/ |
| 47 | ++ (nullable NSURL *)URLOfModelInThisBundle; |
| 48 | + |
| 49 | +/** |
| 50 | + Initialize CoremlEncoder instance from an existing MLModel object. |
| 51 | +
|
| 52 | + Usually the application does not use this initializer unless it makes a subclass of CoremlEncoder. |
| 53 | + Such application may want to use `-[MLModel initWithContentsOfURL:configuration:error:]` and `+URLOfModelInThisBundle` to create a MLModel object to pass-in. |
| 54 | +*/ |
| 55 | +- (instancetype)initWithMLModel:(MLModel *)model NS_DESIGNATED_INITIALIZER; |
| 56 | + |
| 57 | +/** |
| 58 | + Initialize CoremlEncoder instance with the model in this bundle. |
| 59 | +*/ |
| 60 | +- (nullable instancetype)init; |
| 61 | + |
| 62 | +/** |
| 63 | + Initialize CoremlEncoder instance with the model in this bundle. |
| 64 | +
|
| 65 | + @param configuration The model configuration object |
| 66 | + @param error If an error occurs, upon return contains an NSError object that describes the problem. If you are not interested in possible errors, pass in NULL. |
| 67 | +*/ |
| 68 | +- (nullable instancetype)initWithConfiguration:(MLModelConfiguration *)configuration error:(NSError * _Nullable __autoreleasing * _Nullable)error; |
| 69 | + |
| 70 | +/** |
| 71 | + Initialize CoremlEncoder instance from the model URL. |
| 72 | +
|
| 73 | + @param modelURL URL to the .mlmodelc directory for CoremlEncoder. |
| 74 | + @param error If an error occurs, upon return contains an NSError object that describes the problem. If you are not interested in possible errors, pass in NULL. |
| 75 | +*/ |
| 76 | +- (nullable instancetype)initWithContentsOfURL:(NSURL *)modelURL error:(NSError * _Nullable __autoreleasing * _Nullable)error; |
| 77 | + |
| 78 | +/** |
| 79 | + Initialize CoremlEncoder instance from the model URL. |
| 80 | +
|
| 81 | + @param modelURL URL to the .mlmodelc directory for CoremlEncoder. |
| 82 | + @param configuration The model configuration object |
| 83 | + @param error If an error occurs, upon return contains an NSError object that describes the problem. If you are not interested in possible errors, pass in NULL. |
| 84 | +*/ |
| 85 | +- (nullable instancetype)initWithContentsOfURL:(NSURL *)modelURL configuration:(MLModelConfiguration *)configuration error:(NSError * _Nullable __autoreleasing * _Nullable)error; |
| 86 | + |
| 87 | +/** |
| 88 | + Construct CoremlEncoder instance asynchronously with configuration. |
| 89 | + Model loading may take time when the model content is not immediately available (e.g. encrypted model). Use this factory method especially when the caller is on the main thread. |
| 90 | +
|
| 91 | + @param configuration The model configuration |
| 92 | + @param handler When the model load completes successfully or unsuccessfully, the completion handler is invoked with a valid CoremlEncoder instance or NSError object. |
| 93 | +*/ |
| 94 | ++ (void)loadWithConfiguration:(MLModelConfiguration *)configuration completionHandler:(void (^)(CoremlEncoder * _Nullable model, NSError * _Nullable error))handler API_AVAILABLE(macos(11.0), ios(14.0), watchos(7.0), tvos(14.0)) __attribute__((visibility("hidden"))); |
| 95 | + |
| 96 | +/** |
| 97 | + Construct CoremlEncoder instance asynchronously with URL of .mlmodelc directory and optional configuration. |
| 98 | +
|
| 99 | + Model loading may take time when the model content is not immediately available (e.g. encrypted model). Use this factory method especially when the caller is on the main thread. |
| 100 | +
|
| 101 | + @param modelURL The model URL. |
| 102 | + @param configuration The model configuration |
| 103 | + @param handler When the model load completes successfully or unsuccessfully, the completion handler is invoked with a valid CoremlEncoder instance or NSError object. |
| 104 | +*/ |
| 105 | ++ (void)loadContentsOfURL:(NSURL *)modelURL configuration:(MLModelConfiguration *)configuration completionHandler:(void (^)(CoremlEncoder * _Nullable model, NSError * _Nullable error))handler API_AVAILABLE(macos(11.0), ios(14.0), watchos(7.0), tvos(14.0)) __attribute__((visibility("hidden"))); |
| 106 | + |
| 107 | +/** |
| 108 | + Make a prediction using the standard interface |
| 109 | + @param input an instance of CoremlEncoderInput to predict from |
| 110 | + @param error If an error occurs, upon return contains an NSError object that describes the problem. If you are not interested in possible errors, pass in NULL. |
| 111 | + @return the prediction as CoremlEncoderOutput |
| 112 | +*/ |
| 113 | +- (nullable CoremlEncoderOutput *)predictionFromFeatures:(CoremlEncoderInput *)input error:(NSError * _Nullable __autoreleasing * _Nullable)error; |
| 114 | + |
| 115 | +/** |
| 116 | + Make a prediction using the standard interface |
| 117 | + @param input an instance of CoremlEncoderInput to predict from |
| 118 | + @param options prediction options |
| 119 | + @param error If an error occurs, upon return contains an NSError object that describes the problem. If you are not interested in possible errors, pass in NULL. |
| 120 | + @return the prediction as CoremlEncoderOutput |
| 121 | +*/ |
| 122 | +- (nullable CoremlEncoderOutput *)predictionFromFeatures:(CoremlEncoderInput *)input options:(MLPredictionOptions *)options error:(NSError * _Nullable __autoreleasing * _Nullable)error; |
| 123 | + |
| 124 | +/** |
| 125 | + Make a prediction using the convenience interface |
| 126 | + @param melSegment as 1 × 80 × 3000 3-dimensional array of floats: |
| 127 | + @param error If an error occurs, upon return contains an NSError object that describes the problem. If you are not interested in possible errors, pass in NULL. |
| 128 | + @return the prediction as CoremlEncoderOutput |
| 129 | +*/ |
| 130 | +- (nullable CoremlEncoderOutput *)predictionFromMelSegment:(MLMultiArray *)melSegment error:(NSError * _Nullable __autoreleasing * _Nullable)error; |
| 131 | + |
| 132 | +/** |
| 133 | + Batch prediction |
| 134 | + @param inputArray array of CoremlEncoderInput instances to obtain predictions from |
| 135 | + @param options prediction options |
| 136 | + @param error If an error occurs, upon return contains an NSError object that describes the problem. If you are not interested in possible errors, pass in NULL. |
| 137 | + @return the predictions as NSArray<CoremlEncoderOutput *> |
| 138 | +*/ |
| 139 | +- (nullable NSArray<CoremlEncoderOutput *> *)predictionsFromInputs:(NSArray<CoremlEncoderInput*> *)inputArray options:(MLPredictionOptions *)options error:(NSError * _Nullable __autoreleasing * _Nullable)error; |
| 140 | +@end |
| 141 | + |
| 142 | +NS_ASSUME_NONNULL_END |
0 commit comments