mirror of
https://github.com/DarthAffe/StableDiffusion.NET.git
synced 2025-12-12 21:38:45 +00:00
Merge pull request #19 from drasticactions/load-native-library
Allow manually loading SD library
This commit is contained in:
commit
c3a14c2883
@ -26,6 +26,18 @@ internal static partial class Native
|
||||
|
||||
#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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
ObjectDisposedException.ThrowIf(_disposed, this);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user