Start work on more clean client.

This commit is contained in:
2023-04-22 16:32:54 -07:00
parent 1c0fbe02db
commit 4430bdcdd7
9 changed files with 69 additions and 26 deletions

View File

@ -8,13 +8,13 @@ public actor ModelState {
private var pipeline: StableDiffusionPipeline?
private var tokenizer: BPETokenizer?
public init(url: URL) throws {
public init(url: URL) {
self.url = url
}
public func load() throws {
let config = MLModelConfiguration()
config.computeUnits = .all
config.computeUnits = .cpuAndGPU
pipeline = try StableDiffusionPipeline(
resourcesAt: url,
controlNet: [],
@ -25,6 +25,7 @@ public actor ModelState {
let mergesUrl = url.appending(component: "merges.txt")
let vocabUrl = url.appending(component: "vocab.json")
tokenizer = try BPETokenizer(mergesAt: mergesUrl, vocabularyAt: vocabUrl)
try pipeline?.loadResources()
}
public func generate(_ request: SdGenerateImagesRequest) throws -> SdGenerateImagesResponse {