mirror of
https://github.com/DarthAffe/StableDiffusion.NET.git
synced 2025-12-12 21:38:45 +00:00
Compare commits
3 Commits
06b97ba3d8
...
3ec6acb6ea
| Author | SHA1 | Date | |
|---|---|---|---|
| 3ec6acb6ea | |||
| 66568ffee7 | |||
| 1dcbe72e2b |
@ -48,12 +48,10 @@ enum sample_method_t {
|
|||||||
LCM_SAMPLE_METHOD,
|
LCM_SAMPLE_METHOD,
|
||||||
DDIM_TRAILING_SAMPLE_METHOD,
|
DDIM_TRAILING_SAMPLE_METHOD,
|
||||||
TCD_SAMPLE_METHOD,
|
TCD_SAMPLE_METHOD,
|
||||||
|
|
||||||
SAMPLE_METHOD_COUNT
|
SAMPLE_METHOD_COUNT
|
||||||
};
|
};
|
||||||
|
|
||||||
enum scheduler_t {
|
enum scheduler_t {
|
||||||
|
|
||||||
DISCRETE_SCHEDULER,
|
DISCRETE_SCHEDULER,
|
||||||
KARRAS_SCHEDULER,
|
KARRAS_SCHEDULER,
|
||||||
EXPONENTIAL_SCHEDULER,
|
EXPONENTIAL_SCHEDULER,
|
||||||
@ -73,6 +71,7 @@ enum prediction_t {
|
|||||||
EDM_V_PRED,
|
EDM_V_PRED,
|
||||||
SD3_FLOW_PRED,
|
SD3_FLOW_PRED,
|
||||||
FLUX_FLOW_PRED,
|
FLUX_FLOW_PRED,
|
||||||
|
FLUX2_FLOW_PRED,
|
||||||
PREDICTION_COUNT
|
PREDICTION_COUNT
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -158,8 +157,8 @@ typedef struct {
|
|||||||
const char* clip_g_path;
|
const char* clip_g_path;
|
||||||
const char* clip_vision_path;
|
const char* clip_vision_path;
|
||||||
const char* t5xxl_path;
|
const char* t5xxl_path;
|
||||||
const char* qwen2vl_path;
|
const char* llm_path;
|
||||||
const char* qwen2vl_vision_path;
|
const char* llm_vision_path;
|
||||||
const char* diffusion_model_path;
|
const char* diffusion_model_path;
|
||||||
const char* high_noise_diffusion_model_path;
|
const char* high_noise_diffusion_model_path;
|
||||||
const char* vae_path;
|
const char* vae_path;
|
||||||
@ -284,11 +283,11 @@ 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_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_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_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_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 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 get_num_physical_cores();
|
SD_API int32_t get_num_physical_cores();
|
||||||
SD_API const char* sd_get_system_info();
|
SD_API const char* sd_get_system_info();
|
||||||
|
|
||||||
@ -314,7 +313,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 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 free_sd_ctx(sd_ctx_t* sd_ctx);
|
||||||
|
|
||||||
|
|
||||||
SD_API void sd_sample_params_init(sd_sample_params_t* sample_params);
|
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);
|
SD_API char* sd_sample_params_to_str(const sd_sample_params_t* sample_params);
|
||||||
@ -360,4 +358,4 @@ SD_API bool preprocess_canny(sd_image_t image,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // __STABLE_DIFFUSION_H__
|
#endif // __STABLE_DIFFUSION_H__
|
||||||
@ -7,5 +7,6 @@ public enum Prediction
|
|||||||
V,
|
V,
|
||||||
EDM_V,
|
EDM_V,
|
||||||
SD3Flow,
|
SD3Flow,
|
||||||
FluxFlow
|
FluxFlow,
|
||||||
|
Flux2Flow
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using JetBrains.Annotations;
|
using System;
|
||||||
|
using JetBrains.Annotations;
|
||||||
|
|
||||||
namespace StableDiffusion.NET;
|
namespace StableDiffusion.NET;
|
||||||
|
|
||||||
@ -139,9 +140,13 @@ public sealed class DiffusionModelParameter
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string T5xxlPath { get; set; } = string.Empty;
|
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 ClipVisionPath { get; set; } = string.Empty;
|
||||||
public string HighNoiseDiffusionModelPath { get; set; } = string.Empty;
|
public string HighNoiseDiffusionModelPath { get; set; } = string.Empty;
|
||||||
|
|||||||
@ -236,16 +236,20 @@ public static class DiffusionModelBuilderExtension
|
|||||||
return parameter;
|
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;
|
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;
|
return parameter;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,8 +14,8 @@ internal static unsafe class DiffusionModelParameterMarshaller
|
|||||||
clip_g_path = AnsiStringMarshaller.ConvertToUnmanaged(managed.ClipGPath),
|
clip_g_path = AnsiStringMarshaller.ConvertToUnmanaged(managed.ClipGPath),
|
||||||
clip_vision_path = AnsiStringMarshaller.ConvertToUnmanaged(managed.ClipVisionPath),
|
clip_vision_path = AnsiStringMarshaller.ConvertToUnmanaged(managed.ClipVisionPath),
|
||||||
t5xxl_path = AnsiStringMarshaller.ConvertToUnmanaged(managed.T5xxlPath),
|
t5xxl_path = AnsiStringMarshaller.ConvertToUnmanaged(managed.T5xxlPath),
|
||||||
qwen2vl_path = AnsiStringMarshaller.ConvertToUnmanaged(managed.Qwen2VLPath),
|
llm_path = AnsiStringMarshaller.ConvertToUnmanaged(managed.LLMPath),
|
||||||
qwen2vl_vision_path = AnsiStringMarshaller.ConvertToUnmanaged(managed.Qwen2VLVisionPath),
|
llm_vision_path = AnsiStringMarshaller.ConvertToUnmanaged(managed.LLMVisionPath),
|
||||||
diffusion_model_path = AnsiStringMarshaller.ConvertToUnmanaged(managed.DiffusionModelPath),
|
diffusion_model_path = AnsiStringMarshaller.ConvertToUnmanaged(managed.DiffusionModelPath),
|
||||||
high_noise_diffusion_model_path = AnsiStringMarshaller.ConvertToUnmanaged(managed.HighNoiseDiffusionModelPath),
|
high_noise_diffusion_model_path = AnsiStringMarshaller.ConvertToUnmanaged(managed.HighNoiseDiffusionModelPath),
|
||||||
vae_path = AnsiStringMarshaller.ConvertToUnmanaged(managed.VaePath),
|
vae_path = AnsiStringMarshaller.ConvertToUnmanaged(managed.VaePath),
|
||||||
@ -56,8 +56,8 @@ internal static unsafe class DiffusionModelParameterMarshaller
|
|||||||
ClipGPath = AnsiStringMarshaller.ConvertToManaged(unmanaged.clip_g_path) ?? string.Empty,
|
ClipGPath = AnsiStringMarshaller.ConvertToManaged(unmanaged.clip_g_path) ?? string.Empty,
|
||||||
ClipVisionPath = AnsiStringMarshaller.ConvertToManaged(unmanaged.clip_vision_path) ?? string.Empty,
|
ClipVisionPath = AnsiStringMarshaller.ConvertToManaged(unmanaged.clip_vision_path) ?? string.Empty,
|
||||||
T5xxlPath = AnsiStringMarshaller.ConvertToManaged(unmanaged.t5xxl_path) ?? string.Empty,
|
T5xxlPath = AnsiStringMarshaller.ConvertToManaged(unmanaged.t5xxl_path) ?? string.Empty,
|
||||||
Qwen2VLPath = AnsiStringMarshaller.ConvertToManaged(unmanaged.qwen2vl_path) ?? string.Empty,
|
LLMPath = AnsiStringMarshaller.ConvertToManaged(unmanaged.llm_path) ?? string.Empty,
|
||||||
Qwen2VLVisionPath = AnsiStringMarshaller.ConvertToManaged(unmanaged.qwen2vl_vision_path) ?? string.Empty,
|
LLMVisionPath = AnsiStringMarshaller.ConvertToManaged(unmanaged.llm_vision_path) ?? string.Empty,
|
||||||
DiffusionModelPath = AnsiStringMarshaller.ConvertToManaged(unmanaged.diffusion_model_path) ?? string.Empty,
|
DiffusionModelPath = AnsiStringMarshaller.ConvertToManaged(unmanaged.diffusion_model_path) ?? string.Empty,
|
||||||
HighNoiseDiffusionModelPath = AnsiStringMarshaller.ConvertToManaged(unmanaged.high_noise_diffusion_model_path) ?? string.Empty,
|
HighNoiseDiffusionModelPath = AnsiStringMarshaller.ConvertToManaged(unmanaged.high_noise_diffusion_model_path) ?? string.Empty,
|
||||||
VaePath = AnsiStringMarshaller.ConvertToManaged(unmanaged.vae_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_l_path);
|
||||||
AnsiStringMarshaller.Free(unmanaged.clip_g_path);
|
AnsiStringMarshaller.Free(unmanaged.clip_g_path);
|
||||||
AnsiStringMarshaller.Free(unmanaged.t5xxl_path);
|
AnsiStringMarshaller.Free(unmanaged.t5xxl_path);
|
||||||
AnsiStringMarshaller.Free(unmanaged.qwen2vl_path);
|
AnsiStringMarshaller.Free(unmanaged.llm_path);
|
||||||
AnsiStringMarshaller.Free(unmanaged.qwen2vl_vision_path);
|
AnsiStringMarshaller.Free(unmanaged.llm_vision_path);
|
||||||
AnsiStringMarshaller.Free(unmanaged.diffusion_model_path);
|
AnsiStringMarshaller.Free(unmanaged.diffusion_model_path);
|
||||||
AnsiStringMarshaller.Free(unmanaged.vae_path);
|
AnsiStringMarshaller.Free(unmanaged.vae_path);
|
||||||
AnsiStringMarshaller.Free(unmanaged.taesd_path);
|
AnsiStringMarshaller.Free(unmanaged.taesd_path);
|
||||||
|
|||||||
@ -60,8 +60,8 @@ internal unsafe partial class Native
|
|||||||
public byte* clip_g_path;
|
public byte* clip_g_path;
|
||||||
public byte* clip_vision_path;
|
public byte* clip_vision_path;
|
||||||
public byte* t5xxl_path;
|
public byte* t5xxl_path;
|
||||||
public byte* qwen2vl_path;
|
public byte* llm_path;
|
||||||
public byte* qwen2vl_vision_path;
|
public byte* llm_vision_path;
|
||||||
public byte* diffusion_model_path;
|
public byte* diffusion_model_path;
|
||||||
public byte* high_noise_diffusion_model_path;
|
public byte* high_noise_diffusion_model_path;
|
||||||
public byte* vae_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_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_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
|
#endregion
|
||||||
|
|
||||||
@ -220,7 +220,7 @@ internal unsafe partial class Native
|
|||||||
internal static partial void sd_set_progress_callback(sd_progress_cb_t cb, void* data);
|
internal static partial void sd_set_progress_callback(sd_progress_cb_t cb, void* data);
|
||||||
|
|
||||||
[LibraryImport(LIB_NAME, EntryPoint = "sd_set_preview_callback")]
|
[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")]
|
[LibraryImport(LIB_NAME, EntryPoint = "get_num_physical_cores")]
|
||||||
internal static partial int32_t get_num_physical_cores();
|
internal static partial int32_t get_num_physical_cores();
|
||||||
|
|||||||
@ -45,7 +45,7 @@ public static unsafe class StableDiffusionCpp
|
|||||||
else if (_previewCallback == null)
|
else if (_previewCallback == null)
|
||||||
_previewCallback = OnPreview;
|
_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 = "")
|
public static void Convert(string modelPath, string vaePath, Quantization quantization, string outputPath, string tensorTypeRules = "")
|
||||||
@ -104,7 +104,7 @@ public static unsafe class StableDiffusionCpp
|
|||||||
catch { /**/ }
|
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
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user