csssss commited on
Commit
d71310e
·
verified ·
1 Parent(s): 6313156

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +37 -17
README.md CHANGED
@@ -1,41 +1,54 @@
 
 
 
 
1
  ---
2
  license: apache-2.0
3
  ---
4
- FLUX.2-klein-4B 整合GGUF权重包
5
 
6
- 模型说明
7
- 本仓库为整合版权重仓库,仅做文件归集、整合打包,无任何权重训练、微调、参数修改操作:
8
- - GGUF量化Transformer主干:来源于 unsloth/FLUX.2-klein-4B-GGUF
9
- 采用 Unsloth Dynamic 2.0 量化方案,关键层保留高精度,极致平衡推理速度与生成画质。
10
- - VAE、模型配置、原生配套资源:来源于官方基座 black-forest-labs/FLUX.2-klein-4B
11
- -
12
- 原始来源链接
13
- - GGUF量化主干模型:https://huggingface.co/unsloth/FLUX.2-klein-4B-GGUF
14
- - FLUX.2-klein-4B 官方原始基座:https://huggingface.co/black-forest-labs/FLUX.2-klein-4B
15
- -
16
- 修改说明
17
- 本项目仅将两个上游仓库资源整合归集:将 Unsloth 量化的 GGUF Transformer 权重,与官方完整 VAE、模型配置文件合并为一体,方便本地 GGUF 推理、ComfyUI 及 diffusers 一键加载。未修改权重参数、未微调、未重量化、未蒸馏。
18
 
 
19
 
 
 
20
 
 
21
 
22
- 快速使用 / 推理示例
23
 
 
 
 
 
 
 
 
24
 
25
- 安装依赖
26
- pip install torch sdnq diffusers huggingface-hub
27
- 完整可运行代码
28
 
29
 
 
30
 
 
 
 
 
 
 
 
 
 
31
  import torch
32
  from sdnq import SDNQConfig
33
  from diffusers import Flux2KleinPipeline, Flux2Transformer2DModel, GGUFQuantizationConfig
34
  from huggingface_hub import hf_hub_download
35
 
 
36
  device = "cuda"
37
  dtype = torch.bfloat16
38
 
 
39
  gguf_path = hf_hub_download(
40
  repo_id="csssss/com2ai-klein-4b",
41
  filename="transformer/flux-2-klein-4b-Q8_0.gguf",
@@ -46,6 +59,7 @@ config_path = hf_hub_download(
46
  filename="transformer/config.json",
47
  )
48
 
 
49
  transformer = Flux2Transformer2DModel.from_single_file(
50
  gguf_path,
51
  quantization_config=GGUFQuantizationConfig(compute_dtype=dtype),
@@ -53,14 +67,17 @@ transformer = Flux2Transformer2DModel.from_single_file(
53
  config=config_path
54
  )
55
 
 
56
  pipe = Flux2KleinPipeline.from_pretrained(
57
  "csssss/com2ai-klein-4b",
58
  transformer=transformer,
59
  torch_dtype=dtype
60
  )
61
 
 
62
  pipe.enable_model_cpu_offload()
63
 
 
64
  prompt = "A cat holding a sign that says hello world"
65
  image = pipe(
66
  prompt=prompt,
@@ -71,5 +88,8 @@ image = pipe(
71
  generator=torch.Generator(device=device).manual_seed(0)
72
  ).images[0]
73
 
 
74
  image.save("flux-klein.png")
75
  print("✅ 图像生成成功,已保存为 flux-klein.png")
 
 
 
1
+ # FLUX\.2\-klein\-4B 整合GGUF权重包
2
+
3
+
4
+ ```Plain Text
5
  ---
6
  license: apache-2.0
7
  ---
8
+ ```
9
 
10
+ ## 模型说明
 
 
 
 
 
 
 
 
 
 
 
11
 
12
+ 本仓库为**整合版权重仓库**,仅做文件归集、整合打包,无任何权重训练、微调、参数修改操作:
13
 
14
+ - **GGUF量化Transformer主干**:来源于 `unsloth/FLUX.2-klein-4B-GGUF`
15
+ 采用 Unsloth Dynamic 2\.0 量化方案,关键层保留高精度,极致平衡推理速度与生成画质。
16
 
17
+ - **VAE、模型配置、原生配套资源**:来源于官方基座 `black-forest-labs/FLUX.2-klein-4B`
18
 
19
+ ## 原始来源链接
20
 
21
+ - GGUF量化主干模型:[https://huggingface\.co/unsloth/FLUX\.2\-klein\-4B\-GGUF](https://huggingface.co/unsloth/FLUX.2-klein-4B-GGUF)
22
+
23
+ - FLUX\.2\-klein\-4B 官方原始基座:[https://huggingface\.co/black\-forest\-labs/FLUX\.2\-klein\-4B](https://huggingface.co/black-forest-labs/FLUX.2-klein-4B)
24
+
25
+ ## 修改说明
26
+
27
+ 本项目仅将两个上游仓库资源整合归集:将 Unsloth 量化的 GGUF Transformer 权重,与官方完整 VAE、模型配置文件合并为一体,方便本地diffusers GGUF 推理、。**未修改权重参数、未微调、未重量化、未蒸馏**。
28
 
 
 
 
29
 
30
 
31
+ ## 快速使用 / 推理示例(官方标准写法)
32
 
33
+ ### 安装依赖
34
+
35
+ ```Plain Text
36
+ pip install torch sdnq diffusers huggingface-hub
37
+ ```
38
+
39
+ ### 完整可运行代码
40
+
41
+ ```Plain Text
42
  import torch
43
  from sdnq import SDNQConfig
44
  from diffusers import Flux2KleinPipeline, Flux2Transformer2DModel, GGUFQuantizationConfig
45
  from huggingface_hub import hf_hub_download
46
 
47
+ # 设备与精度配置
48
  device = "cuda"
49
  dtype = torch.bfloat16
50
 
51
+ # 精准下载本仓库 GGUF 权重与配置文件
52
  gguf_path = hf_hub_download(
53
  repo_id="csssss/com2ai-klein-4b",
54
  filename="transformer/flux-2-klein-4b-Q8_0.gguf",
 
59
  filename="transformer/config.json",
60
  )
61
 
62
+ # 加载量化 Transformer
63
  transformer = Flux2Transformer2DModel.from_single_file(
64
  gguf_path,
65
  quantization_config=GGUFQuantizationConfig(compute_dtype=dtype),
 
67
  config=config_path
68
  )
69
 
70
+ # 加载完整 FLUX 推理管道(含官方VAE)
71
  pipe = Flux2KleinPipeline.from_pretrained(
72
  "csssss/com2ai-klein-4b",
73
  transformer=transformer,
74
  torch_dtype=dtype
75
  )
76
 
77
+ # 显存优化
78
  pipe.enable_model_cpu_offload()
79
 
80
+ # 文生图推理示例
81
  prompt = "A cat holding a sign that says hello world"
82
  image = pipe(
83
  prompt=prompt,
 
88
  generator=torch.Generator(device=device).manual_seed(0)
89
  ).images[0]
90
 
91
+ # 保存结果
92
  image.save("flux-klein.png")
93
  print("✅ 图像生成成功,已保存为 flux-klein.png")
94
+ ```
95
+