Post

Replies

Boosts

Views

Activity

Reply to Could not create inference context
I'm seeing this error for Apple’s own Vision/Image models in tvOS Simulator using Xcode 13.2.1 and tvOS 15.2 on an M1 Max. Here is the code snippet that causes the error: let requestHandler = VNImageRequestHandler(cgImage: cgImage) let objectness = VNGenerateObjectnessBasedSaliencyImageRequest() let attention = VNGenerateAttentionBasedSaliencyImageRequest() let faces = VNDetectFaceRectanglesRequest() do { try requestHandler.perform([objectness, attention, faces]) } catch { print("Error analyzing image: \(error)") return nil } And as a workaround based on the above response from Apple, this works: let requestHandler = VNImageRequestHandler(cgImage: cgImage) let objectness = VNGenerateObjectnessBasedSaliencyImageRequest() let attention = VNGenerateAttentionBasedSaliencyImageRequest() let faces = VNDetectFaceRectanglesRequest() #if targetEnvironment(simulator) objectness.usesCPUOnly = true attention.usesCPUOnly = true faces.usesCPUOnly = true #endif do { try requestHandler.perform([objectness, attention, faces]) } catch { print("Error analyzing image: \(error)") return nil }
Dec ’21