| import CoreML | |
| import Foundation | |
| guard CommandLine.arguments.count == 2 else { | |
| print("usage: CoreMLCompileOne <path-to-mlpackage-or-mlmodel>") | |
| exit(2) | |
| } | |
| let package = URL(fileURLWithPath: CommandLine.arguments[1]) | |
| do { | |
| let compiled = try MLModel.compileModel(at: package) | |
| print("COMPILE_OK") | |
| print("COMPILED_PATH=\(compiled.path)") | |
| let model = try MLModel(contentsOf: compiled) | |
| print("LOAD_OK") | |
| print("INPUTS=\(Array(model.modelDescription.inputDescriptionsByName.keys).sorted().joined(separator: ","))") | |
| } catch { | |
| print("CONTROLLED_ERROR") | |
| print(String(describing: error)) | |
| } | |