Core ML and Vision
Vision
Apply high-performance image analysis and computer vision techniques to identify faces, detect features, and classify scenes in images and video.
應(yīng)用場景:
Face Detection and Recognition
Machine Learning Image Analysis
Barcode Detection
Image Alignment Analysis
Text Detection
Horizon Detection
支持的圖片類型:
CVPixelBufferRef CGImageRef CIImage NSURL NSData幾乎涵蓋了 iOS 中圖片相關(guān)的 API,很強(qiáng)大。
使用到的類:
VNCoreMLModel
A container for a Core ML model used with Vision requests.
VNCoreMLRequest
An image analysis request that uses a Core ML model to process images.
VNClassificationObservation
Scene classification information produced by an image analysis request.
VNPixelBufferObservation
An output image produced by a Core ML image analysis request.
VNImageRequestHandler
An object that processes one or more image analysis requests pertaining to a single image.
總結(jié)
基于 Core ML 框架,Apple 提供了一個(gè)高性能的視覺處理技術(shù) Vision,它更像是一個(gè)工具庫,對(duì)一些高頻場景進(jìn)行了封裝,比如人臉、條形碼、矩形和文字等,這些基于底層 API 封裝的高級(jí)功能可以幫助開發(fā)者高效地完成特定的功能。
參考博客:http://yulingtianxia.com/blog/2017/06/19/Core-ML-and-Vision-Framework-on-iOS-11/
Core ML
框架層級(jí)圖:
(侵刪)
使用原理:
(侵刪)
轉(zhuǎn)換Core ML模型
支持ML類型:
Core ML 支持 DNN,RNN,CNN,SVM,Tree ensembles,Generalized linear models,Pipeline models 等ML模型
轉(zhuǎn)換方法:
蘋果提供了一個(gè) Python 工具coremltools,可以將業(yè)內(nèi)一些常用的機(jī)器學(xué)習(xí)框架導(dǎo)出的 Model 轉(zhuǎn)成 MLMODEL 文件。代碼會(huì)編譯成可執(zhí)行二進(jìn)制文件,而 MLMODEL 會(huì)編譯成 Bundle 文件,在代碼文件中可以直接調(diào)用 MLMODEL 生成的類。
比如,如果模型是用Caffe創(chuàng)建的,那么將 Caffe 模型(.caffemodel)傳遞給coremltools.converters.caffe.convert:
import coremltools coreml_model = coremltools.converters.caffe.convert('my_caffe_model.caffemodel')然后將所得到的模型保存為 Core ML 模型格式:
coreml_model.save('my_model.mlmodel')當(dāng)你需要轉(zhuǎn)換一個(gè)不在上表中的格式的模型時(shí),也可以創(chuàng)建你自己的轉(zhuǎn)換工具。
編寫你自己的轉(zhuǎn)換工具涉及到將你的模型的輸入、輸出和架構(gòu)的表示(representation)翻譯成 Core ML 模型格式。你需要定義該模型架構(gòu)的每一層以及它們與其它層的連接。使用 Core ML Tools 提供的轉(zhuǎn)換工具為例;它們演示了通過第三方工具創(chuàng)建的多種類型的模型被轉(zhuǎn)換成 Core ML 模型格式的方法。
注:Core ML 模型格式是由一些協(xié)議緩沖文件(protocol buffer files)定義的,具體描述請(qǐng)參閱:https://developer.apple.com/machine-learning
總結(jié)
以上是生活随笔為你收集整理的Core ML and Vision的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 第9章第6节:完成目录页的制作并创建幻灯
- 下一篇: KafkaStream之时间窗口Wind