i have multiple .mlModels in my xcode project and i want user to select the model and perform prediction
let gestureClassifier = GestureClassifier() //mlModel
func predictGesture(window: Int) {
let previousOutput = modelOutputs[window]
let modelOutput = try? gestureClassifier.prediction(features: modelInput, hiddenIn: previousOutput?.hiddenOut, cellIn: previousOutput?.cellOut)
modelOutputs[window] = modelOutput
if let prediction = modelOutput?.activity,
let probability = modelOutput?.activityProbability[prediction] {
if prediction == Config.restItValue {
return
}
if probability > Config.predictionThreshold {
if prediction == Config.chopItValue || prediction == Config.driveItValue || prediction == Config.shakeItValue {
print("prediction: \(prediction)")
self.recordGestures(gesture: prediction)
}
}
else{
print("unrecognised gesture")
self.recordGestures(gesture: "unRecognised Gesture")
}
}
}
i have an other model gestureClassifier1 i would like to do something like this
func predictGesture(window: Int, **selectedModel**) {
let previousOutput = modelOutputs[window]
let modelOutput = try? **selectedModel**.prediction(features: modelInput, hiddenIn:
previousOutput?.hiddenOut, cellIn: previousOutput?.cellOut)
}
how can i achieve this, i tried to used Anyclass as an datatype but class functions such as .prediction(..) is not accessible.