Skip to content

Commit

Permalink
Fix long prompts crashing the app
Browse files Browse the repository at this point in the history
  • Loading branch information
SocketByte committed Oct 9, 2022
1 parent 6ddac71 commit b2a77da
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
All in one, batteries-included software to easily generate and upscale AI art using [Stable Diffusion](https://github.com/CompVis/stable-diffusion).

![Image](https://i.imgur.com/EyjdVXj.png)
![Image](https://i.imgur.com/kB3mL6e.png)

## Requirements / Info

Expand Down
11 changes: 9 additions & 2 deletions SDToolkit/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,13 @@ public static void GenerateFromPrompt(GeneratorConfig config)

private static void Run(GeneratorConfig config)
{
Directory.Delete(WorkingDirectory + "\\stable-diffusion\\outputs\\txt2img-samples", true);
var samplesDir = WorkingDirectory + "\\stable-diffusion\\outputs\\txt2img-samples";
if (Directory.Exists(samplesDir))
{
Directory.Delete(samplesDir, true);
}

var path = DateTimeOffset.Now.ToUnixTimeSeconds().ToString();

config.GenerateButton.Invoke(new MethodInvoker(delegate ()
{
Expand All @@ -89,7 +95,8 @@ private static void Run(GeneratorConfig config)
var prompt = config.Prompt;
var converted = string.Join("_", prompt.Split(' '));

var images = Directory.GetFiles(WorkingDirectory + @"\stable-diffusion\outputs\txt2img-samples\" + converted, "*.png");
var dir = Directory.GetDirectories(WorkingDirectory + @"\stable-diffusion\outputs\txt2img-samples\")[0];
var images = Directory.GetFiles(dir, "*.png");

config.GenerateButton.Invoke(new MethodInvoker(delegate ()
{
Expand Down

0 comments on commit b2a77da

Please sign in to comment.