Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,8 @@ fn get_preset(args: &Args) -> Preset {
.try_into()
.unwrap(),
),
PresetDiscriminants::Lens => Preset::Lens,
PresetDiscriminants::LensTurbo => Preset::LensTurbo,
};
preset
}
34 changes: 27 additions & 7 deletions src/preset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ use crate::{
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, 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,
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,
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,
},
};

Expand Down Expand Up @@ -339,6 +339,12 @@ pub enum Preset {
/// Requires access rights to <https://huggingface.co/black-forest-labs/FLUX.1-dev> providing a token via [crate::util::set_hf_token]
/// cfg_scale 5.0. Enable [crate::api::SampleMethod::EULER_SAMPLE_METHOD] and Diffusion Flash attention. flow_shift 3.0. 512 x 512. 20 steps
LongCatImage(LongCatImageWeight),
/// Requires access rights to <https://huggingface.co/black-forest-labs/FLUX.2-dev> providing a token via [crate::util::set_hf_token]
/// cfg_scale 5.0. Enable Model Diffusion Flash attention. 512x512
Lens,
/// Requires access rights to <https://huggingface.co/black-forest-labs/FLUX.2-dev> providing a token via [crate::util::set_hf_token]
/// cfg_scale 1.0. Enable Model Diffusion Flash attention. 512x512. 4 steps
LensTurbo,
}

impl Preset {
Expand Down Expand Up @@ -383,6 +389,8 @@ impl Preset {
Preset::HiDreamO1ImageDev => hi_dream_o1_image_dev(),
Preset::HiDreamO1Image => hi_dream_o1_image(),
Preset::LongCatImage(sd_type_t) => long_cat_image(sd_type_t),
Preset::Lens => lens(),
Preset::LensTurbo => lens_turbo(),
}
}
}
Expand Down Expand Up @@ -711,7 +719,19 @@ mod tests {
}
#[ignore]
#[test]
fn long_cat_image() {
fn test_long_cat_image() {
run(Preset::LongCatImage(super::LongCatImageWeight::Q4_0));
}

#[ignore]
#[test]
fn test_lens() {
run(Preset::Lens);
}

#[ignore]
#[test]
fn test_lens_turbo() {
run(Preset::LensTurbo);
}
}
35 changes: 35 additions & 0 deletions src/preset_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1679,3 +1679,38 @@ fn long_cat_image_weight_llm(sd_type: LongCatImageWeight) -> Result<(PathBuf, Pa
let llm_path = download_file_hf_hub(llm.0, llm.1)?;
Ok((model_path, llm_path))
}

pub fn lens_turbo() -> Result<ConfigsBuilder, ApiError> {
let vae = download_file_hf_hub("black-forest-labs/FLUX.2-dev", "ae.safetensors")?;
let llm = download_file_hf_hub("unsloth/gpt-oss-20b-GGUF", "gpt-oss-20b-UD-Q4_K_XL.gguf")?;
let model = download_file_hf_hub(
"Comfy-Org/Lens",
"diffusion_models/lens_turbo_bf16.safetensors",
)?;
let mut config = ConfigBuilder::default();
let mut model_config = ModelConfigBuilder::default();
model_config
.diffusion_model(model)
.llm(llm)
.vae(vae)
.diffusion_flash_attention(true);
config.cfg_scale(1.).steps(4).height(512).width(512);

Ok((config, model_config))
}

pub fn lens() -> Result<ConfigsBuilder, ApiError> {
let vae = download_file_hf_hub("black-forest-labs/FLUX.2-dev", "ae.safetensors")?;
let llm = download_file_hf_hub("unsloth/gpt-oss-20b-GGUF", "gpt-oss-20b-UD-Q4_K_XL.gguf")?;
let model = download_file_hf_hub("Comfy-Org/Lens", "diffusion_models/lens_bf16.safetensors")?;
let mut config = ConfigBuilder::default();
let mut model_config = ModelConfigBuilder::default();
model_config
.diffusion_model(model)
.llm(llm)
.vae(vae)
.diffusion_flash_attention(true);
config.cfg_scale(5.).height(512).width(512);

Ok((config, model_config))
}
Loading