mirror of
https://github.com/DarthAffe/StableDiffusion.NET.git
synced 2025-12-12 21:38:45 +00:00
Added checks to parameters to prevent unneccessary updates
This commit is contained in:
parent
cd62691709
commit
76be341505
@ -20,8 +20,11 @@ public sealed unsafe class StableDiffusionParameter : IDisposable
|
|||||||
{
|
{
|
||||||
ObjectDisposedException.ThrowIf(_disposed, this);
|
ObjectDisposedException.ThrowIf(_disposed, this);
|
||||||
|
|
||||||
_negativePrompt = value;
|
if (_negativePrompt != value)
|
||||||
Native.stable_diffusion_full_params_set_negative_prompt(ParamPtr, _negativePrompt);
|
{
|
||||||
|
_negativePrompt = value;
|
||||||
|
Native.stable_diffusion_full_params_set_negative_prompt(ParamPtr, _negativePrompt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,8 +36,11 @@ public sealed unsafe class StableDiffusionParameter : IDisposable
|
|||||||
{
|
{
|
||||||
ObjectDisposedException.ThrowIf(_disposed, this);
|
ObjectDisposedException.ThrowIf(_disposed, this);
|
||||||
|
|
||||||
_cfgScale = value;
|
if (Math.Abs(_cfgScale - value) > 0.0001)
|
||||||
Native.stable_diffusion_full_params_set_cfg_scale(ParamPtr, _cfgScale);
|
{
|
||||||
|
_cfgScale = value;
|
||||||
|
Native.stable_diffusion_full_params_set_cfg_scale(ParamPtr, _cfgScale);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,8 +52,11 @@ public sealed unsafe class StableDiffusionParameter : IDisposable
|
|||||||
{
|
{
|
||||||
ObjectDisposedException.ThrowIf(_disposed, this);
|
ObjectDisposedException.ThrowIf(_disposed, this);
|
||||||
|
|
||||||
_width = value;
|
if (_width != value)
|
||||||
Native.stable_diffusion_full_params_set_width(ParamPtr, _width);
|
{
|
||||||
|
_width = value;
|
||||||
|
Native.stable_diffusion_full_params_set_width(ParamPtr, _width);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,8 +68,11 @@ public sealed unsafe class StableDiffusionParameter : IDisposable
|
|||||||
{
|
{
|
||||||
ObjectDisposedException.ThrowIf(_disposed, this);
|
ObjectDisposedException.ThrowIf(_disposed, this);
|
||||||
|
|
||||||
_height = value;
|
if (_height != value)
|
||||||
Native.stable_diffusion_full_params_set_height(ParamPtr, _height);
|
{
|
||||||
|
_height = value;
|
||||||
|
Native.stable_diffusion_full_params_set_height(ParamPtr, _height);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,8 +84,11 @@ public sealed unsafe class StableDiffusionParameter : IDisposable
|
|||||||
{
|
{
|
||||||
ObjectDisposedException.ThrowIf(_disposed, this);
|
ObjectDisposedException.ThrowIf(_disposed, this);
|
||||||
|
|
||||||
_sampleMethod = value;
|
if (_sampleMethod != value)
|
||||||
Native.stable_diffusion_full_params_set_sample_method(ParamPtr, _sampleMethod.GetNativeName() ?? "EULER_A");
|
{
|
||||||
|
_sampleMethod = value;
|
||||||
|
Native.stable_diffusion_full_params_set_sample_method(ParamPtr, _sampleMethod.GetNativeName() ?? "EULER_A");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,8 +100,11 @@ public sealed unsafe class StableDiffusionParameter : IDisposable
|
|||||||
{
|
{
|
||||||
ObjectDisposedException.ThrowIf(_disposed, this);
|
ObjectDisposedException.ThrowIf(_disposed, this);
|
||||||
|
|
||||||
_sampleSteps = value;
|
if (_sampleSteps != value)
|
||||||
Native.stable_diffusion_full_params_set_sample_steps(ParamPtr, _sampleSteps);
|
{
|
||||||
|
_sampleSteps = value;
|
||||||
|
Native.stable_diffusion_full_params_set_sample_steps(ParamPtr, _sampleSteps);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,8 +116,11 @@ public sealed unsafe class StableDiffusionParameter : IDisposable
|
|||||||
{
|
{
|
||||||
ObjectDisposedException.ThrowIf(_disposed, this);
|
ObjectDisposedException.ThrowIf(_disposed, this);
|
||||||
|
|
||||||
_seed = value;
|
if (_seed != value)
|
||||||
Native.stable_diffusion_full_params_set_seed(ParamPtr, _seed);
|
{
|
||||||
|
_seed = value;
|
||||||
|
Native.stable_diffusion_full_params_set_seed(ParamPtr, _seed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,8 +132,11 @@ public sealed unsafe class StableDiffusionParameter : IDisposable
|
|||||||
{
|
{
|
||||||
ObjectDisposedException.ThrowIf(_disposed, this);
|
ObjectDisposedException.ThrowIf(_disposed, this);
|
||||||
|
|
||||||
_batchCount = value;
|
if (_batchCount != value)
|
||||||
Native.stable_diffusion_full_params_set_batch_count(ParamPtr, _batchCount);
|
{
|
||||||
|
_batchCount = value;
|
||||||
|
Native.stable_diffusion_full_params_set_batch_count(ParamPtr, _batchCount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,8 +148,11 @@ public sealed unsafe class StableDiffusionParameter : IDisposable
|
|||||||
{
|
{
|
||||||
ObjectDisposedException.ThrowIf(_disposed, this);
|
ObjectDisposedException.ThrowIf(_disposed, this);
|
||||||
|
|
||||||
_strength = value;
|
if (Math.Abs(_strength - value) > 0.0001)
|
||||||
Native.stable_diffusion_full_params_set_strength(ParamPtr, _strength);
|
{
|
||||||
|
_strength = value;
|
||||||
|
Native.stable_diffusion_full_params_set_strength(ParamPtr, _strength);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user