diff --git a/Header/stable-diffusion.h b/Header/stable-diffusion.h index 8e9104d..b5b6946 100644 --- a/Header/stable-diffusion.h +++ b/Header/stable-diffusion.h @@ -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, @@ -73,6 +71,7 @@ enum prediction_t { EDM_V_PRED, SD3_FLOW_PRED, FLUX_FLOW_PRED, + FLUX2_FLOW_PRED, PREDICTION_COUNT }; @@ -158,8 +157,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,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_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 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 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 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); @@ -360,4 +358,4 @@ SD_API bool preprocess_canny(sd_image_t image, } #endif -#endif // __STABLE_DIFFUSION_H__ +#endif // __STABLE_DIFFUSION_H__ \ No newline at end of file diff --git a/StableDiffusion.NET/Enums/Prediction.cs b/StableDiffusion.NET/Enums/Prediction.cs index 07e916b..f753030 100644 --- a/StableDiffusion.NET/Enums/Prediction.cs +++ b/StableDiffusion.NET/Enums/Prediction.cs @@ -7,5 +7,6 @@ public enum Prediction V, EDM_V, SD3Flow, - FluxFlow + FluxFlow, + Flux2Flow } diff --git a/StableDiffusion.NET/Models/Parameter/DiffusionModelParameter.cs b/StableDiffusion.NET/Models/Parameter/DiffusionModelParameter.cs index 114513f..dc3a7d4 100644 --- a/StableDiffusion.NET/Models/Parameter/DiffusionModelParameter.cs +++ b/StableDiffusion.NET/Models/Parameter/DiffusionModelParameter.cs @@ -1,4 +1,5 @@ -using JetBrains.Annotations; +using System; +using JetBrains.Annotations; namespace StableDiffusion.NET; @@ -139,9 +140,13 @@ public sealed class DiffusionModelParameter /// 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; diff --git a/StableDiffusion.NET/Models/Parameter/Extensions/DiffusionModelBuilderExtension.cs b/StableDiffusion.NET/Models/Parameter/Extensions/DiffusionModelBuilderExtension.cs index 6f9ec7f..6e398c1 100644 --- a/StableDiffusion.NET/Models/Parameter/Extensions/DiffusionModelBuilderExtension.cs +++ b/StableDiffusion.NET/Models/Parameter/Extensions/DiffusionModelBuilderExtension.cs @@ -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; } diff --git a/StableDiffusion.NET/Native/Marshaller/DiffusionModelParameterMarshaller.cs b/StableDiffusion.NET/Native/Marshaller/DiffusionModelParameterMarshaller.cs index f6fabc7..e8ff8b8 100644 --- a/StableDiffusion.NET/Native/Marshaller/DiffusionModelParameterMarshaller.cs +++ b/StableDiffusion.NET/Native/Marshaller/DiffusionModelParameterMarshaller.cs @@ -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); diff --git a/StableDiffusion.NET/Native/Native.cs b/StableDiffusion.NET/Native/Native.cs index 6e3ec63..16ef550 100644 --- a/StableDiffusion.NET/Native/Native.cs +++ b/StableDiffusion.NET/Native/Native.cs @@ -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,7 +220,7 @@ 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(); diff --git a/StableDiffusion.NET/StableDiffusionCpp.cs b/StableDiffusion.NET/StableDiffusionCpp.cs index 48081fd..13e4c0a 100644 --- a/StableDiffusion.NET/StableDiffusionCpp.cs +++ b/StableDiffusion.NET/StableDiffusionCpp.cs @@ -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 = "") @@ -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 {