Browse Source

More module localization

pull/333/head
Ionite 12 months ago
parent
commit
b136590c3c
No known key found for this signature in database
  1. 18
      StabilityMatrix.Avalonia/Languages/Resources.Designer.cs
  2. 6
      StabilityMatrix.Avalonia/Languages/Resources.resx
  3. 21
      StabilityMatrix.Avalonia/ViewModels/Inference/Modules/SaveImageModule.cs
  4. 43
      StabilityMatrix.Avalonia/ViewModels/Inference/SamplerCardViewModel.cs

18
StabilityMatrix.Avalonia/Languages/Resources.Designer.cs generated

@ -599,6 +599,15 @@ namespace StabilityMatrix.Avalonia.Languages {
} }
} }
/// <summary>
/// Looks up a localized string similar to Addons.
/// </summary>
public static string Label_Addons {
get {
return ResourceManager.GetString("Label_Addons", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Add Stability Matrix to the Start Menu. /// Looks up a localized string similar to Add Stability Matrix to the Start Menu.
/// </summary> /// </summary>
@ -1760,6 +1769,15 @@ namespace StabilityMatrix.Avalonia.Languages {
} }
} }
/// <summary>
/// Looks up a localized string similar to Save Intermediate Image.
/// </summary>
public static string Label_SaveIntermediateImage {
get {
return ResourceManager.GetString("Label_SaveIntermediateImage", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Search.... /// Looks up a localized string similar to Search....
/// </summary> /// </summary>

6
StabilityMatrix.Avalonia/Languages/Resources.resx

@ -858,4 +858,10 @@
<data name="Label_SystemInformation" xml:space="preserve"> <data name="Label_SystemInformation" xml:space="preserve">
<value>System Information</value> <value>System Information</value>
</data> </data>
<data name="Label_Addons" xml:space="preserve">
<value>Addons</value><comment>Inference Sampler Addons</comment>
</data>
<data name="Label_SaveIntermediateImage" xml:space="preserve">
<value>Save Intermediate Image</value><comment>Inference module step to save an intermediate image</comment>
</data>
</root> </root>

21
StabilityMatrix.Avalonia/ViewModels/Inference/Modules/SaveImageModule.cs

@ -1,4 +1,5 @@
using StabilityMatrix.Avalonia.Models.Inference; using StabilityMatrix.Avalonia.Languages;
using StabilityMatrix.Avalonia.Models.Inference;
using StabilityMatrix.Avalonia.Services; using StabilityMatrix.Avalonia.Services;
using StabilityMatrix.Avalonia.ViewModels.Base; using StabilityMatrix.Avalonia.ViewModels.Base;
using StabilityMatrix.Core.Attributes; using StabilityMatrix.Core.Attributes;
@ -14,19 +15,21 @@ public class SaveImageModule : ModuleBase
public SaveImageModule(ServiceManager<ViewModelBase> vmFactory) public SaveImageModule(ServiceManager<ViewModelBase> vmFactory)
: base(vmFactory) : base(vmFactory)
{ {
Title = "Save Intermediary Image"; Title = Resources.Label_SaveIntermediateImage;
} }
/// <inheritdoc /> /// <inheritdoc />
protected override void OnApplyStep(ModuleApplyStepEventArgs e) protected override void OnApplyStep(ModuleApplyStepEventArgs e)
{ {
var preview = e.Builder.Nodes.AddTypedNode( var preview = e.Builder
new ComfyNodeBuilder.PreviewImage .Nodes
{ .AddTypedNode(
Name = e.Builder.Nodes.GetUniqueName("SaveIntermediaryImage"), new ComfyNodeBuilder.PreviewImage
Images = e.Builder.GetPrimaryAsImage() {
} Name = e.Builder.Nodes.GetUniqueName("SaveIntermediateImage"),
); Images = e.Builder.GetPrimaryAsImage()
}
);
e.Builder.Connections.OutputNodes.Add(preview); e.Builder.Connections.OutputNodes.Add(preview);
} }

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

@ -1,10 +1,11 @@
using System; using System;
using System.Collections.Immutable;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Linq; using System.Linq;
using System.Runtime.Serialization;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.ComponentModel;
using StabilityMatrix.Avalonia.Controls; using StabilityMatrix.Avalonia.Controls;
using StabilityMatrix.Avalonia.Languages;
using StabilityMatrix.Avalonia.Models; using StabilityMatrix.Avalonia.Models;
using StabilityMatrix.Avalonia.Models.Inference; using StabilityMatrix.Avalonia.Models.Inference;
using StabilityMatrix.Avalonia.Services; using StabilityMatrix.Avalonia.Services;
@ -21,10 +22,7 @@ namespace StabilityMatrix.Avalonia.ViewModels.Inference;
[View(typeof(SamplerCard))] [View(typeof(SamplerCard))]
[ManagedService] [ManagedService]
[Transient] [Transient]
public partial class SamplerCardViewModel public partial class SamplerCardViewModel : LoadableViewModelBase, IParametersLoadableState, IComfyStep
: LoadableViewModelBase,
IParametersLoadableState,
IComfyStep
{ {
public const string ModuleKey = "Sampler"; public const string ModuleKey = "Sampler";
@ -80,15 +78,12 @@ public partial class SamplerCardViewModel
private int TotalSteps => Steps + RefinerSteps; private int TotalSteps => Steps + RefinerSteps;
public SamplerCardViewModel( public SamplerCardViewModel(IInferenceClientManager clientManager, ServiceManager<ViewModelBase> vmFactory)
IInferenceClientManager clientManager,
ServiceManager<ViewModelBase> vmFactory
)
{ {
ClientManager = clientManager; ClientManager = clientManager;
ModulesCardViewModel = vmFactory.Get<StackEditableCardViewModel>(modulesCard => ModulesCardViewModel = vmFactory.Get<StackEditableCardViewModel>(modulesCard =>
{ {
modulesCard.Title = "Addons"; modulesCard.Title = Resources.Label_Addons;
modulesCard.AvailableModules = new[] { typeof(FreeUModule), typeof(ControlNetModule) }; modulesCard.AvailableModules = new[] { typeof(FreeUModule), typeof(ControlNetModule) };
modulesCard.InitializeDefaults(); modulesCard.InitializeDefaults();
}); });
@ -146,8 +141,7 @@ public partial class SamplerCardViewModel
var primaryLatent = e.Builder.GetPrimaryAsLatent(vae); var primaryLatent = e.Builder.GetPrimaryAsLatent(vae);
// Set primary sampler and scheduler // Set primary sampler and scheduler
e.Builder.Connections.PrimarySampler = e.Builder.Connections.PrimarySampler = SelectedSampler ?? throw new ValidationException("Sampler not selected");
SelectedSampler ?? throw new ValidationException("Sampler not selected");
e.Builder.Connections.PrimaryScheduler = e.Builder.Connections.PrimaryScheduler =
SelectedScheduler ?? throw new ValidationException("Scheduler not selected"); SelectedScheduler ?? throw new ValidationException("Scheduler not selected");
@ -159,9 +153,7 @@ public partial class SamplerCardViewModel
new ComfyNodeBuilder.KSampler new ComfyNodeBuilder.KSampler
{ {
Name = "Sampler", Name = "Sampler",
Model = Model = e.Builder.Connections.BaseModel ?? throw new ArgumentException("No BaseModel"),
e.Builder.Connections.BaseModel
?? throw new ArgumentException("No BaseModel"),
Seed = e.Builder.Connections.Seed, Seed = e.Builder.Connections.Seed,
SamplerName = e.Builder.Connections.PrimarySampler?.Name!, SamplerName = e.Builder.Connections.PrimarySampler?.Name!,
Scheduler = e.Builder.Connections.PrimaryScheduler?.Name!, Scheduler = e.Builder.Connections.PrimaryScheduler?.Name!,
@ -183,9 +175,7 @@ public partial class SamplerCardViewModel
new ComfyNodeBuilder.KSamplerAdvanced new ComfyNodeBuilder.KSamplerAdvanced
{ {
Name = "Sampler", Name = "Sampler",
Model = Model = e.Builder.Connections.BaseModel ?? throw new ArgumentException("No BaseModel"),
e.Builder.Connections.BaseModel
?? throw new ArgumentException("No BaseModel"),
AddNoise = true, AddNoise = true,
NoiseSeed = e.Builder.Connections.Seed, NoiseSeed = e.Builder.Connections.Seed,
Steps = TotalSteps, Steps = TotalSteps,
@ -206,9 +196,7 @@ public partial class SamplerCardViewModel
new ComfyNodeBuilder.KSamplerAdvanced new ComfyNodeBuilder.KSamplerAdvanced
{ {
Name = "Refiner_Sampler", Name = "Refiner_Sampler",
Model = Model = e.Builder.Connections.RefinerModel ?? throw new ArgumentException("No RefinerModel"),
e.Builder.Connections.RefinerModel
?? throw new ArgumentException("No RefinerModel"),
AddNoise = false, AddNoise = false,
NoiseSeed = e.Builder.Connections.Seed, NoiseSeed = e.Builder.Connections.Seed,
Steps = TotalSteps, Steps = TotalSteps,
@ -254,18 +242,11 @@ public partial class SamplerCardViewModel
if ( if (
!string.IsNullOrEmpty(parameters.Sampler) !string.IsNullOrEmpty(parameters.Sampler)
&& GenerationParametersConverter.TryGetSamplerScheduler( && GenerationParametersConverter.TryGetSamplerScheduler(parameters.Sampler, out var samplerScheduler)
parameters.Sampler,
out var samplerScheduler
)
) )
{ {
SelectedSampler = ClientManager.Samplers.FirstOrDefault( SelectedSampler = ClientManager.Samplers.FirstOrDefault(s => s == samplerScheduler.Sampler);
s => s == samplerScheduler.Sampler SelectedScheduler = ClientManager.Schedulers.FirstOrDefault(s => s == samplerScheduler.Scheduler);
);
SelectedScheduler = ClientManager.Schedulers.FirstOrDefault(
s => s == samplerScheduler.Scheduler
);
} }
} }

Loading…
Cancel
Save