|
|
|
@ -68,6 +68,9 @@ struct StableDiffusionSample: ParsableCommand {
|
|
|
|
|
@Flag(help: "Reduce memory usage")
|
|
|
|
|
var reduceMemory: Bool = false
|
|
|
|
|
|
|
|
|
|
@Flag(help: "Increse random seed by 1 for each image")
|
|
|
|
|
var incrementSeed: Bool = false
|
|
|
|
|
|
|
|
|
|
mutating func run() throws {
|
|
|
|
|
guard FileManager.default.fileExists(atPath: resourcePath) else {
|
|
|
|
|
throw RunError.resources("Resource path does not exist \(resourcePath)")
|
|
|
|
@ -89,6 +92,15 @@ struct StableDiffusionSample: ParsableCommand {
|
|
|
|
|
let sampleTimer = SampleTimer()
|
|
|
|
|
sampleTimer.start()
|
|
|
|
|
|
|
|
|
|
let loops = incrementSeed ? imageCount : 1
|
|
|
|
|
let imageCountPerBatch = incrementSeed ? 1 : imageCount
|
|
|
|
|
|
|
|
|
|
for i in 0 ..< loops {
|
|
|
|
|
if (incrementSeed) {
|
|
|
|
|
log("Generating image \(i+1) of \(imageCount) with seed \(seed)\n")
|
|
|
|
|
log("\n")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let images = try pipeline.generateImages(
|
|
|
|
|
prompt: prompt,
|
|
|
|
|
negativePrompt: negativePrompt,
|
|
|
|
@ -107,6 +119,11 @@ struct StableDiffusionSample: ParsableCommand {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_ = try saveImages(images, logNames: true)
|
|
|
|
|
|
|
|
|
|
if (incrementSeed) {
|
|
|
|
|
seed += 1
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func handleProgress(
|
|
|
|
|