File size: 2,253 Bytes
1a8f224
 
 
 
 
 
 
 
 
 
 
3be3841
1a8f224
 
 
 
 
 
32ce5cd
 
 
 
1a8f224
 
0a411f1
1a8f224
 
 
0a411f1
 
 
 
32ce5cd
0a411f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
---
language:
- en
license: other
license_name: krea-2-community-license
license_link: https://huggingface.co/OzzyGT/Krea_2_Turbo_sdnq_dynamic_4bit/blob/main/LICENSE.pdf
base_model:
  - krea/Krea-2-Turbo
base_model_relation: quantized
tags:
- image-generation
- krea2
- sdnq
pipeline_tag: text-to-image
library_name: diffusers
---
# Krea 2 Turbo SDNQ Dynamic INT4

![bf16 vs SDNQ int4 comparison](comparison_bf16_vs_sdnq.png)

*Left: original bf16  ·  Right: this SDNQ int4 model (same prompt and seed).*

This is an int4 quantized version of [krea/Krea-2-Turbo](https://huggingface.co/krea/Krea-2-Turbo) using [SDNQ](https://github.com/Disty0/sdnq) (SD.Next Quantization) with the dynamic option and Hadamard Rotation.

Note: You need SDNQ v0.2.0 or v0.2.2 and above (v0.2.1 is incompatible)

## Usage

You can find ready-to-use scripts in the [diffusers-recipes](https://github.com/asomoza/diffusers-recipes/blob/main/models/krea2_turbo/README.md) repository.

## Sample image

The quantized (right) image above was generated with the following prompt and settings (seed `7`):

```python
import sdnq  # register the SDNQ backend before loading
import torch
from diffusers import DiffusionPipeline

pipe = DiffusionPipeline.from_pretrained("OzzyGT/Krea_2_Turbo_sdnq_dynamic_4bit", torch_dtype=torch.bfloat16)
pipe.to("cuda")

prompt = (
    "A cozy corner bookstore-cafe on a rainy evening, cinematic wide shot. "
    'A large hand-lettered chalkboard sign in the window reads "FRESH COFFEE & OLD BOOKS" '
    "and below it in smaller chalk letters \"open 'til late\". "
    "Warm golden light spills onto wet cobblestones that mirror pink and blue neon reflections. "
    "Inside, tall mahogany shelves are packed with hundreds of colorful book spines with tiny legible titles, "
    "a barista in a striped apron pours delicate latte art, steam curling upward, "
    "a tabby cat sleeps on a windowsill beside a stack of paperbacks. "
    "Intricate detail, sharp focus, shallow depth of field, photorealistic, rich color grading."
)

image = pipe(
    prompt,
    num_inference_steps=8,
    guidance_scale=0.0,
    height=1024,
    width=1024,
    generator=torch.Generator("cuda").manual_seed(7),
).images[0]
image.save("sample.png")
```