mirror of
https://github.com/DarthAffe/StableDiffusion.NET.git
synced 2025-12-13 05:48:40 +00:00
Compare commits
7 Commits
f21a3d876c
...
ac5c3185d0
| Author | SHA1 | Date | |
|---|---|---|---|
| ac5c3185d0 | |||
| bccee9a172 | |||
| 5941b20c0a | |||
| 83f04892ad | |||
| c3a14c2883 | |||
|
|
cde04582ac | ||
| 7ae4c4b9d3 |
12
.github/workflows/backends.yml
vendored
12
.github/workflows/backends.yml
vendored
@ -207,13 +207,13 @@ jobs:
|
||||
matrix:
|
||||
include:
|
||||
- build: 'noavx'
|
||||
defines: '-DCMAKE_OSX_ARCHITECTURES="x86_64" -DGGML_AVX=OFF -DGGML_AVX2=OFF -DGGML_FMA=OFF -DSD_BUILD_SHARED_LIBS=ON'
|
||||
defines: '-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" -DGGML_AVX=OFF -DGGML_AVX2=OFF -DGGML_FMA=OFF -DSD_BUILD_SHARED_LIBS=ON'
|
||||
- build: 'avx'
|
||||
defines: '-DCMAKE_OSX_ARCHITECTURES="x86_64" -DGGML_AVX2=OFF -DSD_BUILD_SHARED_LIBS=ON'
|
||||
defines: '-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" -DGGML_AVX2=OFF -DSD_BUILD_SHARED_LIBS=ON'
|
||||
- build: 'avx2'
|
||||
defines: '-DCMAKE_OSX_ARCHITECTURES="x86_64" -DGGML_AVX2=ON -DSD_BUILD_SHARED_LIBS=ON'
|
||||
defines: '-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" -DGGML_AVX2=ON -DSD_BUILD_SHARED_LIBS=ON'
|
||||
- build: 'avx512'
|
||||
defines: '-DCMAKE_OSX_ARCHITECTURES="x86_64" -DGGML_AVX512=ON -DSD_BUILD_SHARED_LIBS=ON'
|
||||
defines: '-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" -DGGML_AVX512=ON -DSD_BUILD_SHARED_LIBS=ON'
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
@ -270,6 +270,10 @@ jobs:
|
||||
id: pack
|
||||
run: |
|
||||
nuget pack ./Backends/StableDiffusion.NET.Backend.Cpu.nuspec -version ${{ github.event.inputs.version }}
|
||||
nuget pack ./Backends/StableDiffusion.NET.Backend.Cuda11.Windows.nuspec -version ${{ github.event.inputs.version }}
|
||||
nuget pack ./Backends/StableDiffusion.NET.Backend.Cuda12.Windows.nuspec -version ${{ github.event.inputs.version }}
|
||||
nuget pack ./Backends/StableDiffusion.NET.Backend.Cuda11.Linux.nuspec -version ${{ github.event.inputs.version }}
|
||||
nuget pack ./Backends/StableDiffusion.NET.Backend.Cuda12.Linux.nuspec -version ${{ github.event.inputs.version }}
|
||||
nuget pack ./Backends/StableDiffusion.NET.Backend.Cuda.nuspec -version ${{ github.event.inputs.version }}
|
||||
nuget pack ./Backends/StableDiffusion.NET.Backend.Rocm.nuspec -version ${{ github.event.inputs.version }}
|
||||
|
||||
|
||||
@ -13,20 +13,17 @@
|
||||
<releaseNotes></releaseNotes>
|
||||
<copyright>Copyright © Darth Affe 2024</copyright>
|
||||
<readme>readme.md</readme>
|
||||
|
||||
<dependencies>
|
||||
<dependency id="StableDiffusion.NET.Backend.Cuda11.Windows" version="$version$" />
|
||||
<dependency id="StableDiffusion.NET.Backend.Cuda12.Windows" version="$version$" />
|
||||
<dependency id="StableDiffusion.NET.Backend.Cuda11.Linux" version="$version$" />
|
||||
<dependency id="StableDiffusion.NET.Backend.Cuda12.Linux" version="$version$" />
|
||||
</dependencies>
|
||||
</metadata>
|
||||
|
||||
<files>
|
||||
<file src="StableDiffusion.NET.Backend.props" target="build/net8.0/StableDiffusion.NET.Backend.Cuda.props" />
|
||||
|
||||
<file src="windows-cuda11/stable-diffusion.dll" target="runtimes\win-x64\native\cuda11\stable-diffusion.dll" />
|
||||
<file src="windows-cuda12/stable-diffusion.dll" target="runtimes\win-x64\native\cuda12\stable-diffusion.dll" />
|
||||
|
||||
<file src="linux-cuda11/libstable-diffusion.so" target="runtimes\linux-x64\native\cuda11\libstable-diffusion.so" />
|
||||
<file src="linux-cuda12/libstable-diffusion.so" target="runtimes\linux-x64\native\cuda12\libstable-diffusion.so" />
|
||||
|
||||
<file src="sd_net_cuda.png" target="sd_net_cuda.png" />
|
||||
<file src="readme.md" target="readme.md" />
|
||||
<file src="ggml.txt" target="ggml.txt" />
|
||||
<file src="stable-diffusion.cpp.txt" target="stable-diffusion.cpp.txt" />
|
||||
</files>
|
||||
</package>
|
||||
|
||||
28
Backends/StableDiffusion.NET.Backend.Cuda11.Linux.nuspec
Normal file
28
Backends/StableDiffusion.NET.Backend.Cuda11.Linux.nuspec
Normal file
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<package>
|
||||
<metadata>
|
||||
<id>StableDiffusion.NET.Backend.Cuda11.Linux</id>
|
||||
<version>$version$</version>
|
||||
<title>StableDiffusion.NET.Backend.Cuda11.Linux</title>
|
||||
<authors>Darth Affe & stable-diffusion.cpp Authors</authors>
|
||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||
<license type="expression">MIT</license>
|
||||
<icon>sd_net_cuda.png</icon>
|
||||
<projectUrl>https://github.com/DarthAffe/StableDiffusion.NET</projectUrl>
|
||||
<description>CUDA 11 Linux Backend for StableDiffusion.NET.</description>
|
||||
<releaseNotes></releaseNotes>
|
||||
<copyright>Copyright © Darth Affe 2024</copyright>
|
||||
<readme>readme.md</readme>
|
||||
</metadata>
|
||||
|
||||
<files>
|
||||
<file src="StableDiffusion.NET.Backend.props" target="build/net8.0/StableDiffusion.NET.Backend.Cuda.props" />
|
||||
|
||||
<file src="linux-cuda11/libstable-diffusion.so" target="runtimes\linux-x64\native\cuda11\libstable-diffusion.so" />
|
||||
|
||||
<file src="sd_net_cuda.png" target="sd_net_cuda.png" />
|
||||
<file src="readme.md" target="readme.md" />
|
||||
<file src="ggml.txt" target="ggml.txt" />
|
||||
<file src="stable-diffusion.cpp.txt" target="stable-diffusion.cpp.txt" />
|
||||
</files>
|
||||
</package>
|
||||
28
Backends/StableDiffusion.NET.Backend.Cuda11.Windows.nuspec
Normal file
28
Backends/StableDiffusion.NET.Backend.Cuda11.Windows.nuspec
Normal file
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<package>
|
||||
<metadata>
|
||||
<id>StableDiffusion.NET.Backend.Cuda11.Windows</id>
|
||||
<version>$version$</version>
|
||||
<title>StableDiffusion.NET.Backend.Cuda11.Windows</title>
|
||||
<authors>Darth Affe & stable-diffusion.cpp Authors</authors>
|
||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||
<license type="expression">MIT</license>
|
||||
<icon>sd_net_cuda.png</icon>
|
||||
<projectUrl>https://github.com/DarthAffe/StableDiffusion.NET</projectUrl>
|
||||
<description>CUDA 11 Windows Backend for StableDiffusion.NET.</description>
|
||||
<releaseNotes></releaseNotes>
|
||||
<copyright>Copyright © Darth Affe 2024</copyright>
|
||||
<readme>readme.md</readme>
|
||||
</metadata>
|
||||
|
||||
<files>
|
||||
<file src="StableDiffusion.NET.Backend.props" target="build/net8.0/StableDiffusion.NET.Backend.Cuda.props" />
|
||||
|
||||
<file src="windows-cuda11/stable-diffusion.dll" target="runtimes\win-x64\native\cuda11\stable-diffusion.dll" />
|
||||
|
||||
<file src="sd_net_cuda.png" target="sd_net_cuda.png" />
|
||||
<file src="readme.md" target="readme.md" />
|
||||
<file src="ggml.txt" target="ggml.txt" />
|
||||
<file src="stable-diffusion.cpp.txt" target="stable-diffusion.cpp.txt" />
|
||||
</files>
|
||||
</package>
|
||||
28
Backends/StableDiffusion.NET.Backend.Cuda12.Linux.nuspec
Normal file
28
Backends/StableDiffusion.NET.Backend.Cuda12.Linux.nuspec
Normal file
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<package>
|
||||
<metadata>
|
||||
<id>StableDiffusion.NET.Backend.Cuda12.Linux</id>
|
||||
<version>$version$</version>
|
||||
<title>StableDiffusion.NET.Backend.Cuda12.Linux</title>
|
||||
<authors>Darth Affe & stable-diffusion.cpp Authors</authors>
|
||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||
<license type="expression">MIT</license>
|
||||
<icon>sd_net_cuda.png</icon>
|
||||
<projectUrl>https://github.com/DarthAffe/StableDiffusion.NET</projectUrl>
|
||||
<description>CUDA 12 Linux Backend for StableDiffusion.NET.</description>
|
||||
<releaseNotes></releaseNotes>
|
||||
<copyright>Copyright © Darth Affe 2024</copyright>
|
||||
<readme>readme.md</readme>
|
||||
</metadata>
|
||||
|
||||
<files>
|
||||
<file src="StableDiffusion.NET.Backend.props" target="build/net8.0/StableDiffusion.NET.Backend.Cuda.props" />
|
||||
|
||||
<file src="linux-cuda12/libstable-diffusion.so" target="runtimes\linux-x64\native\cuda12\libstable-diffusion.so" />
|
||||
|
||||
<file src="sd_net_cuda.png" target="sd_net_cuda.png" />
|
||||
<file src="readme.md" target="readme.md" />
|
||||
<file src="ggml.txt" target="ggml.txt" />
|
||||
<file src="stable-diffusion.cpp.txt" target="stable-diffusion.cpp.txt" />
|
||||
</files>
|
||||
</package>
|
||||
28
Backends/StableDiffusion.NET.Backend.Cuda12.Windows.nuspec
Normal file
28
Backends/StableDiffusion.NET.Backend.Cuda12.Windows.nuspec
Normal file
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<package>
|
||||
<metadata>
|
||||
<id>StableDiffusion.NET.Backend.Cuda12.Windows</id>
|
||||
<version>$version$</version>
|
||||
<title>StableDiffusion.NET.Backend.Cuda12.Windows</title>
|
||||
<authors>Darth Affe & stable-diffusion.cpp Authors</authors>
|
||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||
<license type="expression">MIT</license>
|
||||
<icon>sd_net_cuda.png</icon>
|
||||
<projectUrl>https://github.com/DarthAffe/StableDiffusion.NET</projectUrl>
|
||||
<description>CUDA 12 Windows Backend for StableDiffusion.NET.</description>
|
||||
<releaseNotes></releaseNotes>
|
||||
<copyright>Copyright © Darth Affe 2024</copyright>
|
||||
<readme>readme.md</readme>
|
||||
</metadata>
|
||||
|
||||
<files>
|
||||
<file src="StableDiffusion.NET.Backend.props" target="build/net8.0/StableDiffusion.NET.Backend.Cuda.props" />
|
||||
|
||||
<file src="windows-cuda12/stable-diffusion.dll" target="runtimes\win-x64\native\cuda12\stable-diffusion.dll" />
|
||||
|
||||
<file src="sd_net_cuda.png" target="sd_net_cuda.png" />
|
||||
<file src="readme.md" target="readme.md" />
|
||||
<file src="ggml.txt" target="ggml.txt" />
|
||||
<file src="stable-diffusion.cpp.txt" target="stable-diffusion.cpp.txt" />
|
||||
</files>
|
||||
</package>
|
||||
@ -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