mirror of
https://github.com/DarthAffe/StableDiffusion.NET.git
synced 2025-12-13 05:48:40 +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 bool _disposed;
|
||||||
|
|
||||||
private readonly DiffusionModelParameter _parameter;
|
public DiffusionModelParameter ModelParameter { get; }
|
||||||
|
|
||||||
private Native.sd_ctx_t* _ctx;
|
private Native.sd_ctx_t* _ctx;
|
||||||
|
|
||||||
@ -20,13 +20,13 @@ public sealed unsafe class DiffusionModel : IDisposable
|
|||||||
|
|
||||||
#region Constructors
|
#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();
|
Initialize();
|
||||||
}
|
}
|
||||||
@ -39,34 +39,34 @@ public sealed unsafe class DiffusionModel : IDisposable
|
|||||||
|
|
||||||
private void Initialize()
|
private void Initialize()
|
||||||
{
|
{
|
||||||
_ctx = Native.new_sd_ctx(_parameter.ModelPath,
|
_ctx = Native.new_sd_ctx(ModelParameter.ModelPath,
|
||||||
_parameter.ClipLPath,
|
ModelParameter.ClipLPath,
|
||||||
_parameter.T5xxlPath,
|
ModelParameter.T5xxlPath,
|
||||||
_parameter.DiffusionModelPath,
|
ModelParameter.DiffusionModelPath,
|
||||||
_parameter.VaePath,
|
ModelParameter.VaePath,
|
||||||
_parameter.TaesdPath,
|
ModelParameter.TaesdPath,
|
||||||
_parameter.ControlNetPath,
|
ModelParameter.ControlNetPath,
|
||||||
_parameter.LoraModelDirectory,
|
ModelParameter.LoraModelDirectory,
|
||||||
_parameter.EmbeddingsDirectory,
|
ModelParameter.EmbeddingsDirectory,
|
||||||
_parameter.StackedIdEmbeddingsDirectory,
|
ModelParameter.StackedIdEmbeddingsDirectory,
|
||||||
_parameter.VaeDecodeOnly,
|
ModelParameter.VaeDecodeOnly,
|
||||||
_parameter.VaeTiling,
|
ModelParameter.VaeTiling,
|
||||||
false,
|
false,
|
||||||
_parameter.ThreadCount,
|
ModelParameter.ThreadCount,
|
||||||
_parameter.Quantization,
|
ModelParameter.Quantization,
|
||||||
_parameter.RngType,
|
ModelParameter.RngType,
|
||||||
_parameter.Schedule,
|
ModelParameter.Schedule,
|
||||||
_parameter.KeepClipOnCPU,
|
ModelParameter.KeepClipOnCPU,
|
||||||
_parameter.KeepControlNetOnCPU,
|
ModelParameter.KeepControlNetOnCPU,
|
||||||
_parameter.KeepVaeOnCPU);
|
ModelParameter.KeepVaeOnCPU);
|
||||||
|
|
||||||
if (_ctx == null) throw new NullReferenceException("Failed to initialize diffusion-model.");
|
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.None => new DiffusionParameter(),
|
||||||
DiffusionModelType.StableDiffusion => DiffusionParameter.StableDiffusionDefault,
|
DiffusionModelType.StableDiffusion => DiffusionParameter.SDXLDefault,
|
||||||
DiffusionModelType.Flux => DiffusionParameter.FluxDefault,
|
DiffusionModelType.Flux => DiffusionParameter.FluxDefault,
|
||||||
_ => throw new ArgumentOutOfRangeException()
|
_ => throw new ArgumentOutOfRangeException()
|
||||||
};
|
};
|
||||||
|
|||||||
@ -11,7 +11,7 @@ public sealed unsafe class UpscaleModel : IDisposable
|
|||||||
|
|
||||||
private bool _disposed;
|
private bool _disposed;
|
||||||
|
|
||||||
private readonly UpscaleModelParameter _parameter;
|
public UpscaleModelParameter ModelParameter { get; }
|
||||||
|
|
||||||
private Native.upscaler_ctx_t* _ctx;
|
private Native.upscaler_ctx_t* _ctx;
|
||||||
|
|
||||||
@ -19,13 +19,13 @@ public sealed unsafe class UpscaleModel : IDisposable
|
|||||||
|
|
||||||
#region Constructors
|
#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();
|
Initialize();
|
||||||
}
|
}
|
||||||
@ -38,9 +38,9 @@ public sealed unsafe class UpscaleModel : IDisposable
|
|||||||
|
|
||||||
private void Initialize()
|
private void Initialize()
|
||||||
{
|
{
|
||||||
_ctx = Native.new_upscaler_ctx(_parameter.ModelPath,
|
_ctx = Native.new_upscaler_ctx(ModelParameter.ModelPath,
|
||||||
_parameter.ThreadCount,
|
ModelParameter.ThreadCount,
|
||||||
_parameter.Quantization);
|
ModelParameter.Quantization);
|
||||||
|
|
||||||
if (_ctx == null) throw new NullReferenceException("Failed to initialize upscale-model.");
|
if (_ctx == null) throw new NullReferenceException("Failed to initialize upscale-model.");
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user