I'm having trouble creating a very simple example of using Apple's CoreML in Objective-C. I have already created a model file using python which works rather simply now:
coreml_model_svm = coremltools.models.MLModel("svm.mlmodel")
test_x = [1.0 for x in range(160)]
predictions_coreml_svm = coreml_model_svm.predict({"input":test_x})
I would like to reproduce the above three lines in Objective-C. I know that my data has to be an MLMultiArray and the model needs to be loaded into MLModel. I've been trying to find some info on the syntax, but it seems I don't understand how the documentation works, and all the examples are in Swift. Here's my code so far. Commenting the MLMultiArray leads to an uncaught exception for initializing the MLModel. When not commenting the MLMultiArray I get no known class method for selector 'initWithShape:dataType:error'.
#import <Foundation/Foundation.h>
#import <CoreML/CoreML.h>
//clang -framework Foundation coremltest.m -o coremltest
int main (int argc, const char * argv[])
{
NSLog(@"start");
NSArray * shape = [[NSArray alloc] init];
MLMultiArrayDataType dataType = MLMultiArrayDataTypeDouble;
NSError * error = nil;
MLMultiArray * input = [MLMultiArray initWithShape:(NSArray*) shape
dataType:(MLMultiArrayDataType ) dataType
error:(NSError **) error];
MLModel * mymodel = [[MLModel init] initWithContentsOfFile:@"svm.mlmodel"];
return 0;
}
I would appreciate any help with this.