From 2c41969942d077228dad2d056dc54f93cadb84ae Mon Sep 17 00:00:00 2001 From: dec2-anon <119710906+dec2-anon@users.noreply.github.com> Date: Sat, 3 Dec 2022 06:02:30 +0600 Subject: [PATCH 1/2] Add Filename Character Limit Very long prompts cause this error: Error: saving("Failed to create destination for file:///path/prompt.seed.final.png" --- swift/StableDiffusionCLI/main.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/swift/StableDiffusionCLI/main.swift b/swift/StableDiffusionCLI/main.swift index 6b09af62..ad6661ef 100644 --- a/swift/StableDiffusionCLI/main.swift +++ b/swift/StableDiffusionCLI/main.swift @@ -145,7 +145,8 @@ struct StableDiffusionSample: ParsableCommand { } func imageName(_ sample: Int, step: Int? = nil) -> String { - var name = prompt.replacingOccurrences(of: " ", with: "_") + var fileCharLimit: Int = 75 + var name = prompt.prefix(fileCharLimit).replacingOccurrences(of: " ", with: "_") if imageCount != 1 { name += ".\(sample)" } From d735ad0d78901aa359d33e382507659ab8c005a6 Mon Sep 17 00:00:00 2001 From: dec2-anon <119710906+dec2-anon@users.noreply.github.com> Date: Sat, 10 Dec 2022 09:32:54 +0600 Subject: [PATCH 2/2] change to a let Co-authored-by: Stefan-Hintz --- swift/StableDiffusionCLI/main.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swift/StableDiffusionCLI/main.swift b/swift/StableDiffusionCLI/main.swift index ad6661ef..860dace1 100644 --- a/swift/StableDiffusionCLI/main.swift +++ b/swift/StableDiffusionCLI/main.swift @@ -145,7 +145,7 @@ struct StableDiffusionSample: ParsableCommand { } func imageName(_ sample: Int, step: Int? = nil) -> String { - var fileCharLimit: Int = 75 + let fileCharLimit = 75 var name = prompt.prefix(fileCharLimit).replacingOccurrences(of: " ", with: "_") if imageCount != 1 { name += ".\(sample)"