Updated readme

This commit is contained in:
DarthAffe 2025-10-27 19:56:48 +01:00
parent 4348323abc
commit 68064e282d

View File

@ -27,11 +27,11 @@ StableDiffusionCpp.Progress += (_, args) => Console.WriteLine($"PROGRESS {args.S
Image<ColorRGB>? treeWithTiger; Image<ColorRGB>? treeWithTiger;
// Load a StableDiffusion model in a using block to unload it again after the two images are created // Load a StableDiffusion model in a using block to unload it again after the two images are created
using (DiffusionModel sd = ModelBuilder.StableDiffusion(@"<path to model") using (DiffusionModel sd = new(DiffusionModelParameter.Create()
// .WithVae(@"<optional path to vae>") .WithModelPath(@"N:\StableDiffusion\stable-diffusion-webui\models\Stable-diffusion\animagineXLV3_v30.safetensors")
.WithMultithreading() // .WithVae(@"<optional path to vae>")
.WithFlashAttention() .WithMultithreading()
.Build()) .WithFlashAttention()))
{ {
// Create a image from a prompt // Create a image from a prompt
Image<ColorRGB>? tree = sd.GenerateImage(ImageGenerationParameter.TextToImage("A beautiful tree standing on a small hill").WithSDXLDefaults()); Image<ColorRGB>? tree = sd.GenerateImage(ImageGenerationParameter.TextToImage("A beautiful tree standing on a small hill").WithSDXLDefaults());
@ -43,17 +43,24 @@ using (DiffusionModel sd = ModelBuilder.StableDiffusion(@"<path to model")
File.WriteAllBytes("image2.png", treeWithTiger.ToPng()); File.WriteAllBytes("image2.png", treeWithTiger.ToPng());
} }
// Load a flux kontext model // Load the qwen image edit model
using DiffusionModel flux = ModelBuilder.Flux(@"<path to flux-model.gguf>", using DiffusionModel qwenContext = new(DiffusionModelParameter.Create()
@"<path to clip_l.safetensors>", .WithDiffusionModelPath(@"<Qwen-Image-Edit-2509-path>")
@"<path to t5xxl_fp16.safetensors>", .WithQwen2VLPath(@"<Qwen2.5-VL-7B-Instruct-path>")
@"<path to ae.safetensors>") .WithQwen2VLVisionPath(@"<Qwen2.5-VL-7B-Instruct.mmproj-path>")
.WithMultithreading() .WithVae(@"<qwen_image_vae-path>")
.WithFlashAttention() .WithMultithreading()
.Build(); .WithFlashAttention()
.WithFlowShift(3)
.WithOffloadedParamsToCPU()
.WithImmediatelyFreedParams());
// Perform an edit on the previosly created image // Perform an edit on the previously created image
Image<ColorRGB>? tigerOnMoon = flux.GenerateImage(ImageGenerationParameter.TextToImage("Remove the hill with the grass and place the tree with the tiger on the moon").WithFluxDefaults().WithRefImages(treeWithTiger)); Image<ColorRGB>? tigerOnMoon = qwenContext.GenerateImage(ImageGenerationParameter.TextToImage("Remove the background and place the tree and the tiger on the moon.")
.WithSize(1024, 1024)
.WithCfg(2.5f)
.WithSampler(Sampler.Euler)
.WithRefImages(treeWithTiger));
File.WriteAllBytes("image3.png", tigerOnMoon.ToPng()); File.WriteAllBytes("image3.png", tigerOnMoon.ToPng());
``` ```