Skip to content

Commit 4c00b32

Browse files
authored
Changed seed type into UInt32 (#47)
1 parent 37ff2a4 commit 4c00b32

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

swift/StableDiffusion/pipeline/StableDiffusionPipeline.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public struct StableDiffusionPipeline: ResourceManaging {
119119
prompt: String,
120120
imageCount: Int = 1,
121121
stepCount: Int = 50,
122-
seed: Int = 0,
122+
seed: UInt32 = 0,
123123
disableSafety: Bool = false,
124124
scheduler: StableDiffusionScheduler = .pndmScheduler,
125125
progressHandler: (Progress) -> Bool = { _ in true }
@@ -205,11 +205,11 @@ public struct StableDiffusionPipeline: ResourceManaging {
205205
return try decodeToImages(latents, disableSafety: disableSafety)
206206
}
207207

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

212-
var random = NumPyRandomSource(seed: UInt32(truncatingIfNeeded: seed))
212+
var random = NumPyRandomSource(seed: seed)
213213
let samples = (0..<count).map { _ in
214214
MLShapedArray<Float32>(
215215
converting: random.normalShapedArray(sampleShape, mean: 0.0, stdev: Double(stdev)))

swift/StableDiffusionCLI/main.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ struct StableDiffusionSample: ParsableCommand {
4848
var outputPath: String = "./"
4949

5050
@Option(help: "Random seed")
51-
var seed: Int = 93
51+
var seed: UInt32 = 93
5252

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

0 commit comments

Comments
 (0)