mirror of
https://github.com/DarthAffe/StableDiffusion.NET.git
synced 2025-12-13 05:48:40 +00:00
Compare commits
6 Commits
371eb5a773
...
d91132fbea
| Author | SHA1 | Date | |
|---|---|---|---|
| d91132fbea | |||
| a1576994a7 | |||
| 0845db4832 | |||
| 32325fa3df | |||
| 56f8e5ba82 | |||
| 6e8bbc7950 |
277
.github/workflows/backends.yml
vendored
Normal file
277
.github/workflows/backends.yml
vendored
Normal file
@ -0,0 +1,277 @@
|
|||||||
|
name: backends
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
version:
|
||||||
|
description: 'version'
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
commit:
|
||||||
|
description: 'sd.cpp commit'
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
windows:
|
||||||
|
runs-on: windows-latest
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- build: 'noavx'
|
||||||
|
defines: '-DGGML_AVX=OFF -DGGML_AVX2=OFF -DGGML_FMA=OFF -DSD_BUILD_SHARED_LIBS=ON'
|
||||||
|
- build: 'avx'
|
||||||
|
defines: '-DGGML_AVX2=OFF -DSD_BUILD_SHARED_LIBS=ON'
|
||||||
|
- build: 'avx2'
|
||||||
|
defines: '-DGGML_AVX2=ON -DSD_BUILD_SHARED_LIBS=ON'
|
||||||
|
- build: 'avx512'
|
||||||
|
defines: '-DGGML_AVX512=ON -DSD_BUILD_SHARED_LIBS=ON'
|
||||||
|
- build: 'cuda11'
|
||||||
|
defines: '-DSD_CUBLAS=ON -DSD_BUILD_SHARED_LIBS=ON'
|
||||||
|
- build: 'cuda12'
|
||||||
|
defines: '-DSD_CUBLAS=ON -DSD_BUILD_SHARED_LIBS=ON'
|
||||||
|
- build: 'rocm5'
|
||||||
|
defines: '-G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DSD_HIPBLAS=ON -DCMAKE_BUILD_TYPE=Release -DAMDGPU_TARGETS="gfx1100;gfx1102;gfx1030" -DSD_BUILD_SHARED_LIBS=ON'
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
id: checkout
|
||||||
|
uses: actions/checkout@v4.1.2
|
||||||
|
with:
|
||||||
|
repository: 'leejet/stable-diffusion.cpp'
|
||||||
|
ref: '${{ github.event.inputs.commit }}'
|
||||||
|
submodules: recursive
|
||||||
|
|
||||||
|
- name: Install cuda-toolkit
|
||||||
|
id: cuda-toolkit-11
|
||||||
|
if: ${{ matrix.build == 'cuda11' }}
|
||||||
|
uses: Jimver/cuda-toolkit@v0.2.14
|
||||||
|
with:
|
||||||
|
cuda: '11.7.1'
|
||||||
|
method: network
|
||||||
|
sub-packages: '["nvcc", "cudart", "cublas", "cublas_dev", "thrust", "visual_studio_integration"]'
|
||||||
|
|
||||||
|
- name: Install cuda-toolkit
|
||||||
|
id: cuda-toolkit-12
|
||||||
|
if: ${{ matrix.build == 'cuda12' }}
|
||||||
|
uses: Jimver/cuda-toolkit@v0.2.14
|
||||||
|
with:
|
||||||
|
cuda: '12.2.0'
|
||||||
|
method: network
|
||||||
|
sub-packages: '["nvcc", "cudart", "cublas", "cublas_dev", "thrust", "visual_studio_integration"]'
|
||||||
|
|
||||||
|
- name: Install rocm-toolkit
|
||||||
|
id: rocm-toolkit
|
||||||
|
if: ${{ matrix.build == 'rocm5' }}
|
||||||
|
uses: Cyberhan123/rocm-toolkit@v0.1.0
|
||||||
|
with:
|
||||||
|
rocm: '5.5.0'
|
||||||
|
|
||||||
|
- name: Install Ninja
|
||||||
|
id: install-ninja
|
||||||
|
if: ${{ matrix.build == 'rocm5' }}
|
||||||
|
uses: urkle/action-get-ninja@v1
|
||||||
|
with:
|
||||||
|
version: 1.11.1
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
id: cmake_build
|
||||||
|
run: |
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
cmake .. ${{ matrix.defines }}
|
||||||
|
cmake --build . --config Release
|
||||||
|
|
||||||
|
- name: Upload artifact
|
||||||
|
id: upload_artifact
|
||||||
|
if: ${{ matrix.build != 'rocm5' }}
|
||||||
|
uses: actions/upload-artifact@v4.3.1
|
||||||
|
with:
|
||||||
|
name: windows-${{ matrix.build }}
|
||||||
|
path: .\build\bin\Release\stable-diffusion.dll
|
||||||
|
|
||||||
|
- name: Upload artifact Rocm
|
||||||
|
id: upload_artifact_rocm
|
||||||
|
if: ${{ matrix.build == 'rocm5' }}
|
||||||
|
uses: actions/upload-artifact@v4.3.1
|
||||||
|
with:
|
||||||
|
name: windows-${{ matrix.build }}
|
||||||
|
path: .\build\bin\stable-diffusion.dll
|
||||||
|
|
||||||
|
linux:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- build: 'noavx'
|
||||||
|
defines: '-DGGML_AVX=OFF -DGGML_AVX2=OFF -DGGML_FMA=OFF -DSD_BUILD_SHARED_LIBS=ON'
|
||||||
|
- build: 'avx'
|
||||||
|
defines: '-DGGML_AVX2=OFF -DSD_BUILD_SHARED_LIBS=ON'
|
||||||
|
- build: 'avx2'
|
||||||
|
defines: '-DGGML_AVX2=ON -DSD_BUILD_SHARED_LIBS=ON'
|
||||||
|
- build: 'avx512'
|
||||||
|
defines: '-DGGML_AVX512=ON -DSD_BUILD_SHARED_LIBS=ON'
|
||||||
|
- build: 'cuda11'
|
||||||
|
defines: '-DSD_CUBLAS=ON -DSD_BUILD_SHARED_LIBS=ON'
|
||||||
|
- build: 'cuda12'
|
||||||
|
defines: '-DSD_CUBLAS=ON -DSD_BUILD_SHARED_LIBS=ON'
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
id: checkout
|
||||||
|
uses: actions/checkout@v4.1.2
|
||||||
|
with:
|
||||||
|
repository: 'leejet/stable-diffusion.cpp'
|
||||||
|
ref: '${{ github.event.inputs.commit }}'
|
||||||
|
submodules: recursive
|
||||||
|
|
||||||
|
- name: Install cuda-toolkit
|
||||||
|
id: cuda-toolkit-11
|
||||||
|
if: ${{ matrix.build == 'cuda11' }}
|
||||||
|
uses: Jimver/cuda-toolkit@v0.2.14
|
||||||
|
with:
|
||||||
|
cuda: '11.7.1'
|
||||||
|
method: network
|
||||||
|
|
||||||
|
- name: Install cuda-toolkit
|
||||||
|
id: cuda-toolkit-12
|
||||||
|
if: ${{ matrix.build == 'cuda12' }}
|
||||||
|
uses: Jimver/cuda-toolkit@v0.2.14
|
||||||
|
with:
|
||||||
|
cuda: '12.2.0'
|
||||||
|
method: network
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
id: cmake_build
|
||||||
|
run: |
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
cmake .. ${{ matrix.defines }}
|
||||||
|
cmake --build . --config Release
|
||||||
|
|
||||||
|
- name: Upload artifact
|
||||||
|
id: upload_artifact
|
||||||
|
uses: actions/upload-artifact@v4.3.1
|
||||||
|
with:
|
||||||
|
name: linux-${{ matrix.build }}
|
||||||
|
path: ./build/bin/libstable-diffusion.so
|
||||||
|
|
||||||
|
linux-hip:
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
container: rocm/dev-ubuntu-22.04:6.0.2
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Dependencies
|
||||||
|
id: depends
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y build-essential git cmake rocblas-dev hipblas-dev
|
||||||
|
hipconfig
|
||||||
|
|
||||||
|
- name: Clone
|
||||||
|
id: checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
repository: 'leejet/stable-diffusion.cpp'
|
||||||
|
ref: '${{ github.event.inputs.commit }}'
|
||||||
|
submodules: recursive
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
id: cmake_build
|
||||||
|
run: |
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
cmake .. -DCMAKE_C_COMPILER=hipcc -DCMAKE_CXX_COMPILER=hipcc -DSD_HIPBLAS=ON -DCMAKE_BUILD_TYPE=Release -DAMDGPU_TARGETS="gfx1100;gfx1102;gfx1030" -DSD_BUILD_SHARED_LIBS=ON
|
||||||
|
cmake --build . --config Release
|
||||||
|
|
||||||
|
- name: Upload artifact Rocm
|
||||||
|
id: upload_artifact_rocm
|
||||||
|
uses: actions/upload-artifact@v4.3.1
|
||||||
|
with:
|
||||||
|
name: linux-rocm6
|
||||||
|
path: ./build/bin/libstable-diffusion.so
|
||||||
|
|
||||||
|
osx:
|
||||||
|
runs-on: macos-latest
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- build: 'noavx'
|
||||||
|
defines: '-DCMAKE_OSX_ARCHITECTURES="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'
|
||||||
|
- build: 'avx2'
|
||||||
|
defines: '-DCMAKE_OSX_ARCHITECTURES="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'
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
id: checkout
|
||||||
|
uses: actions/checkout@v4.1.2
|
||||||
|
with:
|
||||||
|
repository: 'leejet/stable-diffusion.cpp'
|
||||||
|
ref: '${{ github.event.inputs.commit }}'
|
||||||
|
submodules: recursive
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
id: cmake_build
|
||||||
|
run: |
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
cmake .. ${{ matrix.defines }}
|
||||||
|
cmake --build . --config Release
|
||||||
|
|
||||||
|
- name: Upload artifact
|
||||||
|
id: upload_artifact
|
||||||
|
uses: actions/upload-artifact@v4.3.1
|
||||||
|
with:
|
||||||
|
name: osx-${{ matrix.build }}
|
||||||
|
path: ./build/bin/libstable-diffusion.dylib
|
||||||
|
|
||||||
|
release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
needs:
|
||||||
|
- windows
|
||||||
|
- linux
|
||||||
|
- linux-hip
|
||||||
|
- osx
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
id: checkout
|
||||||
|
uses: actions/checkout@v4.1.2
|
||||||
|
|
||||||
|
- name: Download artifacts
|
||||||
|
id: download_artifacts
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
path: Backends
|
||||||
|
|
||||||
|
- name: Display structure of downloaded files
|
||||||
|
run: ls -R
|
||||||
|
|
||||||
|
- name: Setup nuget
|
||||||
|
id: setup_nuget
|
||||||
|
uses: NuGet/setup-nuget@v2.0.0
|
||||||
|
|
||||||
|
- name: Pack
|
||||||
|
id: pack
|
||||||
|
run: |
|
||||||
|
nuget pack ./Backends/StableDiffusion.NET.Backend.Cpu.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 }}
|
||||||
|
|
||||||
|
- name: Upload artifacts
|
||||||
|
id: upload_artifacts
|
||||||
|
uses: actions/upload-artifact@v4.3.1
|
||||||
|
with:
|
||||||
|
name: StableDiffusion.NET.Backend-Nugets
|
||||||
|
path: ./*.nupkg
|
||||||
|
|
||||||
|
- name: Nuget Push
|
||||||
|
id: nuget_push
|
||||||
|
run: dotnet nuget push **\*.nupkg --skip-duplicate --api-key ${{ secrets.NUGET_TOKEN }} --source https://api.nuget.org/v3/index.json
|
||||||
57
.github/workflows/release.yml
vendored
Normal file
57
.github/workflows/release.yml
vendored
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
name: Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
version:
|
||||||
|
description: 'version'
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: windows-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Install .NET Core
|
||||||
|
uses: actions/setup-dotnet@v4
|
||||||
|
with:
|
||||||
|
dotnet-version: 8.0.x
|
||||||
|
|
||||||
|
- name: Restore dependencies
|
||||||
|
run: dotnet restore
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: dotnet build --no-restore --configuration Release /p:Version=${{ github.event.inputs.version }}
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
run: dotnet test --no-build --verbosity normal --configuration Release
|
||||||
|
|
||||||
|
- name: Upload Nuget Build Artifact
|
||||||
|
uses: actions/upload-artifact@v4.3.1
|
||||||
|
with:
|
||||||
|
name: StableDiffusion.NET-Nuget
|
||||||
|
path: StableDiffusion.NET\bin\Release\*.nupkg
|
||||||
|
if-no-files-found: error
|
||||||
|
|
||||||
|
- name: List files
|
||||||
|
run: tree
|
||||||
|
|
||||||
|
- name: Release
|
||||||
|
uses: softprops/action-gh-release@v2.0.4
|
||||||
|
with:
|
||||||
|
tag_name: ${{ github.event.inputs.version }}
|
||||||
|
generate_release_notes: true
|
||||||
|
files: StableDiffusion.NET/bin/Release/net8.0/StableDiffusion.NET.dll
|
||||||
|
|
||||||
|
- name: Nuget Push
|
||||||
|
id: nuget_push
|
||||||
|
run: |
|
||||||
|
dotnet nuget push **\*.nupkg --skip-duplicate --api-key ${{ secrets.NUGET_TOKEN }} --source https://api.nuget.org/v3/index.json
|
||||||
|
dotnet nuget push **\*.snupkg --skip-duplicate --api-key ${{ secrets.NUGET_TOKEN }} --source https://api.nuget.org/v3/index.json
|
||||||
|
|
||||||
2
LICENSE
2
LICENSE
@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2023 leejet
|
Copyright (c) 2024 Darth Affe
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
BIN
Resources/sd_net_icon.xcf
Normal file
BIN
Resources/sd_net_icon.xcf
Normal file
Binary file not shown.
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using StableDiffusion.NET.Helper;
|
||||||
|
|
||||||
namespace StableDiffusion.NET;
|
namespace StableDiffusion.NET;
|
||||||
|
|
||||||
@ -12,14 +13,16 @@ public partial class RocmBackend : IBackend
|
|||||||
|
|
||||||
public int Priority => 10;
|
public int Priority => 10;
|
||||||
|
|
||||||
public bool IsAvailable => (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
|
public bool IsAvailable => ((RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
|
||||||
/*|| RuntimeInformation.IsOSPlatform(OSPlatform.Linux)*/)
|
&& RocmVersion is 5)
|
||||||
&& (RuntimeInformation.OSArchitecture == Architecture.X64)
|
|| (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)
|
||||||
&& RocmVersion is 5;
|
&& RocmVersion is 6))
|
||||||
|
&& (RuntimeInformation.OSArchitecture == Architecture.X64);
|
||||||
|
|
||||||
public string PathPart => RocmVersion switch
|
public string PathPart => RocmVersion switch
|
||||||
{
|
{
|
||||||
5 => "rocm5",
|
5 => "rocm5",
|
||||||
|
6 => "rocm6",
|
||||||
_ => string.Empty
|
_ => string.Empty
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -46,7 +49,6 @@ public partial class RocmBackend : IBackend
|
|||||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||||
{
|
{
|
||||||
string? rocmPath = Environment.GetEnvironmentVariable("HIP_PATH");
|
string? rocmPath = Environment.GetEnvironmentVariable("HIP_PATH");
|
||||||
|
|
||||||
if (rocmPath == null) return -1;
|
if (rocmPath == null) return -1;
|
||||||
|
|
||||||
Match match = GetWindowsVersionRegex().Match(rocmPath);
|
Match match = GetWindowsVersionRegex().Match(rocmPath);
|
||||||
@ -55,7 +57,12 @@ public partial class RocmBackend : IBackend
|
|||||||
}
|
}
|
||||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||||
{
|
{
|
||||||
//TODO DarthAffe 23.03.2024: Get some info where it's located on linux
|
string? hipconfig = ProcessHelper.RunCommand("hipconfig");
|
||||||
|
if (hipconfig == null) return -1;
|
||||||
|
|
||||||
|
Match match = GetLinuxVersionRegex().Match(hipconfig);
|
||||||
|
if (match.Success)
|
||||||
|
version = match.Groups["version"].Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(version))
|
if (string.IsNullOrEmpty(version))
|
||||||
@ -73,5 +80,8 @@ public partial class RocmBackend : IBackend
|
|||||||
[GeneratedRegex(@".*?\\(?<version>\d+.\d*)\\")]
|
[GeneratedRegex(@".*?\\(?<version>\d+.\d*)\\")]
|
||||||
private static partial Regex GetWindowsVersionRegex();
|
private static partial Regex GetWindowsVersionRegex();
|
||||||
|
|
||||||
|
[GeneratedRegex(@"HIP_PATH\s*:\s*[\w\/]+-(?<version>[\d.]+)$")]
|
||||||
|
private static partial Regex GetLinuxVersionRegex();
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
@ -14,7 +14,7 @@ public sealed class Image<TColor> : IImage
|
|||||||
#region Properties & Fields
|
#region Properties & Fields
|
||||||
|
|
||||||
private readonly byte[] _buffer;
|
private readonly byte[] _buffer;
|
||||||
|
|
||||||
private readonly int _x;
|
private readonly int _x;
|
||||||
private readonly int _y;
|
private readonly int _y;
|
||||||
private readonly int _stride;
|
private readonly int _stride;
|
||||||
@ -216,13 +216,8 @@ public sealed class Image<TColor> : IImage
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public int Length => _length;
|
public int Length => _length;
|
||||||
|
|
||||||
#if NET7_0_OR_GREATER
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public int SizeInBytes => Length * TColor.ColorFormat.BytesPerPixel;
|
public int SizeInBytes => Length * TColor.ColorFormat.BytesPerPixel;
|
||||||
#else
|
|
||||||
/// <inheritdoc />
|
|
||||||
public int SizeInBytes => Length * default(TColor).Net6ColorFormat.BytesPerPixel;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -359,13 +354,8 @@ public sealed class Image<TColor> : IImage
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public int Length => _length;
|
public int Length => _length;
|
||||||
|
|
||||||
#if NET7_0_OR_GREATER
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public int SizeInBytes => Length * TColor.ColorFormat.BytesPerPixel;
|
public int SizeInBytes => Length * TColor.ColorFormat.BytesPerPixel;
|
||||||
#else
|
|
||||||
/// <inheritdoc />
|
|
||||||
public int SizeInBytes => Length * default(TColor).Net6ColorFormat.BytesPerPixel;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
27
StableDiffusion.NET/Helper/ProcessHelper.cs
Normal file
27
StableDiffusion.NET/Helper/ProcessHelper.cs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
namespace StableDiffusion.NET.Helper;
|
||||||
|
|
||||||
|
internal static class ProcessHelper
|
||||||
|
{
|
||||||
|
public static string? RunCommand(string command)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using Process process = new();
|
||||||
|
process.StartInfo.UseShellExecute = false;
|
||||||
|
process.StartInfo.RedirectStandardOutput = true;
|
||||||
|
process.StartInfo.FileName = command;
|
||||||
|
process.Start();
|
||||||
|
|
||||||
|
string output = process.StandardOutput.ReadToEnd();
|
||||||
|
process.WaitForExit();
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -4,6 +4,53 @@
|
|||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
|
||||||
|
<Authors>Darth Affe</Authors>
|
||||||
|
<Company>Wyrez</Company>
|
||||||
|
<Language>en-US</Language>
|
||||||
|
<NeutralLanguage>en-US</NeutralLanguage>
|
||||||
|
<Title>StableDiffusion.NET</Title>
|
||||||
|
<AssemblyName>StableDiffusion.NET</AssemblyName>
|
||||||
|
<AssemblyTitle>StableDiffusion.NET</AssemblyTitle>
|
||||||
|
<PackageId>StableDiffusion.NET</PackageId>
|
||||||
|
<RootNamespace>StableDiffusion.NET</RootNamespace>
|
||||||
|
<Description>Stable-Diffusion for .NET based on stable-diffusion.cpp</Description>
|
||||||
|
<Summary>Stable-Diffusion for .NET based on stable-diffusion.cpp</Summary>
|
||||||
|
<Copyright>Copyright © Darth Affe 2024</Copyright>
|
||||||
|
<PackageCopyright>Copyright © Darth Affe 2024</PackageCopyright>
|
||||||
|
<PackageIcon>sd_net.png</PackageIcon>
|
||||||
|
<PackageReadmeFile>README.md</PackageReadmeFile>
|
||||||
|
<PackageProjectUrl>https://github.com/DarthAffe/StableDiffusion.NET</PackageProjectUrl>
|
||||||
|
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||||
|
<RepositoryType>Github</RepositoryType>
|
||||||
|
<RepositoryUrl>https://github.com/DarthAffe/StableDiffusion.NET</RepositoryUrl>
|
||||||
|
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
|
||||||
|
|
||||||
|
<Version>0.0.1</Version>
|
||||||
|
<AssemblyVersion>0.0.1</AssemblyVersion>
|
||||||
|
<FileVersion>0.0.1</FileVersion>
|
||||||
|
|
||||||
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
|
<IncludeSource>True</IncludeSource>
|
||||||
|
<IncludeSymbols>True</IncludeSymbols>
|
||||||
|
<DebugType>portable</DebugType>
|
||||||
|
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<DefineConstants>TRACE;DEBUG</DefineConstants>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<NoWarn>$(NoWarn);CS1591;CS1572;CS1573</NoWarn>
|
||||||
|
<DefineConstants>RELEASE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="sd_net.png" Link="sd_net.png" Pack="true" PackagePath="\" />
|
||||||
|
<None Include="..\README.md" Pack="true" PackagePath="\" />
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
BIN
StableDiffusion.NET/sd_net.png
Normal file
BIN
StableDiffusion.NET/sd_net.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 452 KiB |
Loading…
x
Reference in New Issue
Block a user