Created
February 29, 2020 03:44
-
-
Save digitallysavvy/38b9e923b5edae7334212c85994a14de to your computer and use it in GitHub Desktop.
First snippet of CoreML within ARBroadcaster
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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