Skip to content

Commit

Permalink
Changed seed type into UInt32 (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wanaldino authored Dec 20, 2022
1 parent 37ff2a4 commit 4c00b32
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions swift/StableDiffusion/pipeline/StableDiffusionPipeline.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public struct StableDiffusionPipeline: ResourceManaging {
prompt: String,
imageCount: Int = 1,
stepCount: Int = 50,
seed: Int = 0,
seed: UInt32 = 0,
disableSafety: Bool = false,
scheduler: StableDiffusionScheduler = .pndmScheduler,
progressHandler: (Progress) -> Bool = { _ in true }
Expand Down Expand Up @@ -205,11 +205,11 @@ public struct StableDiffusionPipeline: ResourceManaging {
return try decodeToImages(latents, disableSafety: disableSafety)
}

func generateLatentSamples(_ count: Int, stdev: Float, seed: Int) -> [MLShapedArray<Float32>] {
func generateLatentSamples(_ count: Int, stdev: Float, seed: UInt32) -> [MLShapedArray<Float32>] {
var sampleShape = unet.latentSampleShape
sampleShape[0] = 1

var random = NumPyRandomSource(seed: UInt32(truncatingIfNeeded: seed))
var random = NumPyRandomSource(seed: seed)
let samples = (0..<count).map { _ in
MLShapedArray<Float32>(
converting: random.normalShapedArray(sampleShape, mean: 0.0, stdev: Double(stdev)))
Expand Down
2 changes: 1 addition & 1 deletion swift/StableDiffusionCLI/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ struct StableDiffusionSample: ParsableCommand {
var outputPath: String = "./"

@Option(help: "Random seed")
var seed: Int = 93
var seed: UInt32 = 93

@Option(help: "Compute units to load model with {all,cpuOnly,cpuAndGPU,cpuAndNeuralEngine}")
var computeUnits: ComputeUnits = .all
Expand Down

0 comments on commit 4c00b32

Please sign in to comment.