Browse Source

Add links for invoke IP adapter stuff & finish hf-packages.json & fix drag/drop import

pull/324/head
JT 12 months ago
parent
commit
570e40ca97
  1. 209
      StabilityMatrix.Avalonia/Assets/hf-packages.json
  2. 12
      StabilityMatrix.Avalonia/Models/HuggingFace/HuggingFaceModelType.cs
  3. 10
      StabilityMatrix.Avalonia/Views/CheckpointsPage.axaml.cs
  4. 28
      StabilityMatrix.Avalonia/Views/HuggingFacePage.axaml
  5. 110
      StabilityMatrix.Core/Models/Packages/InvokeAI.cs
  6. 4
      StabilityMatrix.Core/Models/SharedFolderType.cs

209
StabilityMatrix.Avalonia/Assets/hf-packages.json

@ -331,5 +331,214 @@
], ],
"Subfolder": "shuffle", "Subfolder": "shuffle",
"LicenseType": "Open RAIL" "LicenseType": "Open RAIL"
},
{
"ModelCategory": "DiffusersClipVision",
"ModelName": "IP Adapter Encoder",
"RepositoryPath": "InvokeAI/ip_adapter_sd_image_encoder",
"Files": [
"config.json",
"model.safetensors"
],
"Subfolder": "ip_adapter_sd_image_encoder",
"LicenseType": "Apache 2.0"
},
{
"ModelCategory": "DiffusersClipVision",
"ModelName": "IP Adapter Encoder (SDXL)",
"RepositoryPath": "InvokeAI/ip_adapter_sdxl_image_encoder",
"Files": [
"config.json",
"model.safetensors"
],
"Subfolder": "ip_adapter_sd_image_encoder",
"LicenseType": "Apache 2.0"
},
{
"ModelCategory": "DiffusersIpAdapter",
"ModelName": "SD 1.5 Adapter",
"RepositoryPath": "InvokeAI/ip_adapter_sd15",
"Files": [
"image_encoder.txt",
"ip_adapter.bin"
],
"Subfolder": "ip_adapter_sd15",
"LicenseType": "Apache 2.0"
},
{
"ModelCategory": "DiffusersIpAdapter",
"ModelName": "SD 1.5 Light Adapter",
"RepositoryPath": "InvokeAI/ip_adapter_sd15_light",
"Files": [
"image_encoder.txt",
"ip_adapter.bin"
],
"Subfolder": "ip_adapter_sd15_light",
"LicenseType": "Apache 2.0"
},
{
"ModelCategory": "DiffusersIpAdapter",
"ModelName": "SD 1.5 Plus Adapter",
"RepositoryPath": "InvokeAI/ip_adapter_plus_sd15",
"Files": [
"image_encoder.txt",
"ip_adapter.bin"
],
"Subfolder": "ip_adapter_plus_sd15",
"LicenseType": "Apache 2.0"
},
{
"ModelCategory": "DiffusersIpAdapter",
"ModelName": "SD 1.5 Face Plus Adapter",
"RepositoryPath": "InvokeAI/ip_adapter_plus_face_sd15",
"Files": [
"image_encoder.txt",
"ip_adapter.bin"
],
"Subfolder": "ip_adapter_plus_face_sd15",
"LicenseType": "Apache 2.0"
},
{
"ModelCategory": "DiffusersIpAdapterXl",
"ModelName": "SDXL Adapter",
"RepositoryPath": "InvokeAI/ip_adapter_sdxl",
"Files": [
"image_encoder.txt",
"ip_adapter.bin"
],
"Subfolder": "ip_adapter_sdxl",
"LicenseType": "Apache 2.0"
},
{
"ModelCategory": "DiffusersIpAdapterXl",
"ModelName": "SDXL Plus Adapter",
"RepositoryPath": "InvokeAI/ip-adapter-plus_sdxl_vit-h",
"Files": [
"image_encoder.txt",
"ip_adapter.bin"
],
"Subfolder": "ip_adapter_plus_sdxl_vit-h",
"LicenseType": "Apache 2.0"
},
{
"ModelCategory": "DiffusersIpAdapterXl",
"ModelName": "SDXL Face Plus Adapter",
"RepositoryPath": "InvokeAI/ip-adapter-plus-face_sdxl_vit-h",
"Files": [
"image_encoder.txt",
"ip_adapter.bin"
],
"Subfolder": "ip_adapter_plus_face_sdxl_vit-h",
"LicenseType": "CreativeML Open RAIL-M"
},
{
"ModelCategory": "DiffusersT2IAdapter",
"ModelName": "Sketch",
"RepositoryPath": "TencentARC/t2iadapter_sketch_sd15v2",
"Files": [
"config.json",
"diffusion_pytorch_model.bin"
],
"Subfolder": "t2iadapter_sketch_sd15v2",
"LicenseType": "Apache 2.0"
},
{
"ModelCategory": "DiffusersT2IAdapter",
"ModelName": "Depth",
"RepositoryPath": "TencentARC/t2iadapter_depth_sd15v2",
"Files": [
"config.json",
"diffusion_pytorch_model.bin"
],
"Subfolder": "t2iadapter_depth_sd15v2",
"LicenseType": "Apache 2.0"
},
{
"ModelCategory": "DiffusersT2IAdapter",
"ModelName": "Canny",
"RepositoryPath": "TencentARC/t2iadapter_canny_sd15v2",
"Files": [
"config.json",
"diffusion_pytorch_model.bin"
],
"Subfolder": "t2iadapter_canny_sd15v2",
"LicenseType": "Apache 2.0"
},
{
"ModelCategory": "DiffusersT2IAdapter",
"ModelName": "Depth-Zoe",
"RepositoryPath": "TencentARC/t2iadapter_zoedepth_sd15v1",
"Files": [
"config.json",
"diffusion_pytorch_model.bin"
],
"Subfolder": "t2iadapter_zoedepth_sd15v1",
"LicenseType": "Apache 2.0"
},
{
"ModelCategory": "DiffusersT2IAdapter",
"ModelName": "Sketch (SDXL)",
"RepositoryPath": "TencentARC/t2i-adapter-sketch-sdxl-1.0",
"Files": [
"config.json",
"diffusion_pytorch_model.safetensors"
],
"Subfolder": "t2i-adapter-sketch-sdxl-1.0",
"LicenseType": "Apache 2.0"
},
{
"ModelCategory": "DiffusersT2IAdapter",
"ModelName": "Depth-Zoe (SDXL)",
"RepositoryPath": "TencentARC/t2i-adapter-depth-zoe-sdxl-1.0",
"Files": [
"config.json",
"diffusion_pytorch_model.safetensors"
],
"Subfolder": "t2i-adapter-depth-zoe-sdxl-1.0",
"LicenseType": "Apache 2.0"
},
{
"ModelCategory": "DiffusersT2IAdapter",
"ModelName": "OpenPose (SDXL)",
"RepositoryPath": "TencentARC/t2i-adapter-openpose-sdxl-1.0",
"Files": [
"config.json",
"diffusion_pytorch_model.safetensors"
],
"Subfolder": "t2i-adapter-openpose-sdxl-1.0",
"LicenseType": "Apache 2.0"
},
{
"ModelCategory": "DiffusersT2IAdapter",
"ModelName": "Depth-MiDaS (SDXL)",
"RepositoryPath": "TencentARC/t2i-adapter-depth-midas-sdxl-1.0",
"Files": [
"config.json",
"diffusion_pytorch_model.safetensors"
],
"Subfolder": "t2i-adapter-depth-midas-sdxl-1.0",
"LicenseType": "Apache 2.0"
},
{
"ModelCategory": "DiffusersT2IAdapter",
"ModelName": "LineArt (SDXL)",
"RepositoryPath": "TencentARC/t2i-adapter-lineart-sdxl-1.0",
"Files": [
"config.json",
"diffusion_pytorch_model.safetensors"
],
"Subfolder": "t2i-adapter-lineart-sdxl-1.0",
"LicenseType": "Apache 2.0"
},
{
"ModelCategory": "DiffusersT2IAdapter",
"ModelName": "Canny (SDXL)",
"RepositoryPath": "TencentARC/t2i-adapter-canny-sdxl-1.0",
"Files": [
"config.json",
"diffusion_pytorch_model.safetensors"
],
"Subfolder": "t2i-adapter-canny-sdxl-1.0",
"LicenseType": "Apache 2.0"
} }
] ]

