Skip to content

Commit f988643

Browse files
authored
Merge pull request #25 from DarthAffe/DarthAffe-patch-4
Update README.md
2 parents 4d6bc12 + 51deca5 commit f988643

File tree

1 file changed

+34
-3
lines changed

1 file changed

+34
-3
lines changed

README.md

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,43 @@ If GPU-support is available it will prefer this over CPU.
1313
If you want to add your own native-libraries or need more control over which backend to load, check the static `Backends` class.
1414

1515
### Example
16+
#### 1. Create a model
17+
18+
stable diffusion:
19+
```csharp
20+
using DiffusionModel model = ModelBuilder.StableDiffusion(@"<path to model")
21+
.WithVae(@"<optional path to vae>")
22+
.WithMultithreading()
23+
.Build();
24+
```
25+
26+
flux:
1627
```csharp
17-
using StableDiffusionModel sd = new(@"<path_to_model>", new ModelParameter());
18-
IImage<ColorRGB> image = sd.TextToImage("<prompt>", new StableDiffusionParameter());
28+
using DiffusionModel model = ModelBuilder.Flux(@"<path to flux-model.gguf>",
29+
@"<path to clip_l.safetensors>",
30+
@"<path to t5xxl_fp16.safetensors>",
31+
@"<path to ae.safetensors>")
32+
.WithMultithreading()
33+
.Build();
1934
```
2035

36+
#### 2. create image
37+
38+
with default parameters:
39+
```csharp
40+
IImage<ColorRGB> image = model.TextToImage("<prompt>");
41+
```
42+
43+
with custom parameters:
44+
```csharp
45+
IImage<ColorRGB> image = model.TextToImage("<prompt>", model.GetDefaultParameter().WithSeed(1234).WithSize(1344, 768));
46+
```
47+
48+
#### 3. (optional) save the image (requires System.Dawing or SkiaSharp extension)
49+
```csharp
50+
File.WriteAllBytes("output.png", image.ToPng());
51+
```
2152

2253
To process the resulting image further you can write your own extensions or install one of the [HPPH](https://github.com/DarthAffe/HPPH)-extension sets:
2354
[HPPH.System.Drawing](https://www.nuget.org/packages/HPPH.System.Drawing)
24-
[HPPH.SkiaSharp](https://www.nuget.org/packages/HPPH.SkiaSharp)
55+
[HPPH.SkiaSharp](https://www.nuget.org/packages/HPPH.SkiaSharp)

0 commit comments

Comments
 (0)