mirror of
https://github.com/DarthAffe/StableDiffusion.NET.git
synced 2025-12-12 21:38:45 +00:00
Made parameters of models public
This commit is contained in:
parent
23fc44485a
commit
da9f612c03
@ -12,7 +12,7 @@ public sealed unsafe class DiffusionModel : IDisposable
|
||||
|
||||
private bool _disposed;
|
||||
|
||||
private readonly DiffusionModelParameter _parameter;
|
||||
public DiffusionModelParameter ModelParameter { get; }
|
||||
|
||||
private Native.sd_ctx_t* _ctx;
|
||||
|
||||
@ -20,13 +20,13 @@ public sealed unsafe class DiffusionModel : IDisposable
|
||||
|
||||
#region Constructors
|
||||
|
||||
public DiffusionModel(DiffusionModelParameter parameter)
|
||||
public DiffusionModel(DiffusionModelParameter modelParameter)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(parameter, nameof(parameter));
|
||||
ArgumentNullException.ThrowIfNull(modelParameter, nameof(modelParameter));
|
||||
|
||||
parameter.Validate();
|
||||
modelParameter.Validate();
|
||||
|
||||
this._parameter = parameter;
|
||||
this.ModelParameter = modelParameter;
|
||||
|
||||
Initialize();
|
||||
}
|
||||
@ -39,34 +39,34 @@ public sealed unsafe class DiffusionModel : IDisposable
|
||||
|
||||
private void Initialize()
|
||||
{
|
||||
_ctx = Native.new_sd_ctx(_parameter.ModelPath,
|
||||
_parameter.ClipLPath,
|
||||
_parameter.T5xxlPath,
|
||||
_parameter.DiffusionModelPath,
|
||||
_parameter.VaePath,
|
||||
_parameter.TaesdPath,
|
||||
_parameter.ControlNetPath,
|
||||
_parameter.LoraModelDirectory,
|
||||
_parameter.EmbeddingsDirectory,
|
||||
_parameter.StackedIdEmbeddingsDirectory,
|
||||
_parameter.VaeDecodeOnly,
|
||||
_parameter.VaeTiling,
|
||||
_ctx = Native.new_sd_ctx(ModelParameter.ModelPath,
|
||||
ModelParameter.ClipLPath,
|
||||
ModelParameter.T5xxlPath,
|
||||
ModelParameter.DiffusionModelPath,
|
||||
ModelParameter.VaePath,
|
||||
ModelParameter.TaesdPath,
|
||||
ModelParameter.ControlNetPath,
|
||||
ModelParameter.LoraModelDirectory,
|
||||
ModelParameter.EmbeddingsDirectory,
|
||||
ModelParameter.StackedIdEmbeddingsDirectory,
|
||||
ModelParameter.VaeDecodeOnly,
|
||||
ModelParameter.VaeTiling,
|
||||
false,
|
||||
_parameter.ThreadCount,
|
||||
_parameter.Quantization,
|
||||
_parameter.RngType,
|
||||
_parameter.Schedule,
|
||||
_parameter.KeepClipOnCPU,
|
||||
_parameter.KeepControlNetOnCPU,
|
||||
_parameter.KeepVaeOnCPU);
|
||||
ModelParameter.ThreadCount,
|
||||
ModelParameter.Quantization,
|
||||
ModelParameter.RngType,
|
||||
ModelParameter.Schedule,
|
||||
ModelParameter.KeepClipOnCPU,
|
||||
ModelParameter.KeepControlNetOnCPU,
|
||||
ModelParameter.KeepVaeOnCPU);
|
||||
|
||||
if (_ctx == null) throw new NullReferenceException("Failed to initialize diffusion-model.");
|
||||
}
|
||||
|
||||
public DiffusionParameter GetDefaultParameter() => _parameter.DiffusionModelType switch
|
||||
public DiffusionParameter GetDefaultParameter() => ModelParameter.DiffusionModelType switch
|
||||
{
|
||||
DiffusionModelType.None => new DiffusionParameter(),
|
||||
DiffusionModelType.StableDiffusion => DiffusionParameter.StableDiffusionDefault,
|
||||
DiffusionModelType.StableDiffusion => DiffusionParameter.SDXLDefault,
|
||||
DiffusionModelType.Flux => DiffusionParameter.FluxDefault,
|
||||
_ => throw new ArgumentOutOfRangeException()
|
||||
};
|
||||
|
||||
@ -11,7 +11,7 @@ public sealed unsafe class UpscaleModel : IDisposable
|
||||
|
||||
private bool _disposed;
|
||||
|
||||
private readonly UpscaleModelParameter _parameter;
|
||||
public UpscaleModelParameter ModelParameter { get; }
|
||||
|
||||
private Native.upscaler_ctx_t* _ctx;
|
||||
|
||||
@ -19,13 +19,13 @@ public sealed unsafe class UpscaleModel : IDisposable
|
||||
|
||||
#region Constructors
|
||||
|
||||
public UpscaleModel(UpscaleModelParameter parameter)
|
||||
public UpscaleModel(UpscaleModelParameter modelParameter)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(parameter, nameof(parameter));
|
||||
ArgumentNullException.ThrowIfNull(modelParameter, nameof(modelParameter));
|
||||
|
||||
parameter.Validate();
|
||||
modelParameter.Validate();
|
||||
|
||||
this._parameter = parameter;
|
||||
this.ModelParameter = modelParameter;
|
||||
|
||||
Initialize();
|
||||
}
|
||||
@ -38,9 +38,9 @@ public sealed unsafe class UpscaleModel : IDisposable
|
||||
|
||||
private void Initialize()
|
||||
{
|
||||
_ctx = Native.new_upscaler_ctx(_parameter.ModelPath,
|
||||
_parameter.ThreadCount,
|
||||
_parameter.Quantization);
|
||||
_ctx = Native.new_upscaler_ctx(ModelParameter.ModelPath,
|
||||
ModelParameter.ThreadCount,
|
||||
ModelParameter.Quantization);
|
||||
|
||||
if (_ctx == null) throw new NullReferenceException("Failed to initialize upscale-model.");
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user