12
StabilityMatrix.Avalonia/Models/HuggingFace/HuggingFaceModelType.cs

@ -24,10 +24,18 @@ public enum HuggingFaceModelType
[ConvertTo<SharedFolderType>(SharedFolderType.IpAdapter)] [ConvertTo<SharedFolderType>(SharedFolderType.IpAdapter)]
IpAdapter, IpAdapter,
[Description("IP Adapters (Diffusers)")] [Description("IP Adapters (Diffusers SD1.5)")]
[ConvertTo<SharedFolderType>(SharedFolderType.IpAdapter)] [ConvertTo<SharedFolderType>(SharedFolderType.InvokeIpAdapters15)]
DiffusersIpAdapter, DiffusersIpAdapter,
[Description("IP Adapters (Diffusers SDXL)")]
[ConvertTo<SharedFolderType>(SharedFolderType.InvokeIpAdaptersXl)]
DiffusersIpAdapterXl,
[Description("CLIP Vision (Diffusers)")]
[ConvertTo<SharedFolderType>(SharedFolderType.InvokeClipVision)]
DiffusersClipVision,
[Description("T2I Adapters")] [Description("T2I Adapters")]
[ConvertTo<SharedFolderType>(SharedFolderType.T2IAdapter)] [ConvertTo<SharedFolderType>(SharedFolderType.T2IAdapter)]
T2IAdapter, T2IAdapter,

