Skip to content

Instantly share code, notes, and snippets.

@anupamchugh
Created May 29, 2021 02:54
Show Gist options
  • Save anupamchugh/3d1f22c0da5c67f9afd94ae1c3c26cd1 to your computer and use it in GitHub Desktop.
Save anupamchugh/3d1f22c0da5c67f9afd94ae1c3c26cd1 to your computer and use it in GitHub Desktop.
func runVisionRequest() {
guard let model = try? VNCoreMLModel(for: DeepLabV3(configuration: .init()).model)
else { return }
let request = VNCoreMLRequest(model: model, completionHandler: visionRequestDidComplete)
request.imageCropAndScaleOption = .scaleFill
DispatchQueue.global().async {
let handler = VNImageRequestHandler(cgImage: inputImage.cgImage!, options: [:])
do {
try handler.perform([request])
}catch {
print(error)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment