Multi-Platform Package Manager for Stable Diffusion
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

44 lines
1.3 KiB

using System.Text.Json.Nodes;
using CommunityToolkit.Mvvm.ComponentModel;
using StabilityMatrix.Avalonia.Controls;
using StabilityMatrix.Avalonia.Models.Inference;
using StabilityMatrix.Avalonia.Services;
using StabilityMatrix.Avalonia.ViewModels.Base;
using StabilityMatrix.Core.Attributes;
using StabilityMatrix.Core.Models.Api.Comfy;
namespace StabilityMatrix.Avalonia.ViewModels.Inference;
[View(typeof(UpscalerCard))]
public partial class UpscalerCardViewModel : LoadableViewModelBase
{
[ObservableProperty] private double scale = 1;
[ObservableProperty] private ComfyUpscaler? selectedUpscaler;
public IInferenceClientManager ClientManager { get; }
public UpscalerCardViewModel(IInferenceClientManager clientManager)
{
ClientManager = clientManager;
}
/// <inheritdoc />
public override void LoadStateFromJsonObject(JsonObject state)
{
var model = DeserializeModel<UpscalerCardModel>(state);
Scale = model.Scale;
SelectedUpscaler = model.SelectedUpscaler;
}
/// <inheritdoc />
public override JsonObject SaveStateToJsonObject()
{
return SerializeModel(new UpscalerCardModel
{
Scale = Scale,
SelectedUpscaler = SelectedUpscaler
});
}
}