10
StabilityMatrix.Avalonia/Views/CheckpointsPage.axaml.cs

@ -69,7 +69,10 @@ public partial class CheckpointsPage : UserControlBase
case CheckpointFolder folder: case CheckpointFolder folder:
{ {
if (e.Data.Get("Context") is not CheckpointFile file) if (e.Data.Get("Context") is not CheckpointFile file)
return; {
await folder.OnDrop(e);
break;
}
var filePath = new FilePath(file.FilePath); var filePath = new FilePath(file.FilePath);
if (filePath.Directory?.FullPath != folder.DirectoryPath) if (filePath.Directory?.FullPath != folder.DirectoryPath)
@ -81,7 +84,10 @@ public partial class CheckpointsPage : UserControlBase
case CheckpointFile file: case CheckpointFile file:
{ {
if (e.Data.Get("Context") is not CheckpointFile dragFile) if (e.Data.Get("Context") is not CheckpointFile dragFile)
return; {
await file.ParentFolder.OnDrop(e);
break;
}
var parentFolder = file.ParentFolder; var parentFolder = file.ParentFolder;
var dragFilePath = new FilePath(dragFile.FilePath); var dragFilePath = new FilePath(dragFile.FilePath);

28
StabilityMatrix.Avalonia/Views/HuggingFacePage.axaml

@ -169,20 +169,20 @@
</DataTemplate> </DataTemplate>
</ItemsRepeater.ItemTemplate> </ItemsRepeater.ItemTemplate>
</ItemsRepeater> </ItemsRepeater>
<Expander Grid.Column="0" <!-- <Expander Grid.Column="0" -->
Grid.ColumnSpan="2" <!-- Grid.ColumnSpan="2" -->
Grid.Row="3" <!-- Grid.Row="3" -->
Header="Manual Model Download"> <!-- Header="Manual Model Download"> -->
<Grid RowDefinitions="Auto, Auto" ColumnDefinitions="*, Auto"> <!-- <Grid RowDefinitions="Auto, Auto" ColumnDefinitions="*, Auto"> -->
<TextBox Grid.Row="1" Grid.Column="0" <!-- <TextBox Grid.Row="1" Grid.Column="0" -->
Watermark="Enter HuggingFace repo URL" <!-- Watermark="Enter HuggingFace repo URL" -->
Margin="0,8" /> <!-- Margin="0,8" /> -->
<Button Grid.Row="1" Grid.Column="1" <!-- <Button Grid.Row="1" Grid.Column="1" -->
Margin="8,8,0,8" <!-- Margin="8,8,0,8" -->
Classes="accent" <!-- Classes="accent" -->
Content="Import" /> <!-- Content="Import" /> -->
</Grid> <!-- </Grid> -->
</Expander> <!-- </Expander> -->
</Grid> </Grid>
</ScrollViewer> </ScrollViewer>
</controls:UserControlBase> </controls:UserControlBase>

110
StabilityMatrix.Core/Models/Packages/InvokeAI.cs

@ -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 });
} }
} }

4
StabilityMatrix.Core/Models/SharedFolderType.cs

@ -35,4 +35,8 @@ public enum SharedFolderType
AfterDetailer = 1 << 21, AfterDetailer = 1 << 21,
IpAdapter = 1 << 22, IpAdapter = 1 << 22,
T2IAdapter = 1 << 23, T2IAdapter = 1 << 23,
InvokeIpAdapters15 = 1 << 24,
InvokeIpAdaptersXl = 1 << 25,
InvokeClipVision = 1 << 26,
} }

Loading…
Cancel
Save