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
@IBAction func onTapButton(_ sender: Any) { | |
presentAnimationController.selectedCardFrame = imageView.frame | |
self.performSegue(withIdentifier: "showDetail", sender: nil) | |
} |
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
@IBAction func onTapButton(_ sender: Any) { | |
presentAnimationController.selectedCardFrame = imageView.frame | |
self.performSegue(withIdentifier: "showDetail", sender: nil) | |
} |
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
@IBAction func onTapButton(_ sender: Any) { | |
presentAnimationController.selectedCardFrame = imageView.frame | |
self.performSegue(withIdentifier: "showDetail", sender: nil) | |
} |
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
extension MainViewController: UIViewControllerTransitioningDelegate { | |
func animationController(forPresented presented: UIViewController, | |
presenting: UIViewController, | |
source: UIViewController) -> UIViewControllerAnimatedTransitioning? { | |
return presentAnimationController | |
} | |
} |
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
override func prepare(for segue: UIStoryboardSegue, sender: Any?) { | |
let destinationViewController = segue.destination | |
destinationViewController.transitioningDelegate = self | |
} |
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 controller = Pager.PageContainerViewController.instantiate() | |
present(controller, animated: true) | |
let controllers = dataSource.map { _ in PageDetailViewController.instantiate() ?? PageDetailViewController() } | |
controller.configure(with: dataSource, controllers: controllers) |
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
func handleClassification(request: VNRequest, error: Error?) { | |
guard let observations = request.results as? [VNClassificationObservation] | |
else { fatalError("unexpected result type from VNCoreMLRequest") } | |
guard let best = observations.first | |
else { fatalError("can't get best result") } | |
DispatchQueue.main.async { | |
self.classificationLabel.text = "Classification: \"\(best.identifier)\" Confidence: \(best.confidence)" | |
} | |
} |
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 handler = VNImageRequestHandler(ciImage: ciImage, orientation:orientation) | |
DispatchQueue.global(qos: .userInteractive).async { | |
do { | |
try handler.perform([self.classificationRequest]) | |
} catch { | |
print(error) | |
} | |
} |
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
lazy var classificationRequest: VNCoreMLRequest = { | |
do { | |
let model = try VNCoreMLModel(for: ImageClassifier().model) | |
return VNCoreMLRequest(model: model, completionHandler: self.handleClassification) | |
} catch { | |
fatalError("can't load Vision ML model: \(error)") | |
} | |
}() |
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
import CreateMLUI | |
let builder = MLImageClassifierBuilder() | |
builder.showInLiveView() |