mirror of
https://github.com/DarthAffe/StableDiffusion.NET.git
synced 2025-12-13 05:48:40 +00:00
Added logging; Updated stable-diffusion.cpp to 7cb41b1
This commit is contained in:
parent
a7ccbe8ef2
commit
c277e9c830
11
StableDiffusion.NET/EventArgs/StableDiffusionLogEventArgs.cs
Normal file
11
StableDiffusion.NET/EventArgs/StableDiffusionLogEventArgs.cs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
namespace StableDiffusion.NET;
|
||||||
|
|
||||||
|
public class StableDiffusionLogEventArgs(LogLevel level, string text)
|
||||||
|
{
|
||||||
|
#region Properties & Fields
|
||||||
|
|
||||||
|
public LogLevel Level { get; } = level;
|
||||||
|
public string Text { get; } = text;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
@ -21,6 +21,12 @@ internal unsafe partial class Native
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Delegates
|
||||||
|
|
||||||
|
internal delegate void sd_log_cb_t(sd_log_level_t level, [MarshalAs(UnmanagedType.LPStr)] string text, void* data);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region DLL-Import
|
#region DLL-Import
|
||||||
|
|
||||||
internal struct sd_ctx_t;
|
internal struct sd_ctx_t;
|
||||||
@ -98,5 +104,8 @@ internal unsafe partial class Native
|
|||||||
sd_image_t input_image,
|
sd_image_t input_image,
|
||||||
int upscale_factor);
|
int upscale_factor);
|
||||||
|
|
||||||
|
[LibraryImport(LIB_NAME, EntryPoint = "sd_set_log_callback")]
|
||||||
|
internal static partial void sd_set_log_callback(sd_log_cb_t sd_log_cb, void* data);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
@ -1,4 +1,5 @@
|
|||||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=attributes/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=attributes/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=enums/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=enums/@EntryIndexedValue">True</s:Boolean>
|
||||||
|
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=eventargs/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=extensions/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=extensions/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
||||||
@ -18,8 +18,19 @@ public sealed unsafe class StableDiffusionModel : IDisposable
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Events
|
||||||
|
|
||||||
|
public static event EventHandler<StableDiffusionLogEventArgs>? Log;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Constructors
|
#region Constructors
|
||||||
|
|
||||||
|
static StableDiffusionModel()
|
||||||
|
{
|
||||||
|
Native.sd_set_log_callback(OnNativeLog, null);
|
||||||
|
}
|
||||||
|
|
||||||
public StableDiffusionModel(string modelPath, ModelParameter parameter, UpscalerModelParameter? upscalerParameter = null)
|
public StableDiffusionModel(string modelPath, ModelParameter parameter, UpscalerModelParameter? upscalerParameter = null)
|
||||||
{
|
{
|
||||||
this._modelPath = modelPath;
|
this._modelPath = modelPath;
|
||||||
@ -177,5 +188,14 @@ public sealed unsafe class StableDiffusionModel : IDisposable
|
|||||||
|
|
||||||
public static int GetNumPhysicalCores() => Native.get_num_physical_cores();
|
public static int GetNumPhysicalCores() => Native.get_num_physical_cores();
|
||||||
|
|
||||||
|
private static void OnNativeLog(LogLevel level, string text, void* data)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Log?.Invoke(null, new StableDiffusionLogEventArgs(level, text));
|
||||||
|
}
|
||||||
|
catch { /**/ }
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,7 @@ if not exist stable-diffusion.cpp (
|
|||||||
|
|
||||||
cd stable-diffusion.cpp
|
cd stable-diffusion.cpp
|
||||||
git fetch
|
git fetch
|
||||||
git checkout 2c5f3fc53a040a0f97ff8f359e8f8d1385bfd154
|
git checkout 7cb41b190fb9b4703f1737171cefd0abec861154
|
||||||
git submodule init
|
git submodule init
|
||||||
git submodule update
|
git submodule update
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user