Compare commits

...

7 Commits

Author SHA1 Message Date
98784a00d8 Merge branch 'master' of https://github.com/DarthAffe/StableDiffusion.NET 2025-12-07 10:55:34 +01:00
8e61dead47 Updated header-file 2025-12-07 10:55:29 +01:00
49626b0cb4
Merge pull request #66 from DarthAffe/sdccp_update
Small naming changes in sd.cpp
2025-12-07 10:17:30 +01:00
8832456b8f Small naming changes in sd.cpp 2025-12-07 10:15:36 +01:00
3ec6acb6ea
Merge pull request #65 from DarthAffe/sdcppUpdate
Updated sd.cpp
2025-11-30 17:47:43 +01:00
66568ffee7 Updated ref-header 2025-11-30 17:46:45 +01:00
1dcbe72e2b Updated sd.cpp 2025-11-30 17:45:49 +01:00
7 changed files with 42 additions and 35 deletions

View File

@ -48,12 +48,10 @@ enum sample_method_t {
LCM_SAMPLE_METHOD,
DDIM_TRAILING_SAMPLE_METHOD,
TCD_SAMPLE_METHOD,
SAMPLE_METHOD_COUNT
};
enum scheduler_t {
DISCRETE_SCHEDULER,
KARRAS_SCHEDULER,
EXPONENTIAL_SCHEDULER,
@ -67,12 +65,12 @@ enum scheduler_t {
};
enum prediction_t {
DEFAULT_PRED,
EPS_PRED,
V_PRED,
EDM_V_PRED,
SD3_FLOW_PRED,
FLOW_PRED,
FLUX_FLOW_PRED,
FLUX2_FLOW_PRED,
PREDICTION_COUNT
};
@ -158,8 +156,8 @@ typedef struct {
const char* clip_g_path;
const char* clip_vision_path;
const char* t5xxl_path;
const char* qwen2vl_path;
const char* qwen2vl_vision_path;
const char* llm_path;
const char* llm_vision_path;
const char* diffusion_model_path;
const char* high_noise_diffusion_model_path;
const char* vae_path;
@ -284,12 +282,12 @@ typedef struct sd_ctx_t sd_ctx_t;
typedef void (*sd_log_cb_t)(enum sd_log_level_t level, const char* text, void* data);
typedef void (*sd_progress_cb_t)(int step, int steps, float time, void* data);
typedef void (*sd_preview_cb_t)(int step, int frame_count, sd_image_t* frames, bool is_noisy);
typedef void (*sd_preview_cb_t)(int step, int frame_count, sd_image_t* frames, bool is_noisy, void* data);
SD_API void sd_set_log_callback(sd_log_cb_t sd_log_cb, void* data);
SD_API void sd_set_progress_callback(sd_progress_cb_t cb, void* data);
SD_API void sd_set_preview_callback(sd_preview_cb_t cb, enum preview_t mode, int interval, bool denoised, bool noisy);
SD_API int32_t get_num_physical_cores();
SD_API void sd_set_preview_callback(sd_preview_cb_t cb, enum preview_t mode, int interval, bool denoised, bool noisy, void* data);
SD_API int32_t sd_get_num_physical_cores();
SD_API const char* sd_get_system_info();
SD_API const char* sd_type_name(enum sd_type_t type);
@ -314,7 +312,6 @@ SD_API char* sd_ctx_params_to_str(const sd_ctx_params_t* sd_ctx_params);
SD_API sd_ctx_t* new_sd_ctx(const sd_ctx_params_t* sd_ctx_params);
SD_API void free_sd_ctx(sd_ctx_t* sd_ctx);
SD_API void sd_sample_params_init(sd_sample_params_t* sample_params);
SD_API char* sd_sample_params_to_str(const sd_sample_params_t* sample_params);

View File

@ -2,10 +2,11 @@
public enum Prediction
{
Default,
EPS,
V,
EDM_V,
SD3Flow,
FluxFlow
Flow,
FluxFlow,
Flux2Flow,
Default
}

View File

@ -1,4 +1,5 @@
using JetBrains.Annotations;
using System;
using JetBrains.Annotations;
namespace StableDiffusion.NET;
@ -139,9 +140,13 @@ public sealed class DiffusionModelParameter
/// </summary>
public string T5xxlPath { get; set; } = string.Empty;
public string Qwen2VLPath { get; set; } = string.Empty;
[Obsolete("Use LLMPath instead")]
public string Qwen2VLPath { get => LLMPath; set => LLMPath = value; }
public string LLMPath { get; set; } = string.Empty;
public string Qwen2VLVisionPath { get; set; } = string.Empty;
[Obsolete("Use LLMVisionPath instead")]
public string Qwen2VLVisionPath { get => LLMVisionPath; set => LLMVisionPath = value; }
public string LLMVisionPath { get; set; } = string.Empty;
public string ClipVisionPath { get; set; } = string.Empty;
public string HighNoiseDiffusionModelPath { get; set; } = string.Empty;

View File

@ -236,16 +236,20 @@ public static class DiffusionModelBuilderExtension
return parameter;
}
public static DiffusionModelParameter WithQwen2VLPath(this DiffusionModelParameter parameter, string qwen2VLPath)
[Obsolete("Use WithLLMPath instead")]
public static DiffusionModelParameter WithQwen2VLPath(this DiffusionModelParameter parameter, string qwen2VLPath) => parameter.WithLLMPath(qwen2VLPath);
public static DiffusionModelParameter WithLLMPath(this DiffusionModelParameter parameter, string llmPath)
{
parameter.Qwen2VLPath = qwen2VLPath;
parameter.LLMPath = llmPath;
return parameter;
}
public static DiffusionModelParameter WithQwen2VLVisionPath(this DiffusionModelParameter parameter, string qwen2VLVisionPath)
[Obsolete("Use WithLLMVisionPath instead")]
public static DiffusionModelParameter WithQwen2VLVisionPath(this DiffusionModelParameter parameter, string qwen2VLVisionPath) => parameter.WithLLMVisionPath(qwen2VLVisionPath);
public static DiffusionModelParameter WithLLMVisionPath(this DiffusionModelParameter parameter, string llmVisionPath)
{
parameter.Qwen2VLVisionPath = qwen2VLVisionPath;
parameter.LLMVisionPath = llmVisionPath;
return parameter;
}

View File

@ -14,8 +14,8 @@ internal static unsafe class DiffusionModelParameterMarshaller
clip_g_path = AnsiStringMarshaller.ConvertToUnmanaged(managed.ClipGPath),
clip_vision_path = AnsiStringMarshaller.ConvertToUnmanaged(managed.ClipVisionPath),
t5xxl_path = AnsiStringMarshaller.ConvertToUnmanaged(managed.T5xxlPath),
qwen2vl_path = AnsiStringMarshaller.ConvertToUnmanaged(managed.Qwen2VLPath),
qwen2vl_vision_path = AnsiStringMarshaller.ConvertToUnmanaged(managed.Qwen2VLVisionPath),
llm_path = AnsiStringMarshaller.ConvertToUnmanaged(managed.LLMPath),
llm_vision_path = AnsiStringMarshaller.ConvertToUnmanaged(managed.LLMVisionPath),
diffusion_model_path = AnsiStringMarshaller.ConvertToUnmanaged(managed.DiffusionModelPath),
high_noise_diffusion_model_path = AnsiStringMarshaller.ConvertToUnmanaged(managed.HighNoiseDiffusionModelPath),
vae_path = AnsiStringMarshaller.ConvertToUnmanaged(managed.VaePath),
@ -56,8 +56,8 @@ internal static unsafe class DiffusionModelParameterMarshaller
ClipGPath = AnsiStringMarshaller.ConvertToManaged(unmanaged.clip_g_path) ?? string.Empty,
ClipVisionPath = AnsiStringMarshaller.ConvertToManaged(unmanaged.clip_vision_path) ?? string.Empty,
T5xxlPath = AnsiStringMarshaller.ConvertToManaged(unmanaged.t5xxl_path) ?? string.Empty,
Qwen2VLPath = AnsiStringMarshaller.ConvertToManaged(unmanaged.qwen2vl_path) ?? string.Empty,
Qwen2VLVisionPath = AnsiStringMarshaller.ConvertToManaged(unmanaged.qwen2vl_vision_path) ?? string.Empty,
LLMPath = AnsiStringMarshaller.ConvertToManaged(unmanaged.llm_path) ?? string.Empty,
LLMVisionPath = AnsiStringMarshaller.ConvertToManaged(unmanaged.llm_vision_path) ?? string.Empty,
DiffusionModelPath = AnsiStringMarshaller.ConvertToManaged(unmanaged.diffusion_model_path) ?? string.Empty,
HighNoiseDiffusionModelPath = AnsiStringMarshaller.ConvertToManaged(unmanaged.high_noise_diffusion_model_path) ?? string.Empty,
VaePath = AnsiStringMarshaller.ConvertToManaged(unmanaged.vae_path) ?? string.Empty,
@ -96,8 +96,8 @@ internal static unsafe class DiffusionModelParameterMarshaller
AnsiStringMarshaller.Free(unmanaged.clip_l_path);
AnsiStringMarshaller.Free(unmanaged.clip_g_path);
AnsiStringMarshaller.Free(unmanaged.t5xxl_path);
AnsiStringMarshaller.Free(unmanaged.qwen2vl_path);
AnsiStringMarshaller.Free(unmanaged.qwen2vl_vision_path);
AnsiStringMarshaller.Free(unmanaged.llm_path);
AnsiStringMarshaller.Free(unmanaged.llm_vision_path);
AnsiStringMarshaller.Free(unmanaged.diffusion_model_path);
AnsiStringMarshaller.Free(unmanaged.vae_path);
AnsiStringMarshaller.Free(unmanaged.taesd_path);

View File

@ -60,8 +60,8 @@ internal unsafe partial class Native
public byte* clip_g_path;
public byte* clip_vision_path;
public byte* t5xxl_path;
public byte* qwen2vl_path;
public byte* qwen2vl_vision_path;
public byte* llm_path;
public byte* llm_vision_path;
public byte* diffusion_model_path;
public byte* high_noise_diffusion_model_path;
public byte* vae_path;
@ -207,7 +207,7 @@ internal unsafe partial class Native
internal delegate void sd_log_cb_t(sd_log_level_t level, [MarshalAs(UnmanagedType.LPStr)] string text, void* data);
internal delegate void sd_progress_cb_t(int step, int steps, float time, void* data);
internal delegate void sd_preview_cb_t(int step, int frame_count, sd_image_t* frames, bool is_noisy);
internal delegate void sd_preview_cb_t(int step, int frame_count, sd_image_t* frames, bool is_noisy, void* data);
#endregion
@ -220,10 +220,10 @@ internal unsafe partial class Native
internal static partial void sd_set_progress_callback(sd_progress_cb_t cb, void* data);
[LibraryImport(LIB_NAME, EntryPoint = "sd_set_preview_callback")]
internal static partial void sd_set_preview_callback(sd_preview_cb_t? cb, preview_t mode, int interval, [MarshalAs(UnmanagedType.I1)] bool denoised, [MarshalAs(UnmanagedType.I1)] bool noisy);
internal static partial void sd_set_preview_callback(sd_preview_cb_t? cb, preview_t mode, int interval, [MarshalAs(UnmanagedType.I1)] bool denoised, [MarshalAs(UnmanagedType.I1)] bool noisy, void* data);
[LibraryImport(LIB_NAME, EntryPoint = "get_num_physical_cores")]
internal static partial int32_t get_num_physical_cores();
[LibraryImport(LIB_NAME, EntryPoint = "sd_get_num_physical_cores")]
internal static partial int32_t sd_get_num_physical_cores();
[LibraryImport(LIB_NAME, EntryPoint = "sd_get_system_info")]
[return: MarshalAs(UnmanagedType.LPStr)]

View File

@ -45,7 +45,7 @@ public static unsafe class StableDiffusionCpp
else if (_previewCallback == null)
_previewCallback = OnPreview;
Native.sd_set_preview_callback(_previewCallback, mode, interval, denoised, noisy);
Native.sd_set_preview_callback(_previewCallback, mode, interval, denoised, noisy, null);
}
public static void Convert(string modelPath, string vaePath, Quantization quantization, string outputPath, string tensorTypeRules = "")
@ -60,7 +60,7 @@ public static unsafe class StableDiffusionCpp
public static string GetSystemInfo() => Native.sd_get_system_info();
public static int GetNumPhysicalCores() => Native.get_num_physical_cores();
public static int GetNumPhysicalCores() => Native.sd_get_num_physical_cores();
public static Image<ColorRGB> PreprocessCanny(CannyParameter parameter)
{
@ -104,7 +104,7 @@ public static unsafe class StableDiffusionCpp
catch { /**/ }
}
private static void OnPreview(int step, int frameCount, Native.Types.sd_image_t* frames, bool isNoisy)
private static void OnPreview(int step, int frameCount, Native.Types.sd_image_t* frames, bool isNoisy, void* data)
{
try
{