我正在尝试使用我创建的 CoreMl 模型,但出现错误(其他模型不会出现此错误)。该错误由以下行引发:let compiled = try MLModel.compileModel(at: URL(fileURLWithPath: "/Users/myname/Desktop/ItemSimilarityRecommender.mlmodel"))。(注意:我尝试使用我的包中的路径并得到相同的错误)
错误是Error Domain=com.apple.CoreML Code=3 "Error reading protobuf spec. validator error: unable to open file for read" UserInfo={NSLocalizedDescription=Error reading protobuf spec. validator error: unable to open file for read}
我在网上可以找到的关于此错误的唯一信息是,如果省略“.mlmodel”,则可能会发生这种情况,这显然不是我的问题。当我在计算机上手动编译模型时,程序也失败。我制作了这个模型的多个版本来尝试解决这个问题,每次我都会遇到相同的错误。
编辑:
我可以手动编译该文件,它会创建一个看似有效的 .mlmodelc 文件。但是,当我使用 时try MLModel(contentsOf:),它会抛出以下错误:
2021-11-07 15:56:43.131400-0500 Movie Thing[52871:2279366] [coreml] 无法打开文件:/Users/me/Desktop/ItemSimilarityRecommender.mlmodelc/coremldata.bin。它不是有效的 .mlmodelc 文件。2021-11-07 15:56:43.132186-0500 Movie Thing[52871:2279366] [coreml] MLModelAsset:加载失败,错误错误 Domain=com.apple.CoreML Code=0“无法加载模型:file:/// Users/me/Desktop/ItemSimilarityRecommender.mlmodelc/。使用 Xcode 编译模型或
MLModel.compileModel(at:)." UserInfo={NSLocalizedDescription=无法加载模型:file:///Users/me/Desktop/ItemSimilarityRecommender.mlmodelc/。使用 Xcode 或MLModel.compileModel(at:). ,NSUnderlyingError = 0x6000036e3090 {Error Domain = com.apple.CoreML …
对于学校,我正在制作一个有关大屠杀的应用程序。我需要在detailViewController 上显示有关营地的信息,但它不起作用。我可以访问变量的“名称”值(很抱歉,如果我的术语有误),但除此之外什么也没有。其他帖子不是 Swift 的,或者与我的具体问题无关,所以我找不到解决方案。
以下是创建变量类型的类的代码:
class DeathCamp: NSObject {
var name:String = ""
var locationCountry:String = ""
var jewishDeathCount:Int = 0
init(name:String, locationCountry:String, jewishDeathCount:Int){
self.name = name
self.locationCountry = locationCountry
self.jewishDeathCount = jewishDeathCount
}
}
Run Code Online (Sandbox Code Playgroud)
以下是将详细信息项设置为数组的代码:
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "showDetail" {
if let indexPath = self.tableView.indexPathForSelectedRow {
let deathCampNewObject = deathCampArray[indexPath.row]
let countryDeathNewObject = countryArray[indexPath.row]
let controller = (segue.destinationViewController as! UINavigationController).topViewController as! DetailViewController
controller.detailItemDeath = deathCampNewObject
controller.detailItemCountry = countryDeathNewObject
controller.navigationItem.leftBarButtonItem = self.splitViewController?.displayModeButtonItem()
controller.navigationItem.leftItemsSupplementBackButton …Run Code Online (Sandbox Code Playgroud) 搜索后,我找不到这个确切问题的答案。当我使用Xcode 8(GM种子)将应用程序的内部版本上传到iTunes Connect时,它表示内部版本已上传。然后,我收到一封电子邮件(应用程序的名称不是AppName,它只是一个占位符):
WatchKit支持无效-应用程序的根位置(例如/Payload/AppName.app/Watch)缺少预期的应用程序。
我已经更改了配置文件,但是它什么也没做。
我怎样才能解决这个问题?谢谢。
我正在尝试使用 加入数组.joined(separator:)。但是,我希望分隔符包含索引。例如,如果我有数组["red", "orange", "yellow", "green"],我希望输出为"red (0), orange (1), yellow (2), green"。我尝试这样做.joined(separator: "\($0.index), "),但没有成功。