Skip to content

Commit

Permalink
fix(VisualRecognitionV3): temporary workaround to support A12 devices…
Browse files Browse the repository at this point in the history
… for Core ML inference
  • Loading branch information
devinaconley authored and Anthony Oliveri committed Nov 12, 2018
1 parent dcefce5 commit fa212ec
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Source/VisualRecognitionV3/VisualRecognition+CoreML.swift
Expand Up @@ -280,6 +280,9 @@ extension VisualRecognition {
private func loadModelFromDisk(classifierID: String) throws -> MLModel {
let modelURL = try locateModelOnDisk(classifierID: classifierID)

// must build with Xcode 10 or later in order to use `MLModelConfiguration`.
// use the version of Swift to infer the Xcode version since this can’t be checked explicitly.
#if swift(>=4.1.50) || (swift(>=3.4) && !swift(>=4.0))
// temporary workaround for compatibility issue with new A12 based devices
if #available(iOS 12.0, *) {
let modelConfig = MLModelConfiguration()
Expand All @@ -288,6 +291,9 @@ extension VisualRecognition {
} else {
return try MLModel(contentsOf: modelURL)
}
#else
return try MLModel(contentsOf: modelURL)
#endif
}

/// Convert results from Core ML classification requests into a `ClassifiedImages` model.
Expand Down

0 comments on commit fa212ec

Please sign in to comment.