Browse Source

Fix controlnet node temporary conditioning

pull/333/head
Ionite 12 months ago
parent
commit
5a8039f470
No known key found for this signature in database
  1. 8
      StabilityMatrix.Avalonia/Models/Inference/ModuleApplyStepEventArgs.cs
  2. 34
      StabilityMatrix.Avalonia/ViewModels/Inference/SamplerCardViewModel.cs

8
StabilityMatrix.Avalonia/Models/Inference/ModuleApplyStepEventArgs.cs

@ -42,6 +42,14 @@ public class ModuleApplyStepEventArgs : EventArgs
ConditioningNodeConnection Negative ConditioningNodeConnection Negative
) Conditioning { get; set; } ) Conditioning { get; set; }
/// <summary>
/// Temporary refiner conditioning apply step, used by samplers to apply control net.
/// </summary>
public (
ConditioningNodeConnection Positive,
ConditioningNodeConnection Negative
) RefinerConditioning { get; set; }
/// <summary> /// <summary>
/// Temporary model apply step, used by samplers to apply control net. /// Temporary model apply step, used by samplers to apply control net.
/// </summary> /// </summary>

34
StabilityMatrix.Avalonia/ViewModels/Inference/SamplerCardViewModel.cs

@ -108,6 +108,16 @@ public partial class SamplerCardViewModel
/// <inheritdoc /> /// <inheritdoc />
public void ApplyStep(ModuleApplyStepEventArgs e) public void ApplyStep(ModuleApplyStepEventArgs e)
{ {
// Provide temp values
e.Temp.Conditioning = (
e.Builder.Connections.GetRefinerOrBaseConditioning(),
e.Builder.Connections.GetRefinerOrBaseNegativeConditioning()
);
e.Temp.RefinerConditioning = (
e.Builder.Connections.RefinerConditioning!,
e.Builder.Connections.RefinerNegativeConditioning!
);
// Apply steps from our addons // Apply steps from our addons
ApplyAddonSteps(e); ApplyAddonSteps(e);
@ -157,12 +167,8 @@ public partial class SamplerCardViewModel
Scheduler = e.Builder.Connections.PrimaryScheduler?.Name!, Scheduler = e.Builder.Connections.PrimaryScheduler?.Name!,
Steps = Steps, Steps = Steps,
Cfg = CfgScale, Cfg = CfgScale,
Positive = Positive = e.Temp.Conditioning.Positive,
e.Builder.Connections.BaseConditioning Negative = e.Temp.Conditioning.Negative,
?? throw new ArgumentException("No BaseConditioning"),
Negative =
e.Builder.Connections.BaseNegativeConditioning
?? throw new ArgumentException("No BaseNegativeConditioning"),
LatentImage = primaryLatent, LatentImage = primaryLatent,
Denoise = DenoiseStrength, Denoise = DenoiseStrength,
} }
@ -186,12 +192,8 @@ public partial class SamplerCardViewModel
Cfg = CfgScale, Cfg = CfgScale,
SamplerName = e.Builder.Connections.PrimarySampler?.Name!, SamplerName = e.Builder.Connections.PrimarySampler?.Name!,
Scheduler = e.Builder.Connections.PrimaryScheduler?.Name!, Scheduler = e.Builder.Connections.PrimaryScheduler?.Name!,
Positive = Positive = e.Temp.Conditioning.Positive,
e.Builder.Connections.BaseConditioning Negative = e.Temp.Conditioning.Negative,
?? throw new ArgumentException("No BaseConditioning"),
Negative =
e.Builder.Connections.BaseNegativeConditioning
?? throw new ArgumentException("No BaseNegativeConditioning"),
LatentImage = primaryLatent, LatentImage = primaryLatent,
StartAtStep = 0, StartAtStep = 0,
EndAtStep = Steps, EndAtStep = Steps,
@ -213,12 +215,8 @@ public partial class SamplerCardViewModel
Cfg = CfgScale, Cfg = CfgScale,
SamplerName = e.Builder.Connections.PrimarySampler?.Name!, SamplerName = e.Builder.Connections.PrimarySampler?.Name!,
Scheduler = e.Builder.Connections.PrimaryScheduler?.Name!, Scheduler = e.Builder.Connections.PrimaryScheduler?.Name!,
Positive = Positive = e.Temp.RefinerConditioning.Positive,
e.Builder.Connections.RefinerConditioning Negative = e.Temp.RefinerConditioning.Negative,
?? throw new ArgumentException("No RefinerConditioning"),
Negative =
e.Builder.Connections.RefinerNegativeConditioning
?? throw new ArgumentException("No RefinerNegativeConditioning"),
// Connect to previous sampler // Connect to previous sampler
LatentImage = sampler.Output, LatentImage = sampler.Output,
StartAtStep = Steps, StartAtStep = Steps,

Loading…
Cancel
Save