Created
August 3, 2023 12:17
-
-
Save geor-kasapidi/4137bd3b75c06da68b855a6503ca86b1 to your computer and use it in GitHub Desktop.
coreml compilation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static func _compile(data: Data, configuration: MLModelConfiguration = .init()) async throws -> MLModel { | |
let tmp = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) | |
try data.write(to: tmp, options: .atomic) | |
let url = try await MLModel.compileModel(at: tmp) | |
try FileManager.default.removeItem(at: tmp) | |
let model = try MLModel(contentsOf: url, configuration: configuration) | |
try FileManager.default.removeItem(at: url) | |
return model | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment