ios - 如何在 Swift 中使用 Vision 实现 plist?
问题描述
我正在尝试创建一个程序,该程序使用 Vision 来识别罐装饮料并将名称和咖啡因含量显示在屏幕上的两个 UILabel 中。我在 CreateML 中训练了一个模型来识别 Monster 和 Del's Shandy。我有一个小 plist(用于测试目的)和一些我认为可以显示饮料的代码,但它似乎不起作用。我已经获得了要显示的名称和信心水平,尽管这并不是我想要的。这是我用来尝试访问 plist 的代码:
DispatchQueue.main.sync {
if self.productID != nil {
guard self.productCatalog[self.productID] != nil else {
return
}
self.outputLabel.text = self.productCatalog[self.productID]?["Name"] as? String
self.caffeineContentLabel.text = self.productCatalog[self.productID]?["Caffeine"] as? String
}
我以前读plist的字典的方法如下:
override func awakeFromNib() {
if let path = Bundle.main.path(forResource: "ProductCatalog", ofType: "plist") {
productCatalog = NSDictionary(contentsOfFile: path) as? [String: [String: Any]]
}
}
解决方案
推荐阅读
- api - 如何使用 betfair API 显示赔率(后退/下注/平局)
- java - SpringBoot ResourceBundleMessageSource 与外部远程文件
- python - 有没有一种简单的方法可以将第一个之前的值包含在最后一个数据框中?
- python - 如何处理包含混合数据类型的熊猫数据框?
- intellij-idea - 有没有办法在 IntelliJ 项目视图中突出显示有问题的文件
- r - 箱线图问题
- shell - 跨不同命令传递初始标准输入
- build - 盖茨比启动器无法构建
- docker-swarm - Traefik + Docker Swarm 模式
- javascript - 如何计算储蓄账户达到一定金额所需的每月供款?