<\/figure>\n<\/p>\nrFlow\u6a21\u578b\u8f6c\u6362\u4e3aCore ML\u6a21\u578b\uff0c\u5e76\u4fdd\u5b58\u4e3a.mlmodel\u6587\u4ef6\u3002<\/p>\n
\u73b0\u5728\uff0c\u6211\u4eec\u5df2\u7ecf\u5f97\u5230\u4e86\u4e00\u4e2a\u53ef\u4ee5\u5728iOS\u5e94\u7528\u4e2d\u4f7f\u7528\u7684Core ML\u6a21\u578b\u3002\u5728Xcode\u4e2d\u521b\u5efa\u4e00\u4e2a\u65b0\u7684iOS\u5e94\u7528\u7a0b\u5e8f\uff0c\u5c06.mlmodel\u6587\u4ef6\u6dfb\u52a0\u5230\u9879\u76ee\u4e2d\u3002\u7136\u540e\uff0c\u5728\u9700\u8981\u4f7f\u7528\u6a21\u578b\u7684\u5730\u65b9\uff0c\u5bfc\u5165CoreML\u6846\u67b6\uff0c\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u52a0\u8f7d\u6a21\u578b\uff1a<\/p>\n
“`swift<\/p>\n
import CoreML<\/p>\n
let model = try VNCoreMLModel(for: MyModel().model)<\/p>\n
“`<\/p>\n
\u8fd9\u91cc\uff0cMyModel\u4ee3\u8868\u6211\u4eec\u5728Xcode\u4e2d\u521b\u5efa\u7684\u6a21\u578b\u6587\u4ef6\uff0c\u5e76\u4f7f\u7528VNCoreMLModel\u7c7b\u52a0\u8f7d\u6a21\u578b\u3002<\/p>\n
\u6700\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528Vision\u6846\u67b6\u8fdb\u884c\u56fe\u50cf\u5206\u7c7b\uff1a<\/p>\n
“`swift<\/p>\n
import Vision<\/p>\n
let request = VNCoreMLRequest(model: model) { request, error in<\/p>\n
guard let results = request.results as? [VNClassificationObservation],<\/p>\n
let topResult = results.first else {<\/p>\n
fatalError(“Unexpected result type from VNCoreMLRequest”)<\/p>\n
}<\/p>\n
print(“\\(topResult.identifier) with \\(topResult.confidence)”)<\/p>\n
}<\/p>\n
let handler = VNImageRequestHandler(ciImage: ciImage)<\/p>\n
try? handler.perform([request])<\/p>\n
“`<\/p>\n
\u8fd9\u4e2a\u4ee3\u7801\u4f1a\u4f7f\u7528VNCoreMLRequest\u7c7b\u8fdb\u884c\u56fe\u50cf\u5206\u7c7b\uff0c\u5c06\u7ed3\u679c\u6253\u5370\u51fa\u6765\u3002<\/p>\n
\u8fd9\u5c31\u662f\u5c06\u82f9\u679cTF\u6a21\u578b\u4e0a\u67b6\u5230\u5e94\u7528\u4e2d\u7684\u8fc7\u7a0b\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u8fd9\u91cc\u53ea\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff0c\u5b9e\u9645\u5e94\u7528\u4e2d\u53ef\u80fd\u9700\u8981\u66f4\u590d\u6742\u7684\u6a21\u578b\u548c\u4ee3\u7801\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"
\u82f9\u679cTF\u662f\u82f9\u679c\u516c\u53f8\u63a8\u51fa\u7684\u4e00\u79cd\u673a\u5668\u5b66\u4e60\u6a21\u578b\u683c\u5f0f\uff0c\u53ef\u4ee5\u5728\u82f9\u679c\u8bbe\u5907\u4e0a\u8fdb\u884c\u9ad8\u6548\u7684\u673a\u5668\u5b66\u4e60\u63a8\u7406\u3002\u5728iOS 12\u4e4b\u540e\uff0c\u82f9\u679c\u5df2\u7ecf\u5c06Core ML\u6846\u67b6\u66f4\u65b0\u81f3Core ML 2\uff0c\u652f\u6301\u4e86\u82f9\u679cTF\u683c\u5f0f\u7684\u6a21\u578b\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u5982<\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[268,6509,205,25788,25789],"topic":[],"class_list":["post-27323","post","type-post","status-publish","format-standard","hentry","category-appsjsd","tag-268","tag-6509","tag-205","tag-app"],"_links":{"self":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/posts\/27323","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/comments?post=27323"}],"version-history":[{"count":1,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/posts\/27323\/revisions"}],"predecessor-version":[{"id":27374,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/posts\/27323\/revisions\/27374"}],"wp:attachment":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/media?parent=27323"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/categories?post=27323"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/tags?post=27323"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/topic?post=27323"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}