mirror of
https://github.com/DarthAffe/StableDiffusion.NET.git
synced 2025-12-13 05:48:40 +00:00
Allow manually loading SD library
This commit is contained in:
parent
f21a3d876c
commit
cde04582ac
@ -26,6 +26,18 @@ internal static partial class Native
|
|||||||
|
|
||||||
#region Methods
|
#region Methods
|
||||||
|
|
||||||
|
internal static bool LoadNativeLibrary(string libraryPath)
|
||||||
|
{
|
||||||
|
if (_loadedLibraryHandle != nint.Zero) return true;
|
||||||
|
if (NativeLibrary.TryLoad(libraryPath, out nint handle))
|
||||||
|
{
|
||||||
|
_loadedLibraryHandle = handle;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private static nint ResolveDllImport(string libraryname, Assembly assembly, DllImportSearchPath? searchpath)
|
private static nint ResolveDllImport(string libraryname, Assembly assembly, DllImportSearchPath? searchpath)
|
||||||
{
|
{
|
||||||
if (libraryname != LIB_NAME) return nint.Zero;
|
if (libraryname != LIB_NAME) return nint.Zero;
|
||||||
|
|||||||
@ -91,6 +91,15 @@ public sealed unsafe class StableDiffusionModel : IDisposable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Manually load the native stable diffusion library.
|
||||||
|
/// Once set, it will continue to be used for all instances.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="libraryPath">Path to the stable diffusion library.</param>
|
||||||
|
/// <returns>Bool if the library loaded.</returns>
|
||||||
|
public static bool LoadNativeLibrary(string libraryPath)
|
||||||
|
=> Native.LoadNativeLibrary(libraryPath);
|
||||||
|
|
||||||
public IImage<ColorRGB> TextToImage(string prompt, StableDiffusionParameter parameter)
|
public IImage<ColorRGB> TextToImage(string prompt, StableDiffusionParameter parameter)
|
||||||
{
|
{
|
||||||
ObjectDisposedException.ThrowIf(_disposed, this);
|
ObjectDisposedException.ThrowIf(_disposed, this);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user