vantagewithai commited on
Commit
b7ca340
·
verified ·
1 Parent(s): d11a7a3

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +137 -0
README.md ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ license: other
5
+ license_name: flux-non-commercial-license
6
+ tags:
7
+ - image-generation
8
+ - image-editing
9
+ - flux
10
+ - diffusion-single-file
11
+ pipeline_tag: image-to-image
12
+ library_name: diffusers
13
+ ---
14
+
15
+ **Quantized GGUF version of FLUX.2-klein-9b-kv**
16
+
17
+ **Original model Link:** [https://huggingface.co/black-forest-labs/FLUX.2-klein-9b-kv](https://huggingface.co/black-forest-labs/FLUX.2-klein-9b-kv)
18
+
19
+ **Watch us at Youtube:** [@VantageWithAI](https://www.youtube.com/@vantagewithai)
20
+
21
+ ![Teaser](https://huggingface.co/black-forest-labs/FLUX.2-klein-9b-kv/resolve/main/realism.jpg)
22
+ ![Teaser](https://huggingface.co/black-forest-labs/FLUX.2-klein-9b-kv/resolve/main/editing.jpg)
23
+ ![Teaser](https://huggingface.co/black-forest-labs/FLUX.2-klein-9b-kv/resolve/main/others.jpg)
24
+
25
+ `FLUX.2 [klein] 9B-KV` is an optimized variant of FLUX.2 [klein] 9B with **KV-cache support for accelerated multi-reference editing**. This variant caches key-value pairs from reference images during the first denoising step, eliminating redundant computation in subsequent steps for significantly faster multi-image editing workflows.
26
+
27
+ For more information about FLUX.2 [klein], please read our [blog post](https://bfl.ai/blog/flux2-klein-towards-interactive-visual-intelligence).
28
+
29
+ # **Key Features**
30
+
31
+ 1. **KV-Cache Optimization**: Reference image KV pairs are computed once and cached, reducing computation and speeding up inference by up to 2.5 times for multi-reference editing tasks.
32
+ 2. All capabilities of FLUX.2 [klein] 9B: sub-second generation, text-to-image, and multi-reference editing in a single unified model.
33
+ 3. Ideal for interactive applications and real-time editing pipelines where the same reference images are used across multiple generations.
34
+ 4. 9B flow model with 8B Qwen3 text embedder, step-distilled to 4 inference steps.
35
+ 5. Available for non-commercial use.
36
+
37
+ # **How KV-Caching Works**
38
+
39
+ In standard image editing, reference image tokens are processed at every denoising step. With KV-caching:
40
+
41
+ - **Step 0**: Full forward pass processes reference tokens and extracts their key-value pairs into a cache.
42
+ - **Steps 1-3**: Cached KV pairs are reused, skipping redundant reference token computation.
43
+
44
+ This is particularly beneficial when:
45
+ - Editing with multiple reference images
46
+ - Generating variations with the same references
47
+ - Building interactive editing applications
48
+
49
+ # **Usage**
50
+
51
+ We provide a reference implementation in our [GitHub repository](https://github.com/black-forest-labs/flux2).
52
+
53
+ ## **API Endpoints**
54
+
55
+ FLUX.2 [klein] 9B-KV is available via the BFL API at [bfl.ai](https://bfl.ai).
56
+
57
+ ## **Using with Diffusers 🧨**
58
+
59
+ To use FLUX.2 [klein] 9B-KV with the 🧨 Diffusers python library, first install or upgrade diffusers:
60
+
61
+ ```shell
62
+ pip install git+https://github.com/huggingface/diffusers.git
63
+ ```
64
+ Then you can use Flux2KleinKVPipeline to run the model:
65
+ ```python
66
+ import torch
67
+ from diffusers import Flux2KleinKVPipeline
68
+
69
+ device = "cuda"
70
+ dtype = torch.bfloat16
71
+ model_path = "black-forest-labs/FLUX.2-klein-9b-kv"
72
+
73
+ pipe = Flux2KleinKVPipeline.from_pretrained(model_path, torch_dtype=dtype)
74
+ pipe.to(device)
75
+
76
+ # Text-to-image (no reference image)
77
+ print("Generating text-to-image...")
78
+ image = pipe(
79
+ prompt="A cat holding a sign that says hello world",
80
+ height=1024,
81
+ width=1024,
82
+ num_inference_steps=4,
83
+ generator=torch.Generator(device=device).manual_seed(0),
84
+ ).images[0]
85
+ image.save("t2i_output.png")
86
+ print("Saved t2i_output.png")
87
+
88
+ # Image-to-image with KV cache (using the generated image as reference)
89
+ print("Generating image-to-image with KV cache...")
90
+ image_kv = pipe(
91
+ prompt="A cat dressed like a wizard",
92
+ image=image,
93
+ height=1024,
94
+ width=1024,
95
+ num_inference_steps=4,
96
+ generator=torch.Generator(device=device).manual_seed(0),
97
+ ).images[0]
98
+ image_kv.save("kv_output.png")
99
+ print("Saved kv_output.png")
100
+ ```
101
+
102
+ ---
103
+
104
+ # Limitations
105
+
106
+ - This model is not intended or able to provide factual information.
107
+ - While the model can output text, text rendered may be inaccurate or subject to distortion.
108
+ - As a statistical model, this checkpoint may represent or amplify biases observed in the training data.
109
+ - The model may fail to generate output that matches the prompts.
110
+ - Prompt following is heavily influenced by the prompting style.
111
+
112
+ # Out-of-Scope Use
113
+
114
+ This model and its derivatives may not be used outside the scope of the license, including for unlawful, fraudulent, defamatory, abusive, or otherwise violative purposes as further explained in our Usage Policies.
115
+
116
+ # Hardware
117
+
118
+ The FLUX.2 [klein] 9B-KV model fits in ~29GB VRAM and is accessible on NVIDIA RTX 5090 and above.
119
+
120
+ ---
121
+
122
+ # Responsible AI Development
123
+
124
+ Black Forest Labs is committed to responsible model development and deployment. Prior to releasing FLUX.2 [klein] 9B-KV, we evaluated and mitigated a number of risks, including child sexual abuse material (CSAM) and nonconsensual intimate imagery (NCII). For detailed information about our mitigations, evaluation processes, content provenance features, and policies, please see our post: [Capable, Open, and Safe: Combating AI
125
+ Misuse](https://bfl.ai/blog/capable-open-and-safe-combating-ai-misuse).
126
+
127
+ To report safety concerns, contact safety@blackforestlabs.ai.
128
+
129
+ ---
130
+
131
+ # License
132
+
133
+ This model falls under the [FLUX Non-Commercial License](https://huggingface.co/black-forest-labs/FLUX.2-klein-9b-kv-fp8/blob/main/LICENSE).
134
+
135
+ # Trademarks & IP
136
+
137
+ This project may contain trademarks or logos for projects, products, or services. Use of Black Forest Labs and FLUX trademarks or logos in modified versions of this project must not cause confusion or imply sponsorship or endorsement. Any use of third-party trademarks, intellectual property or logos are subject to those third-party's policies.