diff --git a/cli/src/main.rs b/cli/src/main.rs index e3f808a..ec77439 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -12,9 +12,9 @@ use diffusion_rs::{ preset::{ Anima2Weight, AnimaWeight, ChromaRadianceWeight, ChromaWeight, DiffInstructStarWeight, ErnieImageWeight, Flux1MiniWeight, Flux1Weight, Flux2Klein4BWeight, Flux2Klein9BWeight, - Flux2KleinBase4BWeight, Flux2KleinBase9BWeight, Flux2Weight, LongCatImageWeight, - NitroSDRealismWeight, NitroSDVibrantWeight, OvisImageWeight, Preset, PresetBuilder, - PresetDiscriminants, QwenImageWeight, SDXS512DreamShaperWeight, SSD1BWeight, + Flux2KleinBase4BWeight, Flux2KleinBase9BWeight, Flux2Weight, Krea2Weight, + LongCatImageWeight, NitroSDRealismWeight, NitroSDVibrantWeight, OvisImageWeight, Preset, + PresetBuilder, PresetDiscriminants, QwenImageWeight, SDXS512DreamShaperWeight, SSD1BWeight, TwinFlowZImageTurboExpWeight, WeightType, ZImageTurboWeight, }, util::set_hf_token, @@ -416,6 +416,20 @@ fn get_preset(args: &Args) -> Preset { ), PresetDiscriminants::Lens => Preset::Lens, PresetDiscriminants::LensTurbo => Preset::LensTurbo, + PresetDiscriminants::BooguImage => Preset::BooguImage, + PresetDiscriminants::BooguImageTurbo => Preset::BooguImageTurbo, + PresetDiscriminants::Krea2 => Preset::Krea2( + args.weights + .unwrap_or_else(|| Krea2Weight::default().into()) + .try_into() + .unwrap(), + ), + PresetDiscriminants::Krea2Turbo => Preset::Krea2Turbo( + args.weights + .unwrap_or_else(|| Krea2Weight::default().into()) + .try_into() + .unwrap(), + ), }; preset } diff --git a/gui/lib/features/params/providers/params_provider.dart b/gui/lib/features/params/providers/params_provider.dart index 5f486ef..6b2b55f 100644 --- a/gui/lib/features/params/providers/params_provider.dart +++ b/gui/lib/features/params/providers/params_provider.dart @@ -112,10 +112,9 @@ class ParamsNotifier extends Notifier { ParamsState build() { final firstPreset = getPresets().first; final defaults = PresetCatalog.getDefaults(firstPreset); - final firstWeights = getWeightsForPreset(preset: firstPreset); return ParamsState( selectedPreset: firstPreset, - selectedWeight: firstWeights.isEmpty ? null : firstWeights.first, + selectedWeight: defaults.weight, steps: defaults.steps, width: defaults.width, height: defaults.height, @@ -124,10 +123,9 @@ class ParamsNotifier extends Notifier { void setPreset(String preset) { final defaults = PresetCatalog.getDefaults(preset); - final weights = getWeightsForPreset(preset: preset); state = state.copyWith( selectedPreset: preset, - selectedWeightFn: () => weights.isEmpty ? null : weights.first, + selectedWeightFn: () => defaults.weight, stepsFn: () => defaults.steps, widthFn: () => defaults.width, heightFn: () => defaults.height, diff --git a/gui/lib/shared/models/preset_catalog.dart b/gui/lib/shared/models/preset_catalog.dart index d185aa2..76edd4c 100644 --- a/gui/lib/shared/models/preset_catalog.dart +++ b/gui/lib/shared/models/preset_catalog.dart @@ -3,8 +3,9 @@ class PresetDefaults { final int? steps; final int? width; final int? height; + final String? weight; - const PresetDefaults({this.steps, this.width, this.height}); + const PresetDefaults({this.steps, this.width, this.height, this.weight}); } /// Hardcoded preset catalog mirroring src/preset.rs (per D-10, MOCK-04). @@ -15,280 +16,199 @@ class PresetDefaults { class PresetCatalog { PresetCatalog._(); - /// Ordered list of all 42 preset names matching the Preset enum in - /// src/preset.rs. Display labels use PascalCase enum names per UI-SPEC. - static const List presetNames = [ - 'StableDiffusion1_4', - 'StableDiffusion1_5', - 'StableDiffusion2_1', - 'StableDiffusion3Medium', - 'StableDiffusion3_5Medium', - 'StableDiffusion3_5Large', - 'StableDiffusion3_5LargeTurbo', - 'SDXLBase1_0', - 'SDTurbo', - 'SDXLTurbo1_0', - 'Flux1Dev', - 'Flux1Schnell', - 'Flux1Mini', - 'JuggernautXL11', - 'Chroma', - 'NitroSDRealism', - 'NitroSDVibrant', - 'DiffInstructStar', - 'ChromaRadiance', - 'SSD1B', - 'Flux2Dev', - 'ZImageTurbo', - 'QwenImage', - 'OvisImage', - 'DreamShaperXL2_1Turbo', - 'TwinFlowZImageTurboExp', - 'SDXS512DreamShaper', - 'Flux2Klein4B', - 'Flux2KleinBase4B', - 'Flux2Klein9B', - 'Flux2KleinBase9B', - 'SegmindVega', - 'Anima', - 'Anima2', - 'ErnieImage', - 'ErnieImageTurbo', - 'HiDreamO1ImageDev', - 'HiDreamO1Image', - 'LongCatImage', - 'Lens', - 'LensTurbo', - ]; - - /// Weight variants available for each preset, derived from subenum - /// annotations in src/preset.rs. Empty list means no weight variants. - /// Weight labels use human-readable quantization strings per D-11. - static const Map> _weightsByPreset = { - 'StableDiffusion1_4': [], - 'StableDiffusion1_5': [], - 'StableDiffusion2_1': [], - 'StableDiffusion3Medium': [], - 'StableDiffusion3_5Medium': [], - 'StableDiffusion3_5Large': [], - 'StableDiffusion3_5LargeTurbo': [], - 'SDXLBase1_0': [], - 'SDTurbo': [], - 'SDXLTurbo1_0': [], - 'Flux1Dev': ['Q2_K', 'Q3_K', 'Q4_0', 'Q4_K', 'Q8_0'], - 'Flux1Schnell': ['Q2_K', 'Q3_K', 'Q4_0', 'Q4_K', 'Q8_0'], - 'Flux1Mini': ['F32', 'Q2_K', 'Q3_K', 'Q5_K', 'Q6_K', 'Q8_0', 'BF16'], - 'JuggernautXL11': [], - 'Chroma': ['Q4_0', 'Q8_0', 'BF16'], - 'NitroSDRealism': ['F16', 'Q2_K', 'Q3_K', 'Q4_0', 'Q5_0', 'Q6_K', 'Q8_0'], - 'NitroSDVibrant': ['F16', 'Q2_K', 'Q3_K', 'Q4_0', 'Q5_0', 'Q6_K', 'Q8_0'], - 'DiffInstructStar': [ - 'F16', - 'Q2_K', - 'Q3_K', - 'Q4_0', - 'Q5_0', - 'Q6_K', - 'Q8_0', - ], - 'ChromaRadiance': ['Q8_0', 'BF16'], - 'SSD1B': ['F16', 'F8_E4M3'], - 'Flux2Dev': [ - 'Q2_K', - 'Q3_K', - 'Q4_0', - 'Q4_1', - 'Q4_K', - 'Q5_0', - 'Q5_1', - 'Q5_K', - 'Q6_K', - 'Q8_0', - 'BF16', - ], - 'ZImageTurbo': [ - 'Q2_K', - 'Q3_K', - 'Q4_0', - 'Q4_K', - 'Q5_0', - 'Q6_K', - 'Q8_0', - 'BF16', - ], - 'QwenImage': [ - 'Q2_K', - 'Q3_K', - 'Q4_0', - 'Q4_1', - 'Q4_K', - 'Q5_0', - 'Q5_1', - 'Q5_K', - 'Q6_K', - 'Q8_0', - 'BF16', - 'F8_E4M3', - ], - 'OvisImage': ['Q4_0', 'Q8_0', 'BF16'], - 'DreamShaperXL2_1Turbo': [], - 'TwinFlowZImageTurboExp': ['Q3_K', 'Q4_0', 'Q5_0', 'Q6_K', 'Q8_0', 'BF16'], - 'SDXS512DreamShaper': ['F16', 'Q8_0'], - 'Flux2Klein4B': ['Q4_0', 'Q8_0', 'BF16'], - 'Flux2KleinBase4B': ['Q4_0', 'Q8_0', 'BF16'], - 'Flux2Klein9B': ['Q4_0', 'Q8_0', 'BF16'], - 'Flux2KleinBase9B': ['Q4_0', 'Q8_0', 'BF16'], - 'SegmindVega': [], - 'Anima': [ - 'Q3_K', - 'Q4_0', - 'Q4_1', - 'Q4_K', - 'Q5_0', - 'Q5_1', - 'Q5_K', - 'Q6_K', - 'Q8_0', - 'BF16', - ], - 'Anima2': ['Q4_K', 'Q5_K', 'Q6_K', 'Q8_0', 'BF16'], - 'ErnieImage': [ - 'F16', - 'Q2_K', - 'Q3_K', - 'Q4_0', - 'Q4_1', - 'Q4_K', - 'Q5_0', - 'Q5_1', - 'Q5_K', - 'Q6_K', - 'Q8_0', - 'BF16', - ], - 'ErnieImageTurbo': [ - 'F16', - 'Q2_K', - 'Q3_K', - 'Q4_0', - 'Q4_1', - 'Q4_K', - 'Q5_0', - 'Q5_1', - 'Q5_K', - 'Q6_K', - 'Q8_0', - 'BF16', - ], - 'HiDreamO1ImageDev': [], - 'HiDreamO1Image': [], - 'LongCatImage': [ - 'Q3_K', - 'Q4_0', - 'Q4_1', - 'Q4_K', - 'Q5_0', - 'Q5_1', - 'Q5_K', - 'Q6_K', - 'Q8_0', - 'BF16', - ], - 'Lens': [], - 'LensTurbo': [], - }; - - /// Default weight for each preset that has weight variants. - /// Derived from the (default) annotation in subenum definitions. - static const Map _defaultWeights = { - 'Flux1Dev': 'Q2_K', - 'Flux1Schnell': 'Q2_K', - 'Flux1Mini': 'Q8_0', - 'Chroma': 'Q4_0', - 'NitroSDRealism': 'Q8_0', - 'NitroSDVibrant': 'Q8_0', - 'DiffInstructStar': 'Q8_0', - 'ChromaRadiance': 'Q8_0', - 'SSD1B': 'F8_E4M3', - 'Flux2Dev': 'Q2_K', - 'ZImageTurbo': 'Q4_K', - 'QwenImage': 'Q2_K', - 'OvisImage': 'Q4_0', - 'TwinFlowZImageTurboExp': 'Q4_0', - 'SDXS512DreamShaper': 'F16', - 'Flux2Klein4B': 'Q8_0', - 'Flux2KleinBase4B': 'Q8_0', - 'Flux2Klein9B': 'Q4_0', - 'Flux2KleinBase9B': 'Q4_0', - 'Anima': 'Q8_0', - 'Anima2': 'Q8_0', - 'ErnieImage': 'Q4_0', - 'ErnieImageTurbo': 'Q4_0', - 'LongCatImage': 'Q4_0', - }; - - /// Returns weight variants available for the given [presetName]. - /// Returns an empty list when the preset has no weight variants. - static List getWeights(String presetName) { - return _weightsByPreset[presetName] ?? const []; - } - - /// Returns the default weight for the given [presetName], or null - /// if the preset has no weight variants. - static String? getDefaultWeight(String presetName) { - return _defaultWeights[presetName]; - } - - /// Whether the given [presetName] has weight variants. - static bool hasWeights(String presetName) { - final weights = _weightsByPreset[presetName]; - return weights != null && weights.isNotEmpty; - } - /// Per-preset default steps/width/height extracted from src/preset_builder.rs. /// Null fields mean the preset relies on model/backend defaults. static const Map _defaultsByPreset = { 'StableDiffusion1_4': PresetDefaults(steps: 20, width: 512, height: 512), 'StableDiffusion1_5': PresetDefaults(steps: 20, width: 512, height: 512), 'StableDiffusion2_1': PresetDefaults(steps: 25, width: 768, height: 768), - 'StableDiffusion3Medium': PresetDefaults(steps: 30, width: 1024, height: 1024), - 'StableDiffusion3_5Medium': PresetDefaults(steps: 40, width: 1024, height: 1024), - 'StableDiffusion3_5Large': PresetDefaults(steps: 28, width: 1024, height: 1024), - 'StableDiffusion3_5LargeTurbo': PresetDefaults(steps: 4, width: 1024, height: 1024), + 'StableDiffusion3Medium': PresetDefaults( + steps: 30, + width: 1024, + height: 1024, + ), + 'StableDiffusion3_5Medium': PresetDefaults( + steps: 40, + width: 1024, + height: 1024, + ), + 'StableDiffusion3_5Large': PresetDefaults( + steps: 28, + width: 1024, + height: 1024, + ), + 'StableDiffusion3_5LargeTurbo': PresetDefaults( + steps: 4, + width: 1024, + height: 1024, + ), 'SDXLBase1_0': PresetDefaults(steps: 20, width: 1024, height: 1024), 'SDTurbo': PresetDefaults(steps: 4, width: 512, height: 512), 'SDXLTurbo1_0': PresetDefaults(steps: 4, width: 512, height: 512), - 'Flux1Dev': PresetDefaults(steps: 28, width: 1024, height: 1024), - 'Flux1Schnell': PresetDefaults(steps: 4, width: 1024, height: 1024), - 'Flux1Mini': PresetDefaults(steps: 20, width: 1024, height: 1024), + 'Flux1Dev': PresetDefaults( + steps: 28, + width: 1024, + height: 1024, + weight: 'Q2_K', + ), + 'Flux1Schnell': PresetDefaults( + steps: 4, + width: 1024, + height: 1024, + weight: 'Q2_K', + ), + 'Flux1Mini': PresetDefaults( + steps: 20, + width: 1024, + height: 1024, + weight: 'Q8_0', + ), 'JuggernautXL11': PresetDefaults(steps: 20, width: 1024, height: 1024), - 'Chroma': PresetDefaults(steps: 20, width: 512, height: 512), - 'NitroSDRealism': PresetDefaults(steps: 1, width: 1024, height: 1024), - 'NitroSDVibrant': PresetDefaults(steps: 1, width: 1024, height: 1024), - 'DiffInstructStar': PresetDefaults(steps: 1, width: 1024, height: 1024), - 'ChromaRadiance': PresetDefaults(steps: 20, width: 512, height: 512), - 'SSD1B': PresetDefaults(steps: 20, width: 1024, height: 1024), - 'Flux2Dev': PresetDefaults(steps: 20, width: 512, height: 512), - 'ZImageTurbo': PresetDefaults(steps: 9, width: 512, height: 1024), - 'QwenImage': PresetDefaults(steps: 20, width: 1024, height: 1024), - 'OvisImage': PresetDefaults(steps: 20, width: 512, height: 512), - 'DreamShaperXL2_1Turbo': PresetDefaults(steps: 6, width: 1024, height: 1024), - 'TwinFlowZImageTurboExp': PresetDefaults(steps: 3, width: 512, height: 1024), - 'SDXS512DreamShaper': PresetDefaults(steps: 1, width: 512, height: 512), - 'Flux2Klein4B': PresetDefaults(steps: 4, width: 1024, height: 1024), - 'Flux2KleinBase4B': PresetDefaults(steps: 20, width: 1024, height: 1024), - 'Flux2Klein9B': PresetDefaults(steps: 4, width: 1024, height: 1024), - 'Flux2KleinBase9B': PresetDefaults(steps: 20, width: 1024, height: 1024), + 'Chroma': PresetDefaults( + steps: 20, + width: 512, + height: 512, + weight: 'Q4_0', + ), + 'NitroSDRealism': PresetDefaults( + steps: 1, + width: 1024, + height: 1024, + weight: 'Q8_0', + ), + 'NitroSDVibrant': PresetDefaults( + steps: 1, + width: 1024, + height: 1024, + weight: 'Q8_0', + ), + 'DiffInstructStar': PresetDefaults( + steps: 1, + width: 1024, + height: 1024, + weight: 'Q8_0', + ), + 'ChromaRadiance': PresetDefaults( + steps: 20, + width: 512, + height: 512, + weight: 'Q4_0', + ), + 'SSD1B': PresetDefaults( + steps: 20, + width: 1024, + height: 1024, + weight: 'F8_E4M3', + ), + 'Flux2Dev': PresetDefaults( + steps: 20, + width: 512, + height: 512, + weight: 'Q2_K', + ), + 'ZImageTurbo': PresetDefaults( + steps: 9, + width: 512, + height: 1024, + weight: 'Q4_K', + ), + 'QwenImage': PresetDefaults( + steps: 20, + width: 1024, + height: 1024, + weight: 'Q2_K', + ), + 'OvisImage': PresetDefaults( + steps: 20, + width: 512, + height: 512, + weight: 'Q4_0', + ), + 'DreamShaperXL2_1Turbo': PresetDefaults( + steps: 6, + width: 1024, + height: 1024, + ), + 'TwinFlowZImageTurboExp': PresetDefaults( + steps: 3, + width: 512, + height: 1024, + weight: 'Q4_0', + ), + 'SDXS512DreamShaper': PresetDefaults( + steps: 1, + width: 512, + height: 512, + weight: 'F16', + ), + 'Flux2Klein4B': PresetDefaults( + steps: 4, + width: 1024, + height: 1024, + weight: 'Q8_0', + ), + 'Flux2KleinBase4B': PresetDefaults( + steps: 20, + width: 1024, + height: 1024, + weight: 'Q8_0', + ), + 'Flux2Klein9B': PresetDefaults( + steps: 4, + width: 1024, + height: 1024, + weight: 'Q4_0', + ), + 'Flux2KleinBase9B': PresetDefaults( + steps: 20, + width: 1024, + height: 1024, + weight: 'Q4_0', + ), 'SegmindVega': PresetDefaults(steps: 25, width: 1024, height: 1024), - 'Anima': PresetDefaults(steps: 30, width: 1024, height: 1024), - 'Anima2': PresetDefaults(steps: 30, width: 1024, height: 1024), - 'ErnieImage': PresetDefaults(steps: 20, width: 1024, height: 1024), - 'ErnieImageTurbo': PresetDefaults(steps: 8, width: 1024, height: 1024), + 'Anima': PresetDefaults( + steps: 30, + width: 1024, + height: 1024, + weight: 'Q8_0', + ), + 'Anima2': PresetDefaults( + steps: 30, + width: 1024, + height: 1024, + weight: 'Q8_0', + ), + 'ErnieImage': PresetDefaults( + steps: 20, + width: 1024, + height: 1024, + weight: 'Q4_0', + ), + 'ErnieImageTurbo': PresetDefaults( + steps: 8, + width: 1024, + height: 1024, + weight: 'Q4_0', + ), 'HiDreamO1ImageDev': PresetDefaults(steps: 20, width: 1024, height: 1024), 'HiDreamO1Image': PresetDefaults(steps: 20, width: 1024, height: 1024), - 'LongCatImage': PresetDefaults(steps: 20, width: 512, height: 512), + 'LongCatImage': PresetDefaults( + steps: 20, + width: 512, + height: 512, + weight: 'Q4_0', + ), 'Lens': PresetDefaults(steps: 20, width: 512, height: 512), 'LensTurbo': PresetDefaults(steps: 4, width: 512, height: 512), + 'BooguImage': PresetDefaults(steps: 20, width: 512, height: 512), + 'BooguImageTurbo': PresetDefaults(steps: 4, width: 512, height: 512), + 'Krea2': PresetDefaults(steps: 20, width: 512, height: 512, weight: 'Q3_K'), + 'Krea2Turbo': PresetDefaults( + steps: 4, + width: 512, + height: 512, + weight: 'Q3_K', + ), }; /// Returns the default steps/width/height for [presetName]. diff --git a/gui/rust/src/api.rs b/gui/rust/src/api.rs index ac85db9..0c42e4c 100644 --- a/gui/rust/src/api.rs +++ b/gui/rust/src/api.rs @@ -17,7 +17,7 @@ use diffusion_rs::preset::{ Flux2KleinBase4BWeight, Flux2KleinBase9BWeight, Flux2Weight, LongCatImageWeight, NitroSDRealismWeight, NitroSDVibrantWeight, OvisImageWeight, PresetDiscriminants, QwenImageWeight, SDXS512DreamShaperWeight, SSD1BWeight, TwinFlowZImageTurboExpWeight, - ZImageTurboWeight, + ZImageTurboWeight, Krea2Weight, }; use crate::bridge; @@ -99,7 +99,10 @@ fn _get_weights_for_preset(preset: String) -> Vec { | PresetDiscriminants::HiDreamO1ImageDev | PresetDiscriminants::HiDreamO1Image | PresetDiscriminants::Lens - | PresetDiscriminants::LensTurbo => Vec::new(), + | PresetDiscriminants::LensTurbo + | PresetDiscriminants::BooguImage + | PresetDiscriminants::BooguImageTurbo + => Vec::new(), // Presets with weights PresetDiscriminants::Flux1Dev | PresetDiscriminants::Flux1Schnell => { @@ -130,6 +133,9 @@ fn _get_weights_for_preset(preset: String) -> Vec { weight_variants!(ErnieImageWeight) } PresetDiscriminants::LongCatImage => weight_variants!(LongCatImageWeight), + PresetDiscriminants::Krea2 | PresetDiscriminants::Krea2Turbo => { + weight_variants!(Krea2Weight) + } } } diff --git a/gui/rust/src/bridge.rs b/gui/rust/src/bridge.rs index 1f825d4..f11c580 100644 --- a/gui/rust/src/bridge.rs +++ b/gui/rust/src/bridge.rs @@ -21,7 +21,7 @@ use diffusion_rs::preset::{ Flux2KleinBase4BWeight, Flux2KleinBase9BWeight, Flux2Weight, LongCatImageWeight, NitroSDRealismWeight, NitroSDVibrantWeight, OvisImageWeight, Preset, PresetBuilder, PresetDiscriminants, QwenImageWeight, SDXS512DreamShaperWeight, SSD1BWeight, - TwinFlowZImageTurboExpWeight, WeightType, ZImageTurboWeight, + TwinFlowZImageTurboExpWeight, WeightType, ZImageTurboWeight, Krea2Weight, }; use diffusion_rs::util::set_hf_token; @@ -72,6 +72,9 @@ pub fn map_preset(preset_str: &str, weight_str: Option<&str>) -> Result PresetDiscriminants::HiDreamO1Image => Ok(Preset::HiDreamO1Image), PresetDiscriminants::Lens => Ok(Preset::Lens), PresetDiscriminants::LensTurbo => Ok(Preset::LensTurbo), + PresetDiscriminants::BooguImage => Ok(Preset::BooguImage), + PresetDiscriminants::BooguImageTurbo => Ok(Preset::BooguImageTurbo), + // Presets with weights PresetDiscriminants::Flux1Dev => with_weight!(Flux1Dev, Flux1Weight), @@ -98,6 +101,9 @@ pub fn map_preset(preset_str: &str, weight_str: Option<&str>) -> Result PresetDiscriminants::ErnieImage => with_weight!(ErnieImage, ErnieImageWeight), PresetDiscriminants::ErnieImageTurbo => with_weight!(ErnieImageTurbo, ErnieImageWeight), PresetDiscriminants::LongCatImage => with_weight!(LongCatImage, LongCatImageWeight), + PresetDiscriminants::Krea2 => with_weight!(Krea2, Krea2Weight), + PresetDiscriminants::Krea2Turbo => with_weight!(Krea2Turbo, Krea2Weight), + } } diff --git a/src/api.rs b/src/api.rs index 12282d3..f8ece7e 100644 --- a/src/api.rs +++ b/src/api.rs @@ -571,7 +571,7 @@ pub struct ModelConfig { #[builder(default = "(None, CLibString::default())", setter(custom))] extra_tiling_args: (Option>, CLibString), - /// Enable residency+prefetch streaming on top of [ModelConfig::max_vram] (no effect without [ModelConfig::max_vram]; defaults to false) + /// Enable residency+prefetch streaming on top of [ModelConfigBuilder::max_vram] (no effect without [ModelConfigBuilder::max_vram]; defaults to false) #[builder(default = "false")] stream_layers: bool, diff --git a/src/preset.rs b/src/preset.rs index 85acdc8..8197e34 100644 --- a/src/preset.rs +++ b/src/preset.rs @@ -6,13 +6,13 @@ use subenum::subenum; use crate::{ api::{Config, ConfigBuilder, ConfigBuilderError, ModelConfig, ModelConfigBuilder}, preset_builder::{ - anima, anima2, chroma, chroma_radiance, diff_instruct_star, dream_shaper_xl_2_1_turbo, - ernie_image, ernie_image_turbo, flux_1_dev, flux_1_mini, flux_1_schnell, flux_2_dev, - flux_2_klein_4b, flux_2_klein_9b, flux_2_klein_base_4b, flux_2_klein_base_9b, - hi_dream_o1_image, hi_dream_o1_image_dev, juggernaut_xl_11, lens, lens_turbo, - long_cat_image, nitro_sd_realism, nitro_sd_vibrant, ovis_image, qwen_image, sd_turbo, - sdxl_base_1_0, sdxl_turbo_1_0, sdxs512_dream_shaper, segmind_vega, ssd_1b, - stable_diffusion_1_4, stable_diffusion_1_5, stable_diffusion_2_1, + anima, anima2, boogu_image, boogu_image_turbo, chroma, chroma_radiance, diff_instruct_star, + dream_shaper_xl_2_1_turbo, ernie_image, ernie_image_turbo, flux_1_dev, flux_1_mini, + flux_1_schnell, flux_2_dev, flux_2_klein_4b, flux_2_klein_9b, flux_2_klein_base_4b, + flux_2_klein_base_9b, hi_dream_o1_image, hi_dream_o1_image_dev, juggernaut_xl_11, krea2, + krea2_turbo, lens, lens_turbo, long_cat_image, nitro_sd_realism, nitro_sd_vibrant, + ovis_image, qwen_image, sd_turbo, sdxl_base_1_0, sdxl_turbo_1_0, sdxs512_dream_shaper, + segmind_vega, ssd_1b, stable_diffusion_1_4, stable_diffusion_1_5, stable_diffusion_2_1, stable_diffusion_3_5_large, stable_diffusion_3_5_large_turbo, stable_diffusion_3_5_medium, stable_diffusion_3_medium, twinflow_z_image_turbo, z_image_turbo, }, @@ -42,7 +42,8 @@ use crate::{ Anima2Weight(derive(Default)), SDXS512DreamShaperWeight(derive(Default)), ErnieImageWeight(derive(Default)), - LongCatImageWeight(derive(Default)) + LongCatImageWeight(derive(Default)), + Krea2Weight(derive(Default, PartialEq)) )] #[derive(Debug, Clone, Copy, EnumString, VariantNames)] #[strum(ascii_case_insensitive)] @@ -128,7 +129,8 @@ pub enum WeightType { Anima2Weight(default), SDXS512DreamShaperWeight, ErnieImageWeight, - LongCatImageWeight + LongCatImageWeight, + Krea2Weight )] Q8_0, Q8_1, @@ -156,7 +158,8 @@ pub enum WeightType { TwinFlowZImageTurboExpWeight, AnimaWeight, ErnieImageWeight, - LongCatImageWeight + LongCatImageWeight, + Krea2Weight(default) )] Q3_K, #[subenum( @@ -167,7 +170,8 @@ pub enum WeightType { AnimaWeight, Anima2Weight, ErnieImageWeight, - LongCatImageWeight + LongCatImageWeight, + Krea2Weight )] Q4_K, #[subenum( @@ -177,7 +181,8 @@ pub enum WeightType { AnimaWeight, Anima2Weight, ErnieImageWeight, - LongCatImageWeight + LongCatImageWeight, + Krea2Weight )] Q5_K, #[subenum( @@ -192,7 +197,8 @@ pub enum WeightType { AnimaWeight, Anima2Weight, ErnieImageWeight, - LongCatImageWeight + LongCatImageWeight, + Krea2Weight )] Q6_K, Q8_K, @@ -345,6 +351,16 @@ pub enum Preset { /// Requires access rights to providing a token via [crate::util::set_hf_token] /// cfg_scale 1.0. Enable Model Diffusion Flash attention. 512x512. 4 steps LensTurbo, + /// Requires access rights to providing a token via [crate::util::set_hf_token] + /// Diffusion Flash attention enabled. 512x512. 20 steps. Offload params to CPU enabled. + BooguImage, + /// Requires access rights to providing a token via [crate::util::set_hf_token] + /// Diffusion Flash attention enabled. 512x512. 4 steps. Offload params to CPU enabled. + BooguImageTurbo, + /// Diffusion Flash attention enabled. 512x512. 20 steps. Offload params to CPU enabled. + Krea2(Krea2Weight), + /// Diffusion Flash attention enabled. 512x512. 4 steps. Offload params to CPU enabled. + Krea2Turbo(Krea2Weight), } impl Preset { @@ -391,6 +407,10 @@ impl Preset { Preset::LongCatImage(sd_type_t) => long_cat_image(sd_type_t), Preset::Lens => lens(), Preset::LensTurbo => lens_turbo(), + Preset::BooguImage => boogu_image(), + Preset::BooguImageTurbo => boogu_image_turbo(), + Preset::Krea2(sd_type_t) => krea2(sd_type_t), + Preset::Krea2Turbo(sd_type_t) => krea2_turbo(sd_type_t), } } } @@ -464,9 +484,9 @@ mod tests { preset::{ ChromaRadianceWeight, ChromaWeight, DiffInstructStarWeight, Flux1MiniWeight, Flux1Weight, Flux2Klein4BWeight, Flux2Klein9BWeight, Flux2KleinBase4BWeight, - Flux2KleinBase9BWeight, Flux2Weight, NitroSDRealismWeight, NitroSDVibrantWeight, - OvisImageWeight, QwenImageWeight, SDXS512DreamShaperWeight, SSD1BWeight, - TwinFlowZImageTurboExpWeight, ZImageTurboWeight, + Flux2KleinBase9BWeight, Flux2Weight, Krea2Weight, NitroSDRealismWeight, + NitroSDVibrantWeight, OvisImageWeight, QwenImageWeight, SDXS512DreamShaperWeight, + SSD1BWeight, TwinFlowZImageTurboExpWeight, ZImageTurboWeight, }, util::set_hf_token, }; @@ -734,4 +754,28 @@ mod tests { fn test_lens_turbo() { run(Preset::LensTurbo); } + + #[ignore] + #[test] + fn test_boogu_image() { + run(Preset::BooguImage); + } + + #[ignore] + #[test] + fn test_boogu_image_turbo() { + run(Preset::BooguImageTurbo); + } + + #[ignore] + #[test] + fn test_krea2() { + run(Preset::Krea2(Krea2Weight::Q3_K)); + } + + #[ignore] + #[test] + fn test_krea2_turbo() { + run(Preset::Krea2Turbo(Krea2Weight::Q3_K)); + } } diff --git a/src/preset_builder.rs b/src/preset_builder.rs index e265cb8..4030f3d 100644 --- a/src/preset_builder.rs +++ b/src/preset_builder.rs @@ -10,9 +10,9 @@ use crate::{ Anima2Weight, AnimaWeight, ChromaRadianceWeight, ChromaWeight, ConfigsBuilder, DiffInstructStarWeight, ErnieImageWeight, Flux1MiniWeight, Flux1Weight, Flux2Klein4BWeight, Flux2Klein9BWeight, Flux2KleinBase4BWeight, Flux2KleinBase9BWeight, Flux2Weight, - LongCatImageWeight, NitroSDRealismWeight, NitroSDVibrantWeight, OvisImageWeight, - QwenImageWeight, SDXS512DreamShaperWeight, SSD1BWeight, TwinFlowZImageTurboExpWeight, - ZImageTurboWeight, + Krea2Weight, LongCatImageWeight, NitroSDRealismWeight, NitroSDVibrantWeight, + OvisImageWeight, QwenImageWeight, SDXS512DreamShaperWeight, SSD1BWeight, + TwinFlowZImageTurboExpWeight, ZImageTurboWeight, }, }; use diffusion_rs_sys::scheduler_t; @@ -1707,3 +1707,117 @@ pub fn lens() -> Result { Ok((config, model_config)) } + +pub fn boogu_image() -> Result { + let model = download_file_hf_hub( + "Comfy-Org/Boogu-Image", + "diffusion_models/boogu_image_base_bf16.safetensors", + )?; + let (config, mut model_config) = boogu_image_common()?; + model_config.diffusion_model(model); + Ok((config, model_config)) +} + +pub fn boogu_image_turbo() -> Result { + let model = download_file_hf_hub( + "Comfy-Org/Boogu-Image", + "diffusion_models/diffusion_models/diffusion_models/boogu_image_turbo_hotfix_bf16.safetensors", + )?; + let (mut config, mut model_config) = boogu_image_common()?; + model_config.diffusion_model(model); + config.steps(4); + Ok((config, model_config)) +} + +fn boogu_image_common() -> Result { + let llm = download_file_hf_hub( + "unsloth/Qwen3-VL-8B-Instruct-GGUF", + "Qwen3-VL-8B-Instruct-Q4_K_M.gguf", + )?; + let vae = download_file_hf_hub("black-forest-labs/FLUX.1-dev", "ae.safetensors")?; + + let config = ConfigBuilder::default(); + let mut model_config = ModelConfigBuilder::default(); + + model_config + .llm(llm) + .vae(vae) + .diffusion_flash_attention(true); + + offload_params_to_cpu((config, model_config)) +} + +pub fn krea2(sd_type_t: Krea2Weight) -> Result { + let model = match sd_type_t { + Krea2Weight::Q8_0 => { + download_file_hf_hub("realrebelai/KREA-2_GGUFs", "BASE/Krea-2-Base-Q8_0.gguf") + } + Krea2Weight::Q3_K => { + download_file_hf_hub("realrebelai/KREA-2_GGUFs", "BASE/Krea-2-Base-Q3_K_M.gguf") + } + Krea2Weight::Q4_K => { + download_file_hf_hub("realrebelai/KREA-2_GGUFs", "BASE/Krea-2-Base-Q4_K_M.gguf") + } + Krea2Weight::Q5_K => { + download_file_hf_hub("realrebelai/KREA-2_GGUFs", "BASE/Krea-2-Base-Q5_K_M.gguf") + } + Krea2Weight::Q6_K => { + download_file_hf_hub("realrebelai/KREA-2_GGUFs", "BASE/Krea-2-Base-Q6_K.gguf") + } + }?; + let (config, mut model_config) = krea2_common(sd_type_t)?; + model_config.diffusion_model(model); + Ok((config, model_config)) +} + +pub fn krea2_turbo(sd_type_t: Krea2Weight) -> Result { + let model = match sd_type_t { + Krea2Weight::Q8_0 => { + download_file_hf_hub("realrebelai/KREA-2_GGUFs", "TURBO/Krea-2-Turbo-Q8_0.gguf") + } + Krea2Weight::Q3_K => { + download_file_hf_hub("realrebelai/KREA-2_GGUFs", "TURBO/Krea-2-Turbo-Q3_K_M.gguf") + } + Krea2Weight::Q4_K => { + download_file_hf_hub("realrebelai/KREA-2_GGUFs", "TURBO/Krea-2-Turbo-Q4_K_M.gguf") + } + Krea2Weight::Q5_K => { + download_file_hf_hub("realrebelai/KREA-2_GGUFs", "TURBO/Krea-2-Turbo-Q5_K_S.gguf") + } + Krea2Weight::Q6_K => { + download_file_hf_hub("realrebelai/KREA-2_GGUFs", "TURBO/Krea-2-Turbo-Q6_K.gguf") + } + }?; + let (mut config, mut model_config) = krea2_common(sd_type_t)?; + model_config.diffusion_model(model); + config.steps(4); + Ok((config, model_config)) +} + +fn krea2_common(sd_type_t: Krea2Weight) -> Result { + let llm = if sd_type_t == Krea2Weight::Q8_0 { + download_file_hf_hub( + "Qwen/Qwen3-VL-4B-Instruct-GGUF", + "Qwen3VL-4B-Instruct-Q8_0.gguf", + )? + } else { + download_file_hf_hub( + "Qwen/Qwen3-VL-4B-Instruct-GGUF", + "Qwen3VL-4B-Instruct-Q4_K_M.gguf", + )? + }; + let vae = download_file_hf_hub( + "Comfy-Org/Wan_2.1_ComfyUI_repackaged", + "split_files/vae/wan_2.1_vae.safetensors", + )?; + + let config = ConfigBuilder::default(); + let mut model_config = ModelConfigBuilder::default(); + + model_config + .llm(llm) + .vae(vae) + .diffusion_flash_attention(true); + + offload_params_to_cpu((config, model_config)) +} diff --git a/sys/stable-diffusion.cpp b/sys/stable-diffusion.cpp index f440ad9..8caa3f9 160000 --- a/sys/stable-diffusion.cpp +++ b/sys/stable-diffusion.cpp @@ -1 +1 @@ -Subproject commit f440ad9c29dd8bc34e5d1f4b863832b96d6ea05f +Subproject commit 8caa3f908ae6d4a4bef531e73b9a969f266a3d1f