From 62edd0903a1ecd7fea7307391b168f8403e6b654 Mon Sep 17 00:00:00 2001 From: "Devin A. Conley" Date: Thu, 8 Nov 2018 17:37:18 -0600 Subject: [PATCH] fix(VisualRecognitionV3): temporary workaround for new A12 based devices --- .../VisualRecognitionV3/VisualRecognition+CoreML.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Source/VisualRecognitionV3/VisualRecognition+CoreML.swift b/Source/VisualRecognitionV3/VisualRecognition+CoreML.swift index 86664e556..a273aecfb 100644 --- a/Source/VisualRecognitionV3/VisualRecognition+CoreML.swift +++ b/Source/VisualRecognitionV3/VisualRecognition+CoreML.swift @@ -279,7 +279,15 @@ extension VisualRecognition { */ private func loadModelFromDisk(classifierID: String) throws -> MLModel { let modelURL = try locateModelOnDisk(classifierID: classifierID) - return try MLModel(contentsOf: modelURL) + + // temporary workaround for compatibility issue with new A12 based devices + if #available(iOS 12.0, *) { + let modelConfig = MLModelConfiguration() + modelConfig.computeUnits = .cpuAndGPU + return try MLModel(contentsOf: modelURL, configuration: modelConfig) + } else { + return try MLModel(contentsOf: modelURL) + } } /// Convert results from Core ML classification requests into a `ClassifiedImages` model.