Merge pull request #19 from drasticactions/load-native-library

Allow manually loading SD library
This commit is contained in:
DarthAffe authored and GitHub committed 2024-08-01 21:40:16 +02:00
commit c3a14c2883
2 files changed
+21

No files matched your search

+12
View File
@@ -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);