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",
"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)]
IpAdapter,
[Description("IP Adapters (Diffusers)")]
[ConvertTo<SharedFolderType>(SharedFolderType.IpAdapter)]
[Description("IP Adapters (Diffusers SD1.5)")]
[ConvertTo<SharedFolderType>(SharedFolderType.InvokeIpAdapters15)]
DiffusersIpAdapter,
[Description("IP Adapters (Diffusers SDXL)")]
[ConvertTo<SharedFolderType>(SharedFolderType.InvokeIpAdaptersXl)]
DiffusersIpAdapterXl,
[Description("CLIP Vision (Diffusers)")]
[ConvertTo<SharedFolderType>(SharedFolderType.InvokeClipVision)]
DiffusersClipVision,
[Description("T2I Adapters")]
[ConvertTo<SharedFolderType>(SharedFolderType.T2IAdapter)]
T2IAdapter,

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

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

28
StabilityMatrix.Avalonia/Views/HuggingFacePage.axaml

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

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

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

4
StabilityMatrix.Core/Models/SharedFolderType.cs

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

Loading…
Cancel
Save