Failed to perform classification. encountered an unexpected condition: Unspecified error on Apple Vision (M1)

Viewed 96

I got this error that says :

"Failed to perform classification. encountered an unexpected condition: Unspecified error"

my code is pretty basic, so what did i do wrong?

    func updateClassifications(for image: UIImage) {
        let orientation = CGImagePropertyOrientation(image.imageOrientation)
        guard let ciImage = CIImage(image: image) else { fatalError("Unable to create \(CIImage.self) from \(image).") }
        let request = VNDetectFaceRectanglesRequest()
        
        DispatchQueue.global().async {
            let handler = VNImageRequestHandler(ciImage: ciImage, orientation: orientation)
            do {
                try handler.perform([request])
                print(request.results!)
            } catch {
                print("Failed to perform classification.\n\(error.localizedDescription)")
            }
        }
    }
0 Answers
Related