Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
First snippet of CoreML within ARBroadcaster
let mlModel: MLModel = Hotdog().model
var visionRequests = [VNRequest]()
let dispatchQueueML = DispatchQueue(label: "io.agora.dispatchqueue.ml") // A Serial Queue
override func viewDidLoad() {
super.viewDidLoad()
// Set up Vision Model
guard let hotDogModel = try? VNCoreMLModel(for: mlModel) else {
fatalError("Could not load model. Ensure Coreml model is in your XCode Project and part of a target (see: https://stackoverflow.com/questions/45884085/model-is-not-part-of-any-target-add-the-model-to-a-target-to-enable-generation ")
}
// Set up Vision-CoreML Request
let classificationRequest = VNCoreMLRequest(model: hotDogModel, completionHandler: classificationCompleteHandler)
classificationRequest.imageCropAndScaleOption = VNImageCropAndScaleOption.centerCrop // Crop from centre of images and scale to appropriate size.
visionRequests = [classificationRequest]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.