Browse Source

Add layer diffuse selection for SD1.5 / SDXL

pull/629/head
Ionite 8 months ago
parent
commit
660dad4245
No known key found for this signature in database
  1. 22
      StabilityMatrix.Avalonia/ViewModels/Inference/LayerDiffuseCardViewModel.cs
  2. 6
      StabilityMatrix.Core/Models/Api/Comfy/Nodes/ComfyNodeBuilder.cs
  3. 12
      StabilityMatrix.Core/Models/Inference/LayerDiffuseMode.cs

22
StabilityMatrix.Avalonia/ViewModels/Inference/LayerDiffuseCardViewModel.cs

@ -37,6 +37,24 @@ public partial class LayerDiffuseCardViewModel : LoadableViewModelBase, IComfySt
if (SelectedMode == LayerDiffuseMode.None)
return;
var sdType = SelectedMode switch
{
LayerDiffuseMode.GenerateForegroundWithTransparencySD15 => "SD15",
LayerDiffuseMode.GenerateForegroundWithTransparencySDXL => "SDXL",
LayerDiffuseMode.None => throw new ArgumentOutOfRangeException(),
_ => throw new ArgumentOutOfRangeException()
};
// Choose config based on mode
var config = SelectedMode switch
{
LayerDiffuseMode.GenerateForegroundWithTransparencySD15
=> "SD15, Attention Injection, attn_sharing",
LayerDiffuseMode.GenerateForegroundWithTransparencySDXL => "SDXL, Conv Injection",
LayerDiffuseMode.None => throw new ArgumentOutOfRangeException(),
_ => throw new ArgumentOutOfRangeException()
};
foreach (var modelConnections in e.Temp.Models.Values)
{
var layerDiffuseApply = e.Nodes.AddTypedNode(
@ -44,7 +62,7 @@ public partial class LayerDiffuseCardViewModel : LoadableViewModelBase, IComfySt
{
Name = e.Nodes.GetUniqueName($"LayerDiffuseApply_{modelConnections.Name}"),
Model = modelConnections.Model,
Config = "SD15, Attention Injection, attn_sharing",
Config = config,
Weight = Weight,
}
);
@ -71,7 +89,7 @@ public partial class LayerDiffuseCardViewModel : LoadableViewModelBase, IComfySt
Name = applyArgs.Nodes.GetUniqueName("LayerDiffuseDecode"),
Samples = latent,
Images = primaryImage,
SdVersion = "SD15",
SdVersion = sdType
}
);

6
StabilityMatrix.Core/Models/Api/Comfy/Nodes/ComfyNodeBuilder.cs

@ -391,6 +391,12 @@ public class ComfyNodeBuilder
{
public required ModelNodeConnection Model { get; init; }
/// <summary>
/// Available configs:
/// <para>SD15, Attention Injection, attn_sharing</para>
/// <para>SDXL, Conv Injection</para>
/// <para>SDXL, Attention Injection</para>
/// </summary>
public required string Config { get; init; }
[Range(-1d, 3d)]

12
StabilityMatrix.Core/Models/Inference/LayerDiffuseMode.cs

@ -11,8 +11,14 @@ public enum LayerDiffuseMode
None,
/// <summary>
/// Generate foreground only with transparency.
/// Generate foreground only with transparency. SD1.5
/// </summary>
[Display(Name = "Generate Foreground with Transparency")]
GenerateForegroundWithTransparency,
[Display(Name = "(SD 1.5) Generate Foreground with Transparency")]
GenerateForegroundWithTransparencySD15,
/// <summary>
/// Generate foreground only with transparency. SDXL
/// </summary>
[Display(Name = "(SDXL) Generate Foreground with Transparency")]
GenerateForegroundWithTransparencySDXL,
}

Loading…
Cancel
Save