|
|
@ -42,9 +42,7 @@ public class InvokeAI : BaseGitPackage |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
public override Uri PreviewImageUri => |
|
|
|
public override Uri PreviewImageUri => |
|
|
|
new( |
|
|
|
new("https://raw.githubusercontent.com/invoke-ai/InvokeAI/main/docs/assets/canvas_preview.png"); |
|
|
|
"https://raw.githubusercontent.com/invoke-ai/InvokeAI/main/docs/assets/canvas_preview.png" |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override IEnumerable<SharedFolderMethod> AvailableSharedFolderMethods => |
|
|
|
public override IEnumerable<SharedFolderMethod> AvailableSharedFolderMethods => |
|
|
|
new[] { SharedFolderMethod.Symlink, SharedFolderMethod.None }; |
|
|
|
new[] { SharedFolderMethod.Symlink, SharedFolderMethod.None }; |
|
|
@ -63,63 +61,49 @@ public class InvokeAI : BaseGitPackage |
|
|
|
public override Dictionary<SharedFolderType, IReadOnlyList<string>> SharedFolders => |
|
|
|
public override Dictionary<SharedFolderType, IReadOnlyList<string>> SharedFolders => |
|
|
|
new() |
|
|
|
new() |
|
|
|
{ |
|
|
|
{ |
|
|
|
[SharedFolderType.StableDiffusion] = new[] |
|
|
|
[SharedFolderType.StableDiffusion] = new[] { Path.Combine(RelativeRootPath, "autoimport", "main") }, |
|
|
|
|
|
|
|
[SharedFolderType.Lora] = new[] { Path.Combine(RelativeRootPath, "autoimport", "lora") }, |
|
|
|
|
|
|
|
[SharedFolderType.TextualInversion] = new[] { Path.Combine(RelativeRootPath, "autoimport", "embedding") }, |
|
|
|
|
|
|
|
[SharedFolderType.ControlNet] = new[] { Path.Combine(RelativeRootPath, "autoimport", "controlnet") }, |
|
|
|
|
|
|
|
[SharedFolderType.InvokeIpAdapters15] = new[] |
|
|
|
{ |
|
|
|
{ |
|
|
|
Path.Combine(RelativeRootPath, "autoimport", "main") |
|
|
|
Path.Combine(RelativeRootPath, "models", "sd-1", "ip_adapter") |
|
|
|
}, |
|
|
|
}, |
|
|
|
[SharedFolderType.Lora] = new[] |
|
|
|
[SharedFolderType.InvokeIpAdaptersXl] = new[] |
|
|
|
{ |
|
|
|
{ |
|
|
|
Path.Combine(RelativeRootPath, "autoimport", "lora") |
|
|
|
Path.Combine(RelativeRootPath, "models", "sdxl", "ip_adapter") |
|
|
|
}, |
|
|
|
}, |
|
|
|
[SharedFolderType.TextualInversion] = new[] |
|
|
|
[SharedFolderType.InvokeClipVision] = new[] |
|
|
|
{ |
|
|
|
{ |
|
|
|
Path.Combine(RelativeRootPath, "autoimport", "embedding") |
|
|
|
Path.Combine(RelativeRootPath, "models", "any", "clip_vision") |
|
|
|
}, |
|
|
|
}, |
|
|
|
[SharedFolderType.ControlNet] = new[] |
|
|
|
[SharedFolderType.T2IAdapter] = new[] { Path.Combine(RelativeRootPath, "autoimport", "t2i_adapter") } |
|
|
|
{ |
|
|
|
|
|
|
|
Path.Combine(RelativeRootPath, "autoimport", "controlnet") |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
[SharedFolderType.IpAdapter] = new[] |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Path.Combine(RelativeRootPath, "autoimport", "ip_adapter") |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
[SharedFolderType.T2IAdapter] = new[] |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Path.Combine(RelativeRootPath, "autoimport", "t2i_adapter") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
public override Dictionary<SharedOutputType, IReadOnlyList<string>>? SharedOutputFolders => |
|
|
|
public override Dictionary<SharedOutputType, IReadOnlyList<string>>? SharedOutputFolders => |
|
|
|
new() |
|
|
|
new() { [SharedOutputType.Text2Img] = new[] { Path.Combine("invokeai-root", "outputs", "images") } }; |
|
|
|
{ |
|
|
|
|
|
|
|
[SharedOutputType.Text2Img] = new[] |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Path.Combine("invokeai-root", "outputs", "images") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override string OutputFolderName => Path.Combine("invokeai-root", "outputs", "images"); |
|
|
|
public override string OutputFolderName => Path.Combine("invokeai-root", "outputs", "images"); |
|
|
|
|
|
|
|
|
|
|
|
// https://github.com/invoke-ai/InvokeAI/blob/main/docs/features/CONFIGURATION.md |
|
|
|
// https://github.com/invoke-ai/InvokeAI/blob/main/docs/features/CONFIGURATION.md |
|
|
|
public override List<LaunchOptionDefinition> LaunchOptions => |
|
|
|
public override List<LaunchOptionDefinition> LaunchOptions => |
|
|
|
[ |
|
|
|
|
|
|
|
new LaunchOptionDefinition |
|
|
|
[ |
|
|
|
|
|
|
|
new LaunchOptionDefinition |
|
|
|
{ |
|
|
|
{ |
|
|
|
Name = "Host", |
|
|
|
Name = "Host", |
|
|
|
Type = LaunchOptionType.String, |
|
|
|
Type = LaunchOptionType.String, |
|
|
|
DefaultValue = "localhost", |
|
|
|
DefaultValue = "localhost", |
|
|
|
Options = ["--host"] |
|
|
|
Options = ["--host"] |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
new LaunchOptionDefinition |
|
|
|
new LaunchOptionDefinition |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
Name = "Port", |
|
|
|
Name = "Port", |
|
|
|
Type = LaunchOptionType.String, |
|
|
|
Type = LaunchOptionType.String, |
|
|
|
DefaultValue = "9090", |
|
|
|
DefaultValue = "9090", |
|
|
|
Options = ["--port"] |
|
|
|
Options = ["--port"] |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
new LaunchOptionDefinition |
|
|
|
new LaunchOptionDefinition |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
Name = "Allow Origins", |
|
|
|
Name = "Allow Origins", |
|
|
|
Description = |
|
|
|
Description = |
|
|
@ -129,15 +113,13 @@ public class InvokeAI : BaseGitPackage |
|
|
|
DefaultValue = "[]", |
|
|
|
DefaultValue = "[]", |
|
|
|
Options = ["--allow-origins"] |
|
|
|
Options = ["--allow-origins"] |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
new LaunchOptionDefinition |
|
|
|
new LaunchOptionDefinition |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
Name = "Always use CPU", |
|
|
|
Name = "Always use CPU", |
|
|
|
Type = LaunchOptionType.Bool, |
|
|
|
Type = LaunchOptionType.Bool, |
|
|
|
Options = ["--always_use_cpu"] |
|
|
|
Options = ["--always_use_cpu"] |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
new LaunchOptionDefinition |
|
|
|
new LaunchOptionDefinition |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
Name = "Precision", |
|
|
|
Name = "Precision", |
|
|
|
Type = LaunchOptionType.Bool, |
|
|
|
Type = LaunchOptionType.Bool, |
|
|
@ -148,16 +130,14 @@ public class InvokeAI : BaseGitPackage |
|
|
|
"--precision float32" |
|
|
|
"--precision float32" |
|
|
|
] |
|
|
|
] |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
new LaunchOptionDefinition |
|
|
|
new LaunchOptionDefinition |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
Name = "Aggressively free up GPU memory after each operation", |
|
|
|
Name = "Aggressively free up GPU memory after each operation", |
|
|
|
Type = LaunchOptionType.Bool, |
|
|
|
Type = LaunchOptionType.Bool, |
|
|
|
Options = ["--free_gpu_mem"] |
|
|
|
Options = ["--free_gpu_mem"] |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
LaunchOptionDefinition.Extras |
|
|
|
LaunchOptionDefinition.Extras |
|
|
|
]; |
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override IEnumerable<TorchVersion> AvailableTorchVersions => |
|
|
|
public override IEnumerable<TorchVersion> AvailableTorchVersions => |
|
|
|
new[] { TorchVersion.Cpu, TorchVersion.Cuda, TorchVersion.Rocm, TorchVersion.Mps }; |
|
|
|
new[] { TorchVersion.Cpu, TorchVersion.Cuda, TorchVersion.Rocm, TorchVersion.Mps }; |
|
|
@ -194,24 +174,19 @@ public class InvokeAI : BaseGitPackage |
|
|
|
venvRunner.EnvironmentVariables = GetEnvVars(installLocation); |
|
|
|
venvRunner.EnvironmentVariables = GetEnvVars(installLocation); |
|
|
|
progress?.Report(new ProgressReport(-1f, "Installing Package", isIndeterminate: true)); |
|
|
|
progress?.Report(new ProgressReport(-1f, "Installing Package", isIndeterminate: true)); |
|
|
|
|
|
|
|
|
|
|
|
var pipCommandArgs = |
|
|
|
var pipCommandArgs = "-e . --use-pep517 --extra-index-url https://download.pytorch.org/whl/cpu"; |
|
|
|
"-e . --use-pep517 --extra-index-url https://download.pytorch.org/whl/cpu"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (torchVersion) |
|
|
|
switch (torchVersion) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// If has Nvidia Gpu, install CUDA version |
|
|
|
// If has Nvidia Gpu, install CUDA version |
|
|
|
case TorchVersion.Cuda: |
|
|
|
case TorchVersion.Cuda: |
|
|
|
progress?.Report( |
|
|
|
progress?.Report(new ProgressReport(-1f, "Installing PyTorch for CUDA", isIndeterminate: true)); |
|
|
|
new ProgressReport(-1f, "Installing PyTorch for CUDA", isIndeterminate: true) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var args = new List<Argument>(); |
|
|
|
var args = new List<Argument>(); |
|
|
|
if (exists) |
|
|
|
if (exists) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var pipPackages = await venvRunner.PipList().ConfigureAwait(false); |
|
|
|
var pipPackages = await venvRunner.PipList().ConfigureAwait(false); |
|
|
|
var hasCuda121 = pipPackages.Any( |
|
|
|
var hasCuda121 = pipPackages.Any(p => p.Name == "torch" && p.Version.Contains("cu121")); |
|
|
|
p => p.Name == "torch" && p.Version.Contains("cu121") |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
if (!hasCuda121) |
|
|
|
if (!hasCuda121) |
|
|
|
{ |
|
|
|
{ |
|
|
|
args.Add("--upgrade"); |
|
|
|
args.Add("--upgrade"); |
|
|
@ -231,23 +206,18 @@ public class InvokeAI : BaseGitPackage |
|
|
|
.ConfigureAwait(false); |
|
|
|
.ConfigureAwait(false); |
|
|
|
|
|
|
|
|
|
|
|
Logger.Info("Starting InvokeAI install (CUDA)..."); |
|
|
|
Logger.Info("Starting InvokeAI install (CUDA)..."); |
|
|
|
pipCommandArgs = |
|
|
|
pipCommandArgs = "-e .[xformers] --use-pep517 --extra-index-url https://download.pytorch.org/whl/cu121"; |
|
|
|
"-e .[xformers] --use-pep517 --extra-index-url https://download.pytorch.org/whl/cu121"; |
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
// For AMD, Install ROCm version |
|
|
|
// For AMD, Install ROCm version |
|
|
|
case TorchVersion.Rocm: |
|
|
|
case TorchVersion.Rocm: |
|
|
|
await venvRunner |
|
|
|
await venvRunner |
|
|
|
.PipInstall( |
|
|
|
.PipInstall( |
|
|
|
new PipInstallArgs() |
|
|
|
new PipInstallArgs().WithTorch("==2.0.1").WithTorchVision().WithExtraIndex("rocm5.4.2"), |
|
|
|
.WithTorch("==2.0.1") |
|
|
|
|
|
|
|
.WithTorchVision() |
|
|
|
|
|
|
|
.WithExtraIndex("rocm5.4.2"), |
|
|
|
|
|
|
|
onConsoleOutput |
|
|
|
onConsoleOutput |
|
|
|
) |
|
|
|
) |
|
|
|
.ConfigureAwait(false); |
|
|
|
.ConfigureAwait(false); |
|
|
|
Logger.Info("Starting InvokeAI install (ROCm)..."); |
|
|
|
Logger.Info("Starting InvokeAI install (ROCm)..."); |
|
|
|
pipCommandArgs = |
|
|
|
pipCommandArgs = "-e . --use-pep517 --extra-index-url https://download.pytorch.org/whl/rocm5.4.2"; |
|
|
|
"-e . --use-pep517 --extra-index-url https://download.pytorch.org/whl/rocm5.4.2"; |
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
case TorchVersion.Mps: |
|
|
|
case TorchVersion.Mps: |
|
|
|
// For Apple silicon, use MPS |
|
|
|
// For Apple silicon, use MPS |
|
|
@ -260,9 +230,7 @@ public class InvokeAI : BaseGitPackage |
|
|
|
.PipInstall($"{pipCommandArgs}{(exists ? " --upgrade" : "")}", onConsoleOutput) |
|
|
|
.PipInstall($"{pipCommandArgs}{(exists ? " --upgrade" : "")}", onConsoleOutput) |
|
|
|
.ConfigureAwait(false); |
|
|
|
.ConfigureAwait(false); |
|
|
|
|
|
|
|
|
|
|
|
await venvRunner |
|
|
|
await venvRunner.PipInstall("rich packaging python-dotenv", onConsoleOutput).ConfigureAwait(false); |
|
|
|
.PipInstall("rich packaging python-dotenv", onConsoleOutput) |
|
|
|
|
|
|
|
.ConfigureAwait(false); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
progress?.Report(new ProgressReport(-1f, "Configuring InvokeAI", isIndeterminate: true)); |
|
|
|
progress?.Report(new ProgressReport(-1f, "Configuring InvokeAI", isIndeterminate: true)); |
|
|
|
|
|
|
|
|
|
|
@ -358,13 +326,7 @@ public class InvokeAI : BaseGitPackage |
|
|
|
{ |
|
|
|
{ |
|
|
|
onConsoleOutput?.Invoke(s); |
|
|
|
onConsoleOutput?.Invoke(s); |
|
|
|
|
|
|
|
|
|
|
|
if ( |
|
|
|
if (spam3 && s.Text.Contains("[3] Accept the best guess;", StringComparison.OrdinalIgnoreCase)) |
|
|
|
spam3 |
|
|
|
|
|
|
|
&& s.Text.Contains( |
|
|
|
|
|
|
|
"[3] Accept the best guess;", |
|
|
|
|
|
|
|
StringComparison.OrdinalIgnoreCase |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
VenvRunner.Process?.StandardInput.WriteLine("3"); |
|
|
|
VenvRunner.Process?.StandardInput.WriteLine("3"); |
|
|
|
return; |
|
|
|
return; |
|
|
@ -382,17 +344,11 @@ public class InvokeAI : BaseGitPackage |
|
|
|
OnStartupComplete(WebUrl); |
|
|
|
OnStartupComplete(WebUrl); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
VenvRunner.RunDetached( |
|
|
|
VenvRunner.RunDetached($"-c \"{code}\" {arguments}".TrimEnd(), HandleConsoleOutput, OnExit); |
|
|
|
$"-c \"{code}\" {arguments}".TrimEnd(), |
|
|
|
|
|
|
|
HandleConsoleOutput, |
|
|
|
|
|
|
|
OnExit |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
var result = await VenvRunner |
|
|
|
var result = await VenvRunner.Run($"-c \"{code}\" {arguments}".TrimEnd()).ConfigureAwait(false); |
|
|
|
.Run($"-c \"{code}\" {arguments}".TrimEnd()) |
|
|
|
|
|
|
|
.ConfigureAwait(false); |
|
|
|
|
|
|
|
onConsoleOutput?.Invoke(new ProcessOutput { Text = result.StandardOutput }); |
|
|
|
onConsoleOutput?.Invoke(new ProcessOutput { Text = result.StandardOutput }); